Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,11 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import joblib
|
5 |
from fastapi import FastAPI
|
6 |
-
from gradio import
|
7 |
|
8 |
# Load the model
|
9 |
repo_id = "rmaitest/mlmodel2"
|
@@ -42,11 +44,15 @@ iface = gr.Interface(
|
|
42 |
# Create FastAPI app
|
43 |
app = FastAPI()
|
44 |
|
45 |
-
#
|
46 |
-
app
|
|
|
|
|
|
|
47 |
|
48 |
-
# Launch Gradio
|
49 |
if __name__ == "__main__":
|
50 |
iface.launch(share=True)
|
51 |
|
52 |
|
|
|
|
1 |
+
pip install gradio fastapi uvicorn
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
from huggingface_hub import hf_hub_download
|
6 |
import joblib
|
7 |
from fastapi import FastAPI
|
8 |
+
from gradio.routes import Route
|
9 |
|
10 |
# Load the model
|
11 |
repo_id = "rmaitest/mlmodel2"
|
|
|
44 |
# Create FastAPI app
|
45 |
app = FastAPI()
|
46 |
|
47 |
+
# Create a route for the /predict API endpoint
|
48 |
+
@app.post("/predict")
|
49 |
+
async def predict(size: float, bedrooms: int, age: int):
|
50 |
+
# Call the Gradio function manually for the API route
|
51 |
+
return iface.fn(size, bedrooms, age)
|
52 |
|
53 |
+
# Launch Gradio interface (only for UI purposes, if needed)
|
54 |
if __name__ == "__main__":
|
55 |
iface.launch(share=True)
|
56 |
|
57 |
|
58 |
+
|