|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline("image-classification", "dima806/medicinal_plants_image_detection") |
|
|
|
|
|
def image_classifier(image): |
|
|
|
outputs = pipe(image) |
|
|
|
output_text = outputs[0]['label'] |
|
return output_text |
|
|
|
|
|
title = "<h1 style='text-align: center; color: #4CAF50;'>Indian Medicinal Plant Identification</h1>" |
|
description = "<p style='text-align: center; font-size: 18px;'></p>" |
|
|
|
|
|
custom_css = """ |
|
.gradio-interface { |
|
max-width: 600px; |
|
margin: auto; |
|
border-radius: 10px; |
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); |
|
} |
|
.title-container { |
|
padding: 20px; |
|
background-color: #f0f0f0; |
|
border-top-left-radius: 10px; |
|
border-top-right-radius: 10px; |
|
} |
|
.description-container { |
|
padding: 20px; |
|
} |
|
""" |
|
|
|
|
|
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="textbox", title=title, description=description, |
|
theme="gstaff/sketch", css=custom_css, |
|
) |
|
demo.launch(share=True) |