agentsvalley commited on
Commit
93fc1fa
·
verified ·
1 Parent(s): 8ffcee5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # Load a flower classification model from Hugging Face or your custom model
6
+ flower_pipeline = pipeline(task="image-classification", model="microsoft/resnet-50")
7
+
8
+ st.title("Flower Identifier 🌸")
9
+
10
+ # Upload the image
11
+ file_name = st.file_uploader("Upload a flower image")
12
+
13
+ if file_name is not None:
14
+ col1, col2 = st.columns(2)
15
+
16
+ # Display the uploaded image
17
+ image = Image.open(file_name)
18
+ col1.image(image, use_column_width=True)
19
+
20
+ # Make predictions
21
+ predictions = flower_pipeline(image)
22
+
23
+ # Display probabilities
24
+ col2.header("Predictions 🌼")
25
+ for p in predictions:
26
+ col2.subheader(f"{p['label']}: {round(p['score'] * 100, 1)}%")