-
Notifications
You must be signed in to change notification settings - Fork 7
/
showImages.py
38 lines (28 loc) · 1.02 KB
/
showImages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import matplotlib.pyplot as plt
imageFolder = 'dataset'
featuresFolder = 'features'
annotations = np.load('%s/annotations_train2017.npy' % (featuresFolder), allow_pickle=True).item()
annotations.update(np.load('%s/annotations_val2017.npy' % (featuresFolder), allow_pickle=True).item())
def showImage(imageId):
imageName = '000000%s.jpg' % (imageId)
try:
image = plt.imread('%s/%s/%s' % (imageFolder, 'train2017', imageName))
except:
image = plt.imread('%s/%s/%s' % (imageFolder, 'val2017', imageName))
plt.imshow(image)
plt.show()
def showAnnotations(imageId):
print("\nAnnotation for image %s:" % imageId)
for annotation in annotations[imageId]:
print(annotation)
def show(imageIds, image=True, annotation=True):
if type(imageIds) is not list:
imageIds = [imageIds]
for imageId in imageIds:
if annotation:
showAnnotations(imageId)
if image:
showImage(imageId)
if __name__ == '__main__':
show(['329084'])