Spaces:
Sleeping
Sleeping
Download app.py from crisdeyvid/Bridge: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/spaces/crisdeyvid/Bridge/resolve/main/app.py
- Command line
-
hf download hf://spaces/crisdeyvid/Bridge/app.py
-
curl -L -o app.py https://huggingface.co/spaces/crisdeyvid/Bridge/resolve/main/app.py
830 Bytes
| import gradio as gr | |
| import requests | |
| MODEL_URL = "https://crisdeyvid-gema-ai-model.hf.space/predict" | |
| def bridge_predict(features_text): | |
| try: | |
| features = [float(x.strip()) for x in features_text.split(",")] | |
| except Exception as e: | |
| return f"Error: {e}", "" | |
| payload = {"features": features} | |
| try: | |
| resp = requests.post(MODEL_URL, json=payload, timeout=10) | |
| result = resp.json() | |
| return str(result), result.get("signal", "") | |
| except Exception as e: | |
| return f"Error al consultar modelo: {e}", "" | |
| iface = gr.Interface( | |
| fn=bridge_predict, | |
| inputs=gr.Textbox(label="Features separados por coma"), | |
| outputs=[gr.Textbox(label="Respuesta JSON"), gr.Textbox(label="Señal")], | |
| title="Bridge - Puente hacia el Modelo IA" | |
| ) | |
| iface.launch() # <--- SOLO ESTO al final | |