Spaces:
Sleeping
Sleeping
Commit ·
eebb212
1
Parent(s): c19c852
Fix: Update Gradio 6.x API endpoint configuration
Browse files60 unmodified lines61626360 unmodified lines# ✅ Lancement de l'interface# Hugging Face Spaces détecte automatiquement l'interface Gradioiface.launch()60 unmodified lines61626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712860 unmodified lines# ✅ Lancement de l'interface# Hugging Face Spaces détecte automatiquement l'interface Gradioiface.launch()example.comAmine"""Labasni Recommender Service - Hugging Face SpaceInterface Gradio pour les recommandations d'outfitsVersion simplifiée avec gr.Interface"""import gradio as grimport jsonfrom recommender_model import recommend_outfit_mldef recommend_outfit_api(clothes_json: str, preference: str, city: str = "Tunis"):"""API endpoint pour les recommandations d'outfitArgs:clothes_json: JSON string contenant la liste des vêtementspreference: Style préféré (casual, formal, sport)city: Ville pour la météoReturns:JSON avec l'outfit recommandé"""try:clothes_data = json.loads(clothes_json)result = recommend_outfit_ml(clothes_data, preference, city)return json.dumps(result, indent=2)except Exception as e:return json.dumps({"success": False, "error": str(e)})# ✅ Interface Gradio - gr.Interface avec api_name explicite pour Gradio 6.x# Hugging Face Spaces détecte automatiquement la variable 'demo'demo = gr.Interface(fn=recommend_outfit_api,inputs=[gr.Textbox(label="Clothes Data (JSON)",placeholder='[{"id":"top1","category":"top","style":"casual",...}]',lines=10),gr.Dropdown(choices=["casual", "formal", "sport", "chic"],label="Preference",value="casual"),gr.Textbox(label="City", value="Tunis")],outputs=gr.Textbox(label="Recommended Outfit (JSON)", lines=15),title="🎽 Labasni Outfit Recommender",description="Recommandations d'outfits basées sur ML (TensorFlow + PyTorch)",examples=[['[{"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"}]',"casual","Tunis"]],# ✅ CRUCIAL : api_name est nécessaire pour Gradio 6.x# Cela expose l'endpoint /api/predictapi_name="predict")# ✅ Pour Hugging Face Spaces, l'interface est automatiquement détectée et lancée# La variable 'demo' est la convention standard pour Hugging Face Spaces
app.py+65