Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,9 @@ pipe = pipeline("image-classification", "dima806/medicinal_plants_image_detectio
|
|
| 8 |
def image_classifier(image):
|
| 9 |
# Perform image classification
|
| 10 |
outputs = pipe(image)
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
return results
|
| 15 |
|
| 16 |
# Define app title and description with HTML formatting
|
| 17 |
title = "<h1 style='text-align: center; color: #4CAF50;'>Image Classification</h1>"
|
|
@@ -37,9 +36,7 @@ custom_css = """
|
|
| 37 |
"""
|
| 38 |
|
| 39 |
# Launch the Gradio interface with custom HTML and CSS
|
| 40 |
-
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="
|
| 41 |
theme="gstaff/sketch", css=custom_css,
|
| 42 |
)
|
| 43 |
demo.launch()
|
| 44 |
-
|
| 45 |
-
|
|
|
|
| 8 |
def image_classifier(image):
|
| 9 |
# Perform image classification
|
| 10 |
outputs = pipe(image)
|
| 11 |
+
# Get the label of the first result
|
| 12 |
+
output_text = outputs[0]['label']
|
| 13 |
+
return output_text
|
|
|
|
| 14 |
|
| 15 |
# Define app title and description with HTML formatting
|
| 16 |
title = "<h1 style='text-align: center; color: #4CAF50;'>Image Classification</h1>"
|
|
|
|
| 36 |
"""
|
| 37 |
|
| 38 |
# Launch the Gradio interface with custom HTML and CSS
|
| 39 |
+
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="textbox", title=title, description=description,
|
| 40 |
theme="gstaff/sketch", css=custom_css,
|
| 41 |
)
|
| 42 |
demo.launch()
|
|
|
|
|
|