This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# see https://github.com/microsoft/RoadDetections | |
# 1) get the data | |
wget https://usaminedroads.blob.core.windows.net/road-detections/Oceania-Full.zip | |
# 2) extract the records for Australia, second column of tsv only | |
zgrep AUS Oceania-Full.zip | cut -f2 > AUS.geojson | |
# 3) convert to GPKG, works better in QGIS |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Importing Necessary Modules | |
import requests # to get image from the web | |
import shutil # to save it locally | |
## Set up the image URL and filename | |
image_url = "https://cdn.pixabay.com/photo/2020/02/06/09/39/summer-4823612_960_720.jpg" | |
filename = image_url.split("/")[-1] | |
# Open the url image, set stream to True, this will return the stream content. | |
r = requests.get(image_url, stream = True) |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A syllable dictionary I built with Python. See https://zacs.site/blog/building-a-syllable-dictionary-with-python.html for the full writeup. | |
# | |
# This work is licensed under a Creative Commons Attribution 4.0 International License | |
# See https://zacs.site/disclaimers.html for more information. | |
# © 2012-2019 Zachary Szewczyk. | |
a,1 | |
a,1 | |
aa,1 | |
aal,-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torchvision import datasets | |
class ImageFolderWithPaths(datasets.ImageFolder): | |
"""Custom dataset that includes image file paths. Extends | |
torchvision.datasets.ImageFolder | |
""" | |
# override the __getitem__ method. this is the method that dataloader calls | |
def __getitem__(self, index): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://en.wikipedia.org/wiki/Fisher-Yates_shuffle#The_modern_algorithm | |
// https://stackoverflow.com/a/12646864/2684520 | |
// Pre-ES6 | |
/** | |
* Randomize array element order in-place. | |
* Using Durstenfeld shuffle algorithm. | |
*/ | |
function shuffleArray(array) { | |
for (var i = array.length - 1; i > 0; i--) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#%% (0) Important libraries | |
import tensorflow as tf | |
import numpy as np | |
from numpy import random | |
import matplotlib.pyplot as plt | |
from IPython import display | |
% matplotlib inline | |
#%% (1) Dataset creation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use hacker news API as example | |
async function getData() { | |
const ids = await (await fetch('https://hacker-news.firebaseio.com/v0/topstories.json')).json() | |
const data = Promise.all( | |
ids.map(async (i) => await (await fetch(`https://hacker-news.firebaseio.com/v0/item/${i}.json?print=pretty`)).json()) | |
) | |
return data | |
} | |
getData() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateImageFromText(text, width, height) { | |
// TODO Add auto-wrapping logic when text is too wide | |
// TODO Add tiered text scaling (if height > 200: font-size = 36; else if height > 100: font-size = 18; etc) | |
const canvas = document.createElement('canvas'); | |
canvas.width = width; | |
canvas.height = height; | |
const ctx = canvas.getContext('2d'); | |
const fontSize = Math.min(height, 36); | |
ctx.fillStyle = '#212121'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{0: 'tench, Tinca tinca', | |
1: 'goldfish, Carassius auratus', | |
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', | |
3: 'tiger shark, Galeocerdo cuvieri', | |
4: 'hammerhead, hammerhead shark', | |
5: 'electric ray, crampfish, numbfish, torpedo', | |
6: 'stingray', | |
7: 'cock', | |
8: 'hen', | |
9: 'ostrich, Struthio camelus', |
NewerOlder