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 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', |
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
# 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): |
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 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 |