Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,17 @@
|
|
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 |
-
#
|
9 |
-
token = "
|
|
|
|
|
|
|
10 |
|
11 |
# Download the model and scaler from the Hugging Face Hub using the token
|
12 |
model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib", use_auth_token=token)
|
@@ -53,7 +58,6 @@ def predict_diabetes(pregnancies, glucose, blood_pressure, skin_thickness, insul
|
|
53 |
return prediction_text
|
54 |
|
55 |
# Create the Gradio interface
|
56 |
-
# Use gr.Slider to allow for setting min and max values
|
57 |
interface = gr.Interface(
|
58 |
fn=predict_diabetes,
|
59 |
inputs=[
|
@@ -72,4 +76,4 @@ interface = gr.Interface(
|
|
72 |
)
|
73 |
|
74 |
# Launch the interface
|
75 |
-
interface.launch()
|
|
|
1 |
#!pip install gradio --upgrade # Upgrade to the latest version of Gradio
|
2 |
+
#!pip install huggingface_hub joblib
|
3 |
|
4 |
import gradio as gr
|
5 |
import pandas as pd
|
6 |
import joblib
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
+
import os
|
9 |
|
10 |
+
# Load the Hugging Face token from the environment variable
|
11 |
+
token = os.getenv("HF_TOKEN")
|
12 |
+
|
13 |
+
if token is None:
|
14 |
+
raise ValueError("Hugging Face token not found. Please set the 'HF_TOKEN' environment variable.")
|
15 |
|
16 |
# Download the model and scaler from the Hugging Face Hub using the token
|
17 |
model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib", use_auth_token=token)
|
|
|
58 |
return prediction_text
|
59 |
|
60 |
# Create the Gradio interface
|
|
|
61 |
interface = gr.Interface(
|
62 |
fn=predict_diabetes,
|
63 |
inputs=[
|
|
|
76 |
)
|
77 |
|
78 |
# Launch the interface
|
79 |
+
interface.launch()
|