Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import requests | |
| import os | |
| # Define the FastAPI endpoint | |
| API_URL = "http://0.0.0.0:8000/predict" # Update this based on your actual endpoint | |
| flagging_dir = "/app/flagged" | |
| os.makedirs(flagging_dir, exist_ok=True) | |
| def predict(input1, input2, input3, input4, input5, input6, input7): | |
| data = { | |
| "input1": input1, | |
| "input2": input2, | |
| "input3": input3, | |
| "input4": input4, | |
| "input5": input5, | |
| "input6": input6, | |
| "input7": input7 | |
| } | |
| response = requests.post(API_URL, json=data) | |
| return response.json() | |
| # Create a Gradio interface for the inputs and prediction | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=["number","number","number","number","number","number","number"], | |
| outputs="json", | |
| flagging_dir=flagging_dir | |
| ) | |
| iface.launch() | |