Last active
February 11, 2019 17:54
-
-
Save fantods/7ed877ab2dbf172ec8b0b7343d97e07b to your computer and use it in GitHub Desktop.
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
NUM_CLASSES = 228 | |
with open("data/train.json") as train: | |
train_json = json.load(train) | |
def generate_label_array(json_obj): | |
result = [] | |
for data in json_obj['annotations']: | |
temp_array = [0] * NUM_CLASSES | |
for elem in data['labelId']: | |
temp_array[int(elem) - 1] = 1 | |
result.append(temp_array) | |
return np.array(result) | |
train_urls = [obj['url'] for obj in train_json['images']] | |
train_labels = generate_label_arrays(train_json) | |
print(train_urls[0]) | |
# => https://contestimg.wish.com/api/webimage/570f35feb2f4b95d223aa9b1-large |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment