niru-nny commited on
Commit
581b1cc
·
verified ·
1 Parent(s): 37d5336

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -6,20 +6,33 @@ import gradio as gr
6
  import joblib
7
  import pandas as pd
8
  from huggingface_hub import hf_hub_download
 
9
 
10
- # Download model files
11
- model_path = hf_hub_download(
12
- repo_id="niru-nny/house-price-prediction",
13
- filename="house_price_model.joblib"
14
- )
15
- pipeline_path = hf_hub_download(
16
- repo_id="niru-nny/house-price-prediction",
17
- filename="preprocessing_pipeline.joblib"
18
- )
19
 
20
- # Load model and pipeline
21
- model = joblib.load(model_path)
22
- pipeline = joblib.load(pipeline_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  def predict_price(longitude, latitude, housing_median_age, total_rooms,
25
  total_bedrooms, population, households, median_income,
 
6
  import joblib
7
  import pandas as pd
8
  from huggingface_hub import hf_hub_download
9
+ import os
10
 
11
+ print("🔄 Downloading model files...")
 
 
 
 
 
 
 
 
12
 
13
+ # Download model files
14
+ try:
15
+ model_path = hf_hub_download(
16
+ repo_id="niru-nny/house-price-prediction",
17
+ filename="house_price_model.joblib"
18
+ )
19
+ print(f"✅ Model downloaded: {model_path}")
20
+
21
+ pipeline_path = hf_hub_download(
22
+ repo_id="niru-nny/house-price-prediction",
23
+ filename="preprocessing_pipeline.joblib"
24
+ )
25
+ print(f"✅ Pipeline downloaded: {pipeline_path}")
26
+
27
+ # Load model and pipeline
28
+ print("🔄 Loading model and pipeline...")
29
+ model = joblib.load(model_path)
30
+ pipeline = joblib.load(pipeline_path)
31
+ print("✅ Model and pipeline loaded successfully!")
32
+
33
+ except Exception as e:
34
+ print(f"❌ Error loading model: {e}")
35
+ raise
36
 
37
  def predict_price(longitude, latitude, housing_median_age, total_rooms,
38
  total_bedrooms, population, households, median_income,