-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.py
51 lines (40 loc) · 1.47 KB
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import streamlit as st
from PIL import Image
from streamlit_tags import st_tags
from utils import MyPredictor
def load_settings():
# Page config
st.set_page_config(
page_title="Fashion Tagging",
layout="wide",
initial_sidebar_state="expanded"
)
# Title
st.markdown('## Auto Tagging for Fashion Retail Using Multi-label Image Classification')
# Sidebar
global sidebar
sidebar = st.sidebar
with open("assets/test.jpg", "rb") as file:
btn = sidebar.download_button(
label="Download sample image",
data=file,
file_name="test.jpg",
mime="image/jpg"
)
def main():
load_settings()
uploaded_file = st.file_uploader(label="Choose a file", type=['jpg', 'jpeg'])
predictor = MyPredictor()
if uploaded_file is not None:
image = Image.open(uploaded_file)
num_of_tags = sidebar.radio("Number of Tags", (3, 4, 5), index=2)
col1, col2 = st.columns(2)
with col1:
st.markdown('<p style="text-align: center;">Your Image</p><hr>', unsafe_allow_html=True)
st.image(image, caption="Fashion Image")
with col2:
st.markdown('<p style="text-align: center;">Image Tags</p><hr>', unsafe_allow_html=True)
tags = predictor.predict(image=image, num_of_tags=num_of_tags)
tags = st_tags(label="Tags:", text="Add more", value=tags)
if __name__=="__main__":
main()