rama0519 commited on
Commit
4a8f1b3
·
verified ·
1 Parent(s): 2c9bc90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -1,16 +1,23 @@
1
- #!pip install gradio --upgrade # Upgrade to the latest version of Gradio
2
-
3
  import gradio as gr
4
  import pandas as pd
5
  import joblib
6
  from huggingface_hub import hf_hub_download
7
 
8
- # Load the model and scaler from Hugging Face Hub
9
- model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib")
10
- scaler_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="scaler.joblib")
 
 
 
 
 
 
 
 
11
 
12
- model = joblib.load(model_path)
13
- scaler = joblib.load(scaler_path)
14
 
15
  # Define reasonable ranges for each input parameter
16
  ranges = {
@@ -49,7 +56,6 @@ def predict_diabetes(pregnancies, glucose, blood_pressure, skin_thickness, insul
49
  return prediction_text
50
 
51
  # Create the Gradio interface
52
- # Use gr.Slider to allow for setting min and max values
53
  interface = gr.Interface(
54
  fn=predict_diabetes,
55
  inputs=[
@@ -67,5 +73,6 @@ interface = gr.Interface(
67
  description="Enter the medical details to predict if the patient is diabetic or not."
68
  )
69
 
70
- # Launch the interface
71
- interface.launch()
 
 
1
+ # Import necessary libraries
 
2
  import gradio as gr
3
  import pandas as pd
4
  import joblib
5
  from huggingface_hub import hf_hub_download
6
 
7
+ # Function to download model and scaler from Hugging Face Hub
8
+ def download_model():
9
+ # Download the model and scaler
10
+ model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib")
11
+ scaler_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="scaler.joblib")
12
+
13
+ # Load the model and scaler
14
+ model = joblib.load(model_path)
15
+ scaler = joblib.load(scaler_path)
16
+
17
+ return model, scaler
18
 
19
+ # Load model and scaler
20
+ model, scaler = download_model()
21
 
22
  # Define reasonable ranges for each input parameter
23
  ranges = {
 
56
  return prediction_text
57
 
58
  # Create the Gradio interface
 
59
  interface = gr.Interface(
60
  fn=predict_diabetes,
61
  inputs=[
 
73
  description="Enter the medical details to predict if the patient is diabetic or not."
74
  )
75
 
76
+ # Launch the Gradio interface
77
+ if __name__ == "__main__":
78
+ interface.launch()