rmaitest commited on
Commit
b1f7899
1 Parent(s): 6df5537

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -19
app.py CHANGED
@@ -1,10 +1,7 @@
1
-
2
  import gradio as gr
3
  import pandas as pd
4
  from huggingface_hub import hf_hub_download
5
  import joblib
6
- from fastapi import FastAPI
7
- from gradio.routes import Route
8
 
9
  # Load the model
10
  repo_id = "rmaitest/mlmodel2"
@@ -14,7 +11,6 @@ model_file = "house_price_model.pkl" # Adjust as necessary
14
  model_path = hf_hub_download(repo_id, model_file)
15
  model = joblib.load(model_path)
16
 
17
- # Define the prediction function
18
  def predict_price(size, bedrooms, age):
19
  # Create a DataFrame from the input
20
  input_data = pd.DataFrame({
@@ -40,18 +36,5 @@ iface = gr.Interface(
40
  description="Enter the size, number of bedrooms, and age of the house to get the predicted price."
41
  )
42
 
43
- # Create FastAPI app
44
- app = FastAPI()
45
-
46
- # Create a route for the /predict API endpoint
47
- @app.post("/predict")
48
- async def predict(size: float, bedrooms: int, age: int):
49
- # Call the Gradio function manually for the API route
50
- return iface.fn(size, bedrooms, age)
51
-
52
- # Launch Gradio interface (only for UI purposes, if needed)
53
- if __name__ == "__main__":
54
- iface.launch(share=True)
55
-
56
-
57
-
 
 
1
  import gradio as gr
2
  import pandas as pd
3
  from huggingface_hub import hf_hub_download
4
  import joblib
 
 
5
 
6
  # Load the model
7
  repo_id = "rmaitest/mlmodel2"
 
11
  model_path = hf_hub_download(repo_id, model_file)
12
  model = joblib.load(model_path)
13
 
 
14
  def predict_price(size, bedrooms, age):
15
  # Create a DataFrame from the input
16
  input_data = pd.DataFrame({
 
36
  description="Enter the size, number of bedrooms, and age of the house to get the predicted price."
37
  )
38
 
39
+ # Launch the interface with a public URL
40
+ iface.launch(share=True)