Spaces:
Sleeping
Sleeping
| 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() | |