Skip to content

Instantly share code, notes, and snippets.

@fantods
Last active February 11, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fantods/7ed877ab2dbf172ec8b0b7343d97e07b to your computer and use it in GitHub Desktop.
Save fantods/7ed877ab2dbf172ec8b0b7343d97e07b to your computer and use it in GitHub Desktop.
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