Skip to content

Instantly share code, notes, and snippets.

View harrisonford's full-sized avatar
📈
Never code Han Solo.

Kristofher Muñoz Rojas harrisonford

📈
Never code Han Solo.
View GitHub Profile
import json
import numpy as np
import pandas as pd
from pycocotools import mask as cocomask
# global order used when doing annotations, used when people tag without adding id's (because it's faster)
# I use this because when I tagged stuff with other people we didn't manually add the tags, but we tagged always
# in the same order so I can auto-tag the ID now.
tag_order = ['right_ankle', 'right_knee', 'right_hip', 'left_hip', 'left_knee', 'left_ankle', 'pelvis', 'thorax',
# convert VIA-VGG annotations to MSCOCO JSON format
def load_annotations(json_path):
with open(json_path) as f:
annotations = json.load(f)
return annotations
def via2coco(via_json, output_path):
@harrisonford
harrisonford / gist:7a86ea5790e7dc24543c0aece92ede31
Created July 11, 2018 19:49
Implements NSS (Natural Scanpath Saliency) scoring function from MIT Benchmark page for python
import numpy.ma as ma
# NOTE: THIS FUNCTION ASUMES BOTH MAPS ARE SAME SIZE! (modify to generalize)
# And also salmap, fixmap are np.arrays or equivalent
def nss(salmap, fixmap, threshold=0):
# Z-score salmap and binarize fixmap
salmap_scored = (salmap - salmap.mean())/salmap.std()
fixmap_mask = fixmap <= threshold # all these '1' values are going to be eliminated using mask