Spaces:
Runtime error
Runtime error
- app.py +15 -5
- images/airplane_003.jpg +0 -0
- images/airport_002.jpg +0 -0
- images/airport_075.jpg +0 -0
- images/beach_002.jpg +0 -0
- images/industrial_area_003.jpg +0 -0
- images/meadow_019.jpg +0 -0
- images/rectangular_farmland_218.jpg +0 -0
- images/ship_018.jpg +0 -0
app.py
CHANGED
|
@@ -52,15 +52,25 @@ with open("scene_labels.json") as labels_file:
|
|
| 52 |
def classify_image(img):
|
| 53 |
img = tf.convert_to_tensor(img, dtype=tf.float32)
|
| 54 |
img = tf.expand_dims(img, axis=0)
|
| 55 |
-
# probs = model.predict(img).flatten()
|
| 56 |
probs = (model(img))[0]
|
| 57 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 58 |
|
| 59 |
image = gr.inputs.Image(shape=(256, 256))
|
| 60 |
label = gr.outputs.Label(num_top_classes=5)
|
| 61 |
-
examples = ['images/airplane_002.jpg',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 64 |
-
intf.launch()
|
| 65 |
-
|
| 66 |
-
# intf.launch(share=True) # ,inline=False
|
|
|
|
| 52 |
def classify_image(img):
|
| 53 |
img = tf.convert_to_tensor(img, dtype=tf.float32)
|
| 54 |
img = tf.expand_dims(img, axis=0)
|
|
|
|
| 55 |
probs = (model(img))[0]
|
| 56 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 57 |
|
| 58 |
image = gr.inputs.Image(shape=(256, 256))
|
| 59 |
label = gr.outputs.Label(num_top_classes=5)
|
| 60 |
+
examples = ['images/airplane_002.jpg',
|
| 61 |
+
'images/airport_002.jpg',
|
| 62 |
+
'images/beach_002.jpg',
|
| 63 |
+
'images/bridge_679.jpg',
|
| 64 |
+
'images/cloud_227.jpg',
|
| 65 |
+
'images/forest_235.jpg',
|
| 66 |
+
'images/rectangular_farmland_218.jpg',
|
| 67 |
+
'images/meadow_019.jpg',
|
| 68 |
+
'images/industrial_area_003.jpg',
|
| 69 |
+
'images/ship_018.jpg',
|
| 70 |
+
'images/freeway_159.jpg',
|
| 71 |
+
'images/airport_075.jpg',
|
| 72 |
+
]
|
| 73 |
|
| 74 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 75 |
+
intf.launch(inline=False)
|
| 76 |
+
|
|
|
images/airplane_003.jpg
DELETED
|
Binary file (10.7 kB)
|
|
|
images/airport_002.jpg
ADDED
|
images/airport_075.jpg
DELETED
|
Binary file (7.53 kB)
|
|
|
images/beach_002.jpg
ADDED
|
images/industrial_area_003.jpg
ADDED
|
images/meadow_019.jpg
ADDED
|
images/rectangular_farmland_218.jpg
ADDED
|
images/ship_018.jpg
ADDED
|