tcsenpai commited on
Commit
dc774e7
·
1 Parent(s): 6e0f7b7

Upload example.py

Browse files
Files changed (1) hide show
  1. example.py +23 -0
example.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # TF for image classification model
3
+
4
+ import tensorflow
5
+ import numpy
6
+ from PIL import Image
7
+
8
+ model = tensorflow.saved_model.load('./')
9
+ classes = [ "naked" , "dressed" , ]
10
+
11
+ img = Image.open("image.jpg").convert('RGB')
12
+ img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
13
+ inp_numpy = numpy.array(img)[None]
14
+
15
+
16
+ inp = tensorflow.constant(inp_numpy, dtype='float32')
17
+
18
+ class_scores = model(inp)[0].numpy()
19
+
20
+
21
+ print("")
22
+ print("class_scores", class_scores)
23
+ print("Class : ", classes[class_scores.argmax()])