ManuelMC commited on
Commit
1fc4be1
·
verified ·
1 Parent(s): 3fd4512

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -57
app.py DELETED
@@ -1,57 +0,0 @@
1
- # Import the necessary libraries
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.
16
- def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
17
- # Convert the input parameters into a 2D list/array because
18
- # scikit-learn's predict() expects a 2D array of shape (n_samples, n_features)
19
- input = np.array([[sepal_length, sepal_width, petal_length, petal_width]])
20
- prediction = pipeline.predict(input)
21
-
22
- # Convert the prediction to the string label
23
- if prediction == 0:
24
- return 'iris-setosa'
25
- elif prediction == 1:
26
- return 'Iris-versicolor'
27
- elif prediction == 2:
28
- return 'Iris-virginica'
29
- else:
30
- return "Invalid prediction"
31
-
32
- # Create a Gradio Interface:
33
- # - fn: the function to call for inference
34
- # - inputs: a list of component types to collect user input (in this case, four numeric values)
35
- # - outputs: how the prediction is displayed (in this case, as text)
36
- # - live: whether to update the output in real-time as the user types
37
- interface = gr.Interface(
38
- fn=predict_iris,
39
- inputs=["number", "number", "number", "number"],
40
- outputs="text",
41
- live=True,
42
- title="Iris Species Identifier",
43
- description="Enter the four measurements to predict the Iris species."
44
- )
45
-
46
- # Run the interface when this script is executed directly.
47
- # This will launch a local Gradio server and open a user interface in the browser.
48
- if __name__ == "__main__":
49
- # To create a public link, set the parameter share=True
50
- interface.launch()
51
-
52
- '''
53
- # The Flag button allows users (or testers) to mark or “flag”
54
- # a particular input-output interaction for later review.
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
- '''