Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,3 +62,15 @@ with gr.Blocks(title="Face condition Analyzer") as demo:
|
|
| 62 |
|
| 63 |
# Lancer l'application
|
| 64 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# Lancer l'application
|
| 64 |
demo.launch()
|
| 65 |
+
@demo.api() # pour exposer une API REST utilisable dans Flutter
|
| 66 |
+
def predict_api(file: gr.File):
|
| 67 |
+
img = PILImage.create(file.name)
|
| 68 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 69 |
+
return {
|
| 70 |
+
"predicted_class": labels[pred_idx],
|
| 71 |
+
"all_predictions": [
|
| 72 |
+
{"class": labels[i], "probability": float(probs[i])}
|
| 73 |
+
for i in range(len(labels))
|
| 74 |
+
]
|
| 75 |
+
}
|
| 76 |
+
|