Spaces:
Runtime error
Runtime error
Add application file
Browse files
app.py
CHANGED
|
@@ -47,10 +47,12 @@ class Contrastive_Loss_2(tf.keras.losses.Loss):
|
|
| 47 |
model = tf.keras.models.load_model( filepath='contrastive_model.h5', custom_objects={'Contrastive_Loss_2': Contrastive_Loss_2})
|
| 48 |
|
| 49 |
with open("scene_labels.json") as labels_file:
|
| 50 |
-
|
| 51 |
|
| 52 |
def classify_image(img):
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 55 |
|
| 56 |
image = gr.inputs.Image(shape=(256, 256))
|
|
|
|
| 47 |
model = tf.keras.models.load_model( filepath='contrastive_model.h5', custom_objects={'Contrastive_Loss_2': Contrastive_Loss_2})
|
| 48 |
|
| 49 |
with open("scene_labels.json") as labels_file:
|
| 50 |
+
labels = json.load(labels_file)
|
| 51 |
|
| 52 |
def classify_image(img):
|
| 53 |
+
img = tf.convert_to_tensor(img, dtype=tf.float32)
|
| 54 |
+
# pred,idx,probs = model.predict(img)
|
| 55 |
+
probs = model.predict(img)
|
| 56 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 57 |
|
| 58 |
image = gr.inputs.Image(shape=(256, 256))
|