| import streamlit as st |
| from transformers import pipeline |
| from PIL import Image |
| from streamlit_extras.add_vertical_space import add_vertical_space |
|
|
|
|
| flower_pipeline = pipeline(task="image-classification", model="microsoft/resnet-50") |
|
|
|
|
| st.set_page_config(page_title="Flower Identifier ๐ธ", layout="wide", page_icon="๐ผ") |
|
|
|
|
| st.markdown( |
| """ |
| <div style="text-align: center; padding: 10px;"> |
| <h1 style="color: #2D6A4F; font-size: 50px;">Flower Identifier ๐ธ</h1> |
| <p style="color: #40916C; font-size: 20px;">Snap it, upload it, and identify the bloom!</p> |
| </div> |
| """, |
| unsafe_allow_html=True |
| ) |
|
|
|
|
| file_name = st.file_uploader("Upload a flower image ๐ธ", type=["jpg", "jpeg", "png"]) |
|
|
| add_vertical_space(1) |
|
|
| if file_name is not None: |
| col1, col2 = st.columns([1, 2]) |
|
|
| image = Image.open(file_name) |
| col1.image( |
| image, |
| use_container_width=True, |
| caption="Uploaded Image", |
| output_format="auto" |
| ) |
|
|
|
|
| predictions = flower_pipeline(image) |
|
|
| col2.markdown("### ๐บ Predictions & Confidence Levels") |
| |
| for p in predictions: |
| col2.write(f"**{p['label']}**") |
| col2.progress(p["score"]) |
|
|
|
|
| st.markdown( |
| """ |
| <hr style="border-top: 3px solid #40916C;"> |
| <div style="text-align: center;"> |
| <p style="color: #1B4332;">Powered by AgentsValley ๐ฟ</p> |
| </div> |
| """, |
| unsafe_allow_html=True |
| ) |
|
|