Spaces:
Runtime error
Runtime error
Create gradio_app.py
Browse files- gradio_app.py +28 -0
gradio_app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# Define the FastAPI endpoint
|
| 5 |
+
API_URL = "http://localhost:8000/predict" # Update this based on your actual endpoint
|
| 6 |
+
|
| 7 |
+
def predict(input1, input2, input3, input4, input5, input6, input7):
|
| 8 |
+
data = {
|
| 9 |
+
"input1": input1,
|
| 10 |
+
"input2": input2,
|
| 11 |
+
"input3": input3,
|
| 12 |
+
"input4": input4,
|
| 13 |
+
"input5": input5,
|
| 14 |
+
"input6": input6,
|
| 15 |
+
"input7": input7
|
| 16 |
+
}
|
| 17 |
+
response = requests.post(API_URL, json=data)
|
| 18 |
+
return response.json()
|
| 19 |
+
|
| 20 |
+
# Create a Gradio interface for the inputs and prediction
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=predict,
|
| 23 |
+
inputs=[gr.inputs.Number(), gr.inputs.Number(), gr.inputs.Number(), gr.inputs.Number(),
|
| 24 |
+
gr.inputs.Number(), gr.inputs.Number(), gr.inputs.Number()],
|
| 25 |
+
outputs="json"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
iface.launch()
|