Sa-m commited on
Commit
951e3cc
·
verified ·
1 Parent(s): 4900bb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -41,10 +41,13 @@ model=load_model('Models/best_model1.h5')
41
  # return result
42
 
43
  def classify_image(inp):
44
- inp = inp.reshape((-1, IMG_SIZE, IMG_SIZE, 3))
45
- inp = tf.keras.applications.vgg16.preprocess_input(inp)
46
- prediction = model.predict(inp).flatten()
47
- return {labels[i]: float(prediction[i]) for i in range(NUM_CLASSES)}
 
 
 
48
 
49
  # image = gr.inputs.Image(shape=(IMG_SIZE, IMG_SIZE))
50
  # label = gr.outputs.Label(num_top_classes=2)
 
41
  # return result
42
 
43
  def classify_image(inp):
44
+ # Resize the image to the required size
45
+ inp = tf.image.resize(inp, [IMG_SIZE, IMG_SIZE])
46
+ inp = inp.numpy()
47
+ inp = inp.reshape((-1, IMG_SIZE, IMG_SIZE, 3))
48
+ inp = tf.keras.applications.vgg16.preprocess_input(inp)
49
+ prediction = model.predict(inp).flatten()
50
+ return {labels[i]: float(prediction[i]) for i in range(NUM_CLASSES)}
51
 
52
  # image = gr.inputs.Image(shape=(IMG_SIZE, IMG_SIZE))
53
  # label = gr.outputs.Label(num_top_classes=2)