Delete example.py
Browse files- example.py +0 -23
example.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 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 = [ "not_photo" , "photo" , ]
|
| 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()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|