Spaces:
Sleeping
Sleeping
File size: 1,525 Bytes
5d27254 fcb0962 590bfb0 b91cad9 590bfb0 fcb0962 b91cad9 fcb0962 ed11c69 80b1db8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import gradio as gr
from transformers import pipeline
# Load the model pipeline
pipe = pipeline("image-classification", "dima806/medicinal_plants_image_detection")
# Define the image classification function
def image_classifier(image):
# Perform image classification
outputs = pipe(image)
# Get the label of the first result
output_text = outputs[0]['label']
return output_text
# Define app title and description with HTML formatting
title = "<h1 style='text-align: center; color: #4CAF50;'>Image Classification</h1>"
description = "<p style='text-align: center; font-size: 18px;'>This application serves to classify Medicinal Plants </p>"
# Define custom CSS styles for the Gradio app
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;
}
"""
# Launch the Gradio interface with custom HTML and CSS
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()
|