Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,12 +40,8 @@ def predict_image(img):
|
|
| 40 |
# Trouver les sous-catégories correspondantes
|
| 41 |
subcategories = subcategory_dict.get(category_name, [])
|
| 42 |
|
| 43 |
-
# Préparer les résultats
|
| 44 |
-
results = {
|
| 45 |
-
"Category": category_name,
|
| 46 |
-
"Price ($)": f"{price_pred[0][0]:.2f}",
|
| 47 |
-
"Subcategories": ", ".join(subcategories) if subcategories else "No subcategories"
|
| 48 |
-
}
|
| 49 |
return results
|
| 50 |
|
| 51 |
# Charger le modèle pré-entraîné
|
|
@@ -56,11 +52,7 @@ model = tf.keras.models.load_model('trained_model.h5', custom_objects={'mse': Me
|
|
| 56 |
interface = gr.Interface(
|
| 57 |
fn=predict_image,
|
| 58 |
inputs=gr.Image(type="pil"),
|
| 59 |
-
outputs=
|
| 60 |
-
gr.Label(label="Category"),
|
| 61 |
-
gr.Text(label="Price ($)"),
|
| 62 |
-
gr.Text(label="Subcategories")
|
| 63 |
-
],
|
| 64 |
title="Image Classification with TensorFlow",
|
| 65 |
description="Upload an image to predict its category, price, and subcategories."
|
| 66 |
)
|
|
|
|
| 40 |
# Trouver les sous-catégories correspondantes
|
| 41 |
subcategories = subcategory_dict.get(category_name, [])
|
| 42 |
|
| 43 |
+
# Préparer les résultats sous forme de texte
|
| 44 |
+
results = f"Category: {category_name}\nPrice ($): {price_pred[0][0]:.2f}\nSubcategories: {', '.join(subcategories) if subcategories else 'No subcategories'}"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
return results
|
| 46 |
|
| 47 |
# Charger le modèle pré-entraîné
|
|
|
|
| 52 |
interface = gr.Interface(
|
| 53 |
fn=predict_image,
|
| 54 |
inputs=gr.Image(type="pil"),
|
| 55 |
+
outputs=gr.Textbox(label="Prediction Results"),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
title="Image Classification with TensorFlow",
|
| 57 |
description="Upload an image to predict its category, price, and subcategories."
|
| 58 |
)
|