rrighart commited on
Commit
88927e5
1 Parent(s): e9a74ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -3,7 +3,7 @@ import tensorflow as tf
3
  import numpy as np
4
  from numpy import asarray
5
  from datetime import datetime
6
-
7
 
8
  model = tf.keras.models.load_model("simple-CNN-model.2022-8-9.hdf5")
9
 
@@ -18,7 +18,10 @@ def image_predict(img):
18
  global model
19
  if model is None:
20
  model = tf.keras.models.load_model("models/simple-CNN-model.2022-8-9.hdf5")
21
-
 
 
 
22
  data = np.asarray(img)
23
 
24
  ndata = np.expand_dims(data, axis=0)
@@ -53,14 +56,8 @@ iface = gr.Interface(
53
  description = "App classifying objects on different colors",
54
  article = "<p style='text-align: center'><a href='https://www.rrighart.com' target='_blank'>Webpage</a></p>",
55
  fn=image_predict,
56
- inputs=gr.Image(shape=(227,227)),
57
  outputs=gr.Label(),
58
  examples=['shoes1.jpg', 'shoes2.jpg'],
59
- enable_queue=True,
60
- interpretation="default",
61
- debug=True
62
  )
63
  iface.launch()
64
-
65
-
66
-
3
  import numpy as np
4
  from numpy import asarray
5
  from datetime import datetime
6
+ import cv2
7
 
8
  model = tf.keras.models.load_model("simple-CNN-model.2022-8-9.hdf5")
9
 
18
  global model
19
  if model is None:
20
  model = tf.keras.models.load_model("models/simple-CNN-model.2022-8-9.hdf5")
21
+
22
+ #img = img.reshape((None, 227, 227, 3))
23
+
24
+ img = cv2.resize(img, (227, 227))
25
  data = np.asarray(img)
26
 
27
  ndata = np.expand_dims(data, axis=0)
56
  description = "App classifying objects on different colors",
57
  article = "<p style='text-align: center'><a href='https://www.rrighart.com' target='_blank'>Webpage</a></p>",
58
  fn=image_predict,
59
+ inputs=gr.Image(width=227, height=227), # shape=(227,227)
60
  outputs=gr.Label(),
61
  examples=['shoes1.jpg', 'shoes2.jpg'],
 
 
 
62
  )
63
  iface.launch()