Owos commited on
Commit
4aa0559
1 Parent(s): 0918548

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -19
app.py CHANGED
@@ -24,6 +24,7 @@ st.sidebar.markdown('<p class="font">Afrodreams.AI</p>', unsafe_allow_html=True)
24
  with st.sidebar.expander("About the App"):
25
  st.write("""
26
  This app takes in your image and styles it with a unique african art.""")
 
27
 
28
  #Add file uploader to allow users to upload photos
29
  uploaded_file = st.file_uploader("", type=['jpg','png','jpeg'])
@@ -42,29 +43,32 @@ if uploaded_file is not None:
42
 
43
  # add a button
44
  run = st.button('Generate Art')
 
 
 
 
 
 
 
 
 
 
 
45
  if run==True:
46
-
47
- with st.spinner('Wait for it...'):
48
- params = neural_style.TransferParams()
49
- params.gpu = "c"
50
- params.backend = "mkl"
51
- params.image_size = 300
52
- params.content_image = uploaded_file
53
- path = 'stylesv2'
54
- styles = os.listdir(path)
55
- params.style_image = path + '/' + random.choice(styles)
56
- neural_style.transfer(params)
57
 
58
  #display image when done.
59
  with col2:
60
- result = Image.open('out.png')
61
- st.image(result, width=500)
62
- buf = BytesIO()
63
- result.save(buf, format="JPEG")
64
- byte_im = buf.getvalue()
65
- run =st.download_button(label="Download Image", data=byte_im, file_name='afrodreams.jpg', mime="image/png")
66
-
67
-
 
68
 
69
 
70
 
 
24
  with st.sidebar.expander("About the App"):
25
  st.write("""
26
  This app takes in your image and styles it with a unique african art.""")
27
+ style_weight = st.slider("Select Style Weight)
28
 
29
  #Add file uploader to allow users to upload photos
30
  uploaded_file = st.file_uploader("", type=['jpg','png','jpeg'])
 
43
 
44
  # add a button
45
  run = st.button('Generate Art')
46
+ my_bar = st.progress(0)
47
+ params = neural_style.TransferParams()
48
+ params.gpu = "c"
49
+ params.backend = "mkl"
50
+ params.image_size = 300
51
+ params.content_image = uploaded_file
52
+ path = 'stylesv2'
53
+ styles = os.listdir(path)
54
+ params.style_weight = 12
55
+ params.style_image = path + '/' + random.choice(styles)
56
+
57
  if run==True:
58
+ st.session_state.submitted = True
59
+ my_bar.progress(neural_style.transfer(params))
 
 
 
 
 
 
 
 
 
60
 
61
  #display image when done.
62
  with col2:
63
+ if 'submitted' in st.session_state:
64
+ result = Image.open('out.png')
65
+ st.image(result, width=500)
66
+ buf = BytesIO()
67
+ result.save(buf, format="JPEG")
68
+ byte_im = buf.getvalue()
69
+ run =st.download_button(label="Download Image", data=byte_im, file_name='afrodreams.jpg', mime="image/png")
70
+
71
+
72
 
73
 
74