salma-mahjoub commited on
Commit
b775d58
·
1 Parent(s): bd20751

Fix: Update Gradio 6.x API endpoint configuration

Browse files
Files changed (1) hide show
  1. app.py +0 -65
app.py CHANGED
@@ -8,71 +8,6 @@ import gradio as gr
8
  import json
9
  from recommender_model import recommend_outfit_ml
10
 
11
- def recommend_outfit_api(clothes_json: str, preference: str, city: str = "Tunis"):
12
- """
13
- API endpoint pour les recommandations d'outfit
14
-
15
- Args:
16
- clothes_json: JSON string contenant la liste des vêtements
17
- preference: Style préféré (casual, formal, sport)
18
- city: Ville pour la météo
19
-
20
- Returns:
21
- JSON avec l'outfit recommandé
22
- """
23
- try:
24
- clothes_data = json.loads(clothes_json)
25
- result = recommend_outfit_ml(clothes_data, preference, city)
26
- return json.dumps(result, indent=2)
27
- except Exception as e:
28
- return json.dumps({"success": False, "error": str(e)})
29
-
30
- # ✅ Interface Gradio - gr.Interface avec api_name explicite pour Gradio 6.x
31
- iface = gr.Interface(
32
- fn=recommend_outfit_api,
33
- inputs=[
34
- gr.Textbox(
35
- label="Clothes Data (JSON)",
36
- placeholder='[{"id":"top1","category":"top","style":"casual",...}]',
37
- lines=10
38
- ),
39
- gr.Dropdown(
40
- choices=["casual", "formal", "sport", "chic"],
41
- label="Preference",
42
- value="casual"
43
- ),
44
- gr.Textbox(label="City", value="Tunis")
45
- ],
46
- outputs=gr.Textbox(label="Recommended Outfit (JSON)", lines=15),
47
- title="🎽 Labasni Outfit Recommender",
48
- description="Recommandations d'outfits basées sur ML (TensorFlow + PyTorch)",
49
- examples=[
50
- [
51
- '[{"id":"top1","category":"top","style":"casual","color":"white","season":"summer","score":0.8,"imageURL":"https://example.com/top.jpg"},{"id":"bot1","category":"bottom","style":"casual","color":"blue","season":"summer","score":0.7,"imageURL":"https://example.com/bottom.jpg"},{"id":"shoe1","category":"footwear","style":"casual","color":"black","season":"summer","score":0.9,"imageURL":"https://example.com/shoes.jpg"}]',
52
- "casual",
53
- "Tunis"
54
- ]
55
- ],
56
- # ✅ CRUCIAL : api_name est nécessaire pour Gradio 6.x
57
- # Cela expose l'endpoint /api/predict
58
- api_name="predict"
59
- )
60
-
61
- # ✅ Lancement de l'interface
62
- # Hugging Face Spaces détecte automatiquement l'interface Gradio
63
- iface.launch()
64
- example.com
65
- Amine
66
- """
67
- Labasni Recommender Service - Hugging Face Space
68
- Interface Gradio pour les recommandations d'outfits
69
- Version simplifiée avec gr.Interface
70
- """
71
-
72
- import gradio as gr
73
- import json
74
- from recommender_model import recommend_outfit_ml
75
-
76
  def recommend_outfit_api(clothes_json: str, preference: str, city: str = "Tunis"):
77
  """
78
  API endpoint pour les recommandations d'outfit
 
8
  import json
9
  from recommender_model import recommend_outfit_ml
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  def recommend_outfit_api(clothes_json: str, preference: str, city: str = "Tunis"):
12
  """
13
  API endpoint pour les recommandations d'outfit