plant / app.py
dharma75
plant detection model test
433e85f
raw
history blame contribute delete
946 Bytes
'''
import gradio as gr
def greet(name):
return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
demo.launch(share=True)
'''
import gradio as gr
from transformers import pipeline
# Load the plant identification model
classifier = pipeline("image-classification", model="umutbozdag/plant-identity")
# Define the prediction function
def identify_plant(image):
results = classifier(image)
# Format top result
top_result = results[0]
label = top_result['label']
score = round(top_result['score'] * 100, 2)
return f"Prediction: {label} ({score}%)"
# Create Gradio interface
gr.Interface(
fn=identify_plant,
inputs=gr.Image(type="filepath", label="Upload Plant Image"),
outputs=gr.Text(label="Plant Identification Result"),
title="Plant Identifier",
description="Upload an image of a plant to identify its species using a Hugging Face model."
).launch()