Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,9 @@ import numpy as np
|
|
8 |
from PIL import Image, ImageEnhance
|
9 |
from io import BytesIO
|
10 |
import streamlit_ext as ste #for download button not to rerun
|
|
|
|
|
|
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
#Create two columns with different width
|
@@ -48,7 +51,7 @@ if uploaded_file is not None:
|
|
48 |
params = neural_style.TransferParams()
|
49 |
params.gpu = "c"
|
50 |
params.backend = "mkl"
|
51 |
-
params.image_size =
|
52 |
params.content_image = uploaded_file
|
53 |
params.style_weight = style_weight
|
54 |
keep_style = False
|
@@ -71,7 +74,14 @@ if uploaded_file is not None:
|
|
71 |
buf = BytesIO()
|
72 |
result.save(buf, format="png")
|
73 |
if len(os.listdir('generated_samples')) <= 10:
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
byte_im = buf.getvalue()
|
76 |
run =ste.download_button(button_text="Download Image", data=byte_im, download_filename='afrodreams.jpg', mime="image/png")
|
77 |
#keeping the current style by update the weight
|
|
|
8 |
from PIL import Image, ImageEnhance
|
9 |
from io import BytesIO
|
10 |
import streamlit_ext as ste #for download button not to rerun
|
11 |
+
import huggingface_hub
|
12 |
+
|
13 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
14 |
|
15 |
st.set_page_config(layout="wide")
|
16 |
#Create two columns with different width
|
|
|
51 |
params = neural_style.TransferParams()
|
52 |
params.gpu = "c"
|
53 |
params.backend = "mkl"
|
54 |
+
params.image_size = 400
|
55 |
params.content_image = uploaded_file
|
56 |
params.style_weight = style_weight
|
57 |
keep_style = False
|
|
|
74 |
buf = BytesIO()
|
75 |
result.save(buf, format="png")
|
76 |
if len(os.listdir('generated_samples')) <= 10:
|
77 |
+
|
78 |
+
_ = huggingface_hub.upload_file(path_or_fileobj = 'out.png',
|
79 |
+
path_in_repo =f"generated_samples/{str(len(os.listdir('generated_samples')))}.png",
|
80 |
+
repo_id='AfrodreamsAI/afrodreams',
|
81 |
+
repo_type='space',
|
82 |
+
token=HF_TOKEN
|
83 |
+
)
|
84 |
+
|
85 |
byte_im = buf.getvalue()
|
86 |
run =ste.download_button(button_text="Download Image", data=byte_im, download_filename='afrodreams.jpg', mime="image/png")
|
87 |
#keeping the current style by update the weight
|