agentsvalley commited on
Commit
3d70293
ยท
verified ยท
1 Parent(s): 3930452

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -3,13 +3,13 @@ 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;">
@@ -20,7 +20,7 @@ st.markdown(
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)
@@ -28,7 +28,6 @@ add_vertical_space(1)
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,
@@ -37,21 +36,21 @@ if file_name is not None:
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
 
3
  from PIL import Image
4
  from streamlit_extras.add_vertical_space import add_vertical_space
5
 
6
+
7
  flower_pipeline = pipeline(task="image-classification", model="microsoft/resnet-50")
8
 
9
+
10
  st.set_page_config(page_title="Flower Identifier ๐ŸŒธ", layout="wide", page_icon="๐ŸŒผ")
11
 
12
+
13
  st.markdown(
14
  """
15
  <div style="text-align: center; padding: 10px;">
 
20
  unsafe_allow_html=True
21
  )
22
 
23
+
24
  file_name = st.file_uploader("Upload a flower image ๐Ÿ“ธ", type=["jpg", "jpeg", "png"])
25
 
26
  add_vertical_space(1)
 
28
  if file_name is not None:
29
  col1, col2 = st.columns([1, 2])
30
 
 
31
  image = Image.open(file_name)
32
  col1.image(
33
  image,
 
36
  output_format="auto"
37
  )
38
 
39
+
40
  predictions = flower_pipeline(image)
41
 
42
  col2.markdown("### ๐ŸŒบ Predictions & Confidence Levels")
43
 
44
  for p in predictions:
45
  col2.write(f"**{p['label']}**")
46
+ col2.progress(p["score"])
47
+
48
 
 
49
  st.markdown(
50
  """
51
  <hr style="border-top: 3px solid #40916C;">
52
  <div style="text-align: center;">
53
+ <p style="color: #1B4332;">Powered by AgentsValley ๐ŸŒฟ</p>
54
  </div>
55
  """,
56
  unsafe_allow_html=True