Skip to content

Commit 121d80a

Browse files
committed
Add simple script to inspect feature files
1 parent 5d405c7 commit 121d80a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'''
2+
This script will open a feature file and inspect it
3+
The feature has a dataset called "images" which contains RGB images of 100,100
4+
It will then create a sample mosaic of 3x3 images using pyplot to let users inspect the features and how they look
5+
'''
6+
7+
import h5py
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
import sys
11+
12+
if len(sys.argv) > 0:
13+
feature_file = sys.argv[1]
14+
else:
15+
feature_file = "features.h5"
16+
17+
# open the file
18+
with h5py.File(feature_file, "r") as f:
19+
# get the images dataset
20+
images = f["images"]
21+
# get the first 9 images
22+
images = images[:9]
23+
# reshape the images to 3x3
24+
#images = np.reshape(images, (3,3,100,100,3))
25+
# transpose the images to 3x3
26+
#images = np.transpose(images, (0,2,1,3,4))
27+
# flatten the images to 9x100x100x3
28+
#images = np.reshape(images, (9,100,100,3))
29+
30+
# hide axis from pyplot
31+
plt.axis('off')
32+
33+
# plot the images
34+
for i in range(9):
35+
plt.subplot(3,3,i+1)
36+
plt.imshow(images[i])
37+
plt.show()
38+
print(f"Image {i+1} is {images[i].shape}")

0 commit comments

Comments
 (0)