Skip to content

Instantly share code, notes, and snippets.


Henrique Mendonça henrique

View GitHub Profile
henrique / imagenet1000_clsidx_to_labels.json
Last active Jul 27, 2021
ImageNet 1k (ILSVRC2012) classes and WordNet synsets
View imagenet1000_clsidx_to_labels.json
"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",
henrique / cifar100.json
Last active Jul 25, 2021
CIFAR100 classes list (and 20 superclasses) as in
View cifar100.json
"classes": ["apple", "aquarium_fish", "baby", "bear", "beaver", "bed", "bee", "beetle", "bicycle", "bottle", "bowl", "boy", "bridge", "bus", "butterfly", "camel", "can", "castle", "caterpillar", "cattle", "chair", "chimpanzee", "clock", "cloud", "cockroach", "couch", "crab", "crocodile", "cup", "dinosaur", "dolphin", "elephant", "flatfish", "forest", "fox", "girl", "hamster", "house", "kangaroo", "keyboard", "lamp", "lawn_mower", "leopard", "lion", "lizard", "lobster", "man", "maple_tree", "motorcycle", "mountain", "mouse", "mushroom", "oak_tree", "orange", "orchid", "otter", "palm_tree", "pear", "pickup_truck", "pine_tree", "plain", "plate", "poppy", "porcupine", "possum", "rabbit", "raccoon", "ray", "road", "rocket", "rose", "sea", "seal", "shark", "shrew", "skunk", "skyscraper", "snail", "snake", "spider", "squirrel", "streetcar", "sunflower", "sweet_pepper", "table", "tank", "telephone", "television", "tiger", "tractor", "train", "trout", "tulip", "turtle", "wardrobe", "whale", "willow_tree", "wolf", "
View gee_reduce_n_reproject.js
// Make a suitable image for `reduceConnectedComponents()`
// by adding a label band to the `img_pop3` image.
img_pop3 = img_pop3.addBands('labels'));
// Calculate the total population in demand area
// defined by the previously added "labels" band
// and reproject to original scale
var patchPop = img_pop3.reduceConnectedComponents({
reducer: ee.Reducer.sum(),
labelBand: 'labels',
View gee_segmentation_n_patches.js
// GMeans Segmentation
var seg = ee.Algorithms.Image.Segmentation.GMeans(, 3, 50, 10);
Map.addLayer(seg.randomVisualizer(), {opacity:0.5}, 'GMeans Segmentation');
// SNIC Segmentation
var snic = ee.Algorithms.Image.Segmentation.SNIC(, 30, 0, 8, 300);
Map.addLayer(snic.randomVisualizer(), {opacity:0.5}, 'SNIC Segmentation');
// Uniquely label the patches and visualize.
var patchid =
.connectedComponents(, 256);
View gee_electricity_demand_nga.js
// GRID3 population data
var img_pop3 = ee.ImageCollection('users/henrique/GRID3_NGA_PopEst_v1_1_mean_float')
// Nigerian nightlights (1Y median)
var nighttime = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG')
.filter('2018–09–01', '2019–09–30'))
// Demand layer
var demand = img_pop3.gte(pop_threshold) // threshold population
View gist:f8c45f0e7aa09d72c3b8
"number": 0,
"timestamp": 1433080800
"number": -6,
"timestamp": 1433084400