Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,10 +41,13 @@ model=load_model('Models/best_model1.h5')
|
|
41 |
# return result
|
42 |
|
43 |
def classify_image(inp):
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
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)
|