Manuel commited on
Commit
1396993
·
1 Parent(s): 3fd4512

Add application file

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -2,14 +2,21 @@
2
  import gradio as gr # Gradio is a library to quickly build and share demos for ML models
3
  import joblib # joblib is used here to load the trained model from a file
4
  import numpy as np # NumPy for numerical operations (if needed for array manipulation)
 
5
 
6
- # Load the pre-trained Decision Tree classifier from the joblib file
7
 
 
 
 
 
 
 
 
 
8
 
9
- #pipeline = joblib.load("./models/iris_dt.joblib")
10
- #Use the model hosted on huggingface. Usar de guia archivo de Bernardo para no ejecutar en local
11
-
12
- pipeline = joblib.load("ManuelMC/iris_dt.joblib")
13
 
14
  # Define a function that takes the four iris measurements as input
15
  # and returns the predicted iris species label.
@@ -55,3 +62,5 @@ if __name__ == "__main__":
55
  # When someone clicks Flag, Gradio saves the input values (and often the output) to a log.csv file
56
  # letting you keep track of interesting or potentially problematic cases for debugging or analysis later on
57
  '''
 
 
 
2
  import gradio as gr # Gradio is a library to quickly build and share demos for ML models
3
  import joblib # joblib is used here to load the trained model from a file
4
  import numpy as np # NumPy for numerical operations (if needed for array manipulation)
5
+ from huggingface_hub import hf_hub_download
6
 
7
+ HF_TOKEN = 'hf_your_token_here' # Replace with your actual Hugging Face token
8
 
9
+ # Replace with your actual Hugging Face model repo ID and file names
10
+ # For example, repo_id="username/iris-decision-tree"
11
+ # Use repo_type="model" if it's a model repository
12
+ model_path = hf_hub_download(
13
+ repo_id="brjapon/iris-dt",
14
+ filename="iris_dt.joblib", # The model file stored in the HF repo
15
+ repo_type="model" # Could also be 'dataset' if you're storing it that way
16
+ )
17
 
18
+ # Load the trained model
19
+ pipeline = joblib.load(model_path)
 
 
20
 
21
  # Define a function that takes the four iris measurements as input
22
  # and returns the predicted iris species label.
 
62
  # When someone clicks Flag, Gradio saves the input values (and often the output) to a log.csv file
63
  # letting you keep track of interesting or potentially problematic cases for debugging or analysis later on
64
  '''
65
+
66
+