Owos commited on
Commit
7780f80
·
1 Parent(s): bdfc810

Update Home.py

Browse files
Files changed (1) hide show
  1. Home.py +13 -19
Home.py CHANGED
@@ -7,7 +7,7 @@ import numpy as np
7
  from PIL import Image, ImageEnhance
8
  from io import BytesIO
9
  import matplotlib.pyplot as plt
10
- #import streamlit_ext as ste #for download button not to rerun
11
  from huggingface_hub import upload_file
12
 
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
@@ -31,9 +31,6 @@ with col1: # To display the header text using css style
31
 
32
 
33
 
34
- #with st.sidebar.expander("About the App"):
35
- # st.write("""
36
- # This app takes in your image and styles it with a unique african art.""")
37
 
38
 
39
  #Add file uploader to allow users to upload photos
@@ -64,11 +61,8 @@ def display_random_images(five_rand_imgs, display_type, size= (15, 6)):
64
 
65
  st.pyplot(fig)
66
 
67
- def select_title_from_check_box(index, names_dict):
68
- return names_dict[index]
69
- def format_func(five_rand_imgs):
70
- st.write(' the lenght is', len(five_rand_imgs))
71
- return list(range(len(five_rand_imgs)))
72
  path = 'stylesv2'
73
 
74
 
@@ -142,18 +136,18 @@ if uploaded_file is not None:
142
  st.image(result, width=300)
143
  buf = BytesIO()
144
  result.save(buf, format="png")
145
- if len(os.listdir('generated_samples')) <= 10:
146
- img_file_name = f"generated_samples/{str(len(os.listdir('generated_samples')))}.png"
147
-
148
- _ = upload_file(path_or_fileobj = 'out.png',
149
- path_in_repo = img_file_name,
150
- repo_id='AfrodreamsAI/afrodreams',
151
- repo_type='space',
152
- token=HF_TOKEN
153
- )
154
 
155
  byte_im = buf.getvalue()
156
- #run =ste.download_button(button_text="Download Image", data=byte_im, download_filename='afrodreams.jpg', mime="image/png")
157
 
158
 
159
 
 
7
  from PIL import Image, ImageEnhance
8
  from io import BytesIO
9
  import matplotlib.pyplot as plt
10
+ import streamlit_ext as ste #for download button not to rerun
11
  from huggingface_hub import upload_file
12
 
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
 
31
 
32
 
33
 
 
 
 
34
 
35
 
36
  #Add file uploader to allow users to upload photos
 
61
 
62
  st.pyplot(fig)
63
 
64
+
65
+
 
 
 
66
  path = 'stylesv2'
67
 
68
 
 
136
  st.image(result, width=300)
137
  buf = BytesIO()
138
  result.save(buf, format="png")
139
+
140
+ img_file_name = f"generated_samples/{str(len(os.listdir('generated_samples')))}.png"
141
+
142
+ _ = upload_file(path_or_fileobj = 'out.png',
143
+ path_in_repo = img_file_name,
144
+ repo_id='AfrodreamsAI/afrodreams',
145
+ repo_type='space',
146
+ token=HF_TOKEN
147
+ )
148
 
149
  byte_im = buf.getvalue()
150
+ run = ste.download_button(button_text="Download Image", data=byte_im, download_filename='afrodreams.jpg', mime="image/png")
151
 
152
 
153