agentsvalley commited on
Commit
3bb0515
·
verified ·
1 Parent(s): a8fdae2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -11
app.py CHANGED
@@ -1,26 +1,58 @@
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_container_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)}%")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
  from PIL import Image
4
+ from streamlit_extras.add_vertical_space import add_vertical_space
5
 
6
  # Load a flower classification model from Hugging Face or your custom model
7
  flower_pipeline = pipeline(task="image-classification", model="microsoft/resnet-50")
8
 
9
+ # Page Layout
10
+ st.set_page_config(page_title="Flower Identifier 🌸", layout="wide", page_icon="🌼")
11
 
12
+ # Page Header
13
+ st.markdown(
14
+ """
15
+ <div style="text-align: center; padding: 10px;">
16
+ <h1 style="color: #2D6A4F; font-size: 50px;">Flower Identifier 🌸</h1>
17
+ <p style="color: #40916C; font-size: 20px;">Snap it, upload it, and identify the bloom!</p>
18
+ </div>
19
+ """,
20
+ unsafe_allow_html=True
21
+ )
22
+
23
+ # File Upload Section
24
+ file_name = st.file_uploader("Upload a flower image 📸", type=["jpg", "jpeg", "png"])
25
+
26
+ add_vertical_space(1)
27
 
28
  if file_name is not None:
29
+ col1, col2 = st.columns([1, 2])
30
 
31
+ # Display the uploaded image with shadow effect
32
  image = Image.open(file_name)
33
+ col1.image(
34
+ image,
35
+ use_container_width=True,
36
+ caption="Uploaded Image",
37
+ output_format="auto"
38
+ )
39
+
40
+ # Display predictions
41
  predictions = flower_pipeline(image)
42
 
43
+ col2.markdown("### 🌺 Predictions & Confidence Levels")
44
+
45
  for p in predictions:
46
+ col2.write(f"**{p['label']}**")
47
+ col2.progress(p["score"]) # Progress bar for probabilities
48
+
49
+ # Footer
50
+ st.markdown(
51
+ """
52
+ <hr style="border-top: 3px solid #40916C;">
53
+ <div style="text-align: center;">
54
+ <p style="color: #1B4332;">Powered by Hugging Face Transformers 🌿</p>
55
+ </div>
56
+ """,
57
+ unsafe_allow_html=True
58
+ )