dharma75 commited on
Commit
433e85f
·
1 Parent(s): 441b066

plant detection model test

Browse files
Files changed (2) hide show
  1. app.py +26 -1
  2. requirements.txt +2 -0
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
 
3
  def greet(name):
@@ -5,4 +6,28 @@ def greet(name):
5
 
6
  demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
7
 
8
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
  import gradio as gr
3
 
4
  def greet(name):
 
6
 
7
  demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
8
 
9
+ demo.launch(share=True)
10
+ '''
11
+ import gradio as gr
12
+ from transformers import pipeline
13
+
14
+ # Load the plant identification model
15
+ classifier = pipeline("image-classification", model="umutbozdag/plant-identity")
16
+
17
+ # Define the prediction function
18
+ def identify_plant(image):
19
+ results = classifier(image)
20
+ # Format top result
21
+ top_result = results[0]
22
+ label = top_result['label']
23
+ score = round(top_result['score'] * 100, 2)
24
+ return f"Prediction: {label} ({score}%)"
25
+
26
+ # Create Gradio interface
27
+ gr.Interface(
28
+ fn=identify_plant,
29
+ inputs=gr.Image(type="filepath", label="Upload Plant Image"),
30
+ outputs=gr.Text(label="Plant Identification Result"),
31
+ title="Plant Identifier",
32
+ description="Upload an image of a plant to identify its species using a Hugging Face model."
33
+ ).launch()
requirements.txt CHANGED
@@ -1 +1,3 @@
 
 
1
  gradio
 
1
+ transformers
2
+ torch
3
  gradio