Spaces:
Sleeping
Sleeping
resize image instead of crop
Browse files
app.py
CHANGED
@@ -9,12 +9,14 @@ with open('labels.txt','r') as f:
|
|
9 |
|
10 |
def classify_image(inp):
|
11 |
model = tf.keras.models.load_model('saved_model')
|
|
|
|
|
12 |
inp = inp.reshape((-1, 480, 480, 3)).astype(np.float32)
|
13 |
-
inp =
|
14 |
prediction = model.predict(inp).flatten()
|
15 |
return {labels[i]: float(prediction[i]) for i in range(36)}
|
16 |
|
17 |
-
image = gr.inputs.Image(
|
18 |
label = gr.outputs.Label(num_top_classes=3)
|
19 |
|
20 |
gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True, theme = "grass", examples = [["test.jpg"]]).launch()
|
|
|
9 |
|
10 |
def classify_image(inp):
|
11 |
model = tf.keras.models.load_model('saved_model')
|
12 |
+
inp.resize((480,480))
|
13 |
+
inp = np.array(inp)
|
14 |
inp = inp.reshape((-1, 480, 480, 3)).astype(np.float32)
|
15 |
+
inp = inp.divide(inp,255.0)
|
16 |
prediction = model.predict(inp).flatten()
|
17 |
return {labels[i]: float(prediction[i]) for i in range(36)}
|
18 |
|
19 |
+
image = gr.inputs.Image(type='pil')
|
20 |
label = gr.outputs.Label(num_top_classes=3)
|
21 |
|
22 |
gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True, theme = "grass", examples = [["test.jpg"]]).launch()
|