Sarah Yakum commited on
Commit
d120484
·
1 Parent(s): 972723f
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,8 +1,9 @@
 
1
  import streamlit as st
2
 
3
  st.title("Segmentation of Beauty Products")
4
 
5
- file_name = st.file_uploader("Upload a a beauty product")
6
 
7
 
8
  from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
@@ -21,7 +22,7 @@ from PIL import Image
21
 
22
  if file_name is not None:
23
  image = Image.open(file_name)
24
- image.show()
25
 
26
  pixel_values = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
27
 
@@ -89,4 +90,4 @@ if file_name is not None:
89
 
90
  plt.figure(figsize=(15, 10))
91
  plt.imshow(img)
92
- plt.show()
 
1
+ #credit to https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SegFormer/Segformer_inference_notebook.ipynb for segmentation code
2
  import streamlit as st
3
 
4
  st.title("Segmentation of Beauty Products")
5
 
6
+ file_name = st.file_uploader("Upload an image of a beauty product")
7
 
8
 
9
  from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
 
22
 
23
  if file_name is not None:
24
  image = Image.open(file_name)
25
+ st.image(image, caption='Image without Segmentation')
26
 
27
  pixel_values = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
28
 
 
90
 
91
  plt.figure(figsize=(15, 10))
92
  plt.imshow(img)
93
+ st.plyplot(img)