Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -334,33 +334,20 @@ def get_image_as_base64(url):
|
|
334 |
return base64.b64encode(response.content).decode("utf-8")
|
335 |
else:
|
336 |
return None
|
337 |
-
|
338 |
def create_download_link(filename, base64_str):
|
339 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
340 |
return href
|
341 |
-
|
342 |
-
# List of image URLs
|
343 |
image_urls = [
|
344 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/gv1xmIiXh1NGTeeV-cYF2.png",
|
345 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/2YsnDyc_nDNW71PPKozdN.png",
|
346 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/G_GkRD_IT3f14K7gWlbwi.png",
|
347 |
]
|
348 |
-
|
349 |
-
# Select a random URL from the list
|
350 |
selected_image_url = random.choice(image_urls)
|
351 |
-
|
352 |
-
# Get the base64 encoded string of the selected image
|
353 |
selected_image_base64 = get_image_as_base64(selected_image_url)
|
354 |
-
|
355 |
if selected_image_base64 is not None:
|
356 |
with st.sidebar:
|
357 |
st.markdown("""### Word Game AI""")
|
358 |
-
# Display the image
|
359 |
st.markdown(f"")
|
360 |
-
|
361 |
-
# Create and display the download link
|
362 |
-
#download_link = create_download_link("downloaded_image.png", selected_image_base64)
|
363 |
-
#st.markdown(download_link, unsafe_allow_html=True)
|
364 |
else:
|
365 |
st.sidebar.write("Failed to load the image.")
|
366 |
# ---- Art Card Sidebar with random selection of image.
|
|
|
334 |
return base64.b64encode(response.content).decode("utf-8")
|
335 |
else:
|
336 |
return None
|
|
|
337 |
def create_download_link(filename, base64_str):
|
338 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
339 |
return href
|
|
|
|
|
340 |
image_urls = [
|
341 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/gv1xmIiXh1NGTeeV-cYF2.png",
|
342 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/2YsnDyc_nDNW71PPKozdN.png",
|
343 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/G_GkRD_IT3f14K7gWlbwi.png",
|
344 |
]
|
|
|
|
|
345 |
selected_image_url = random.choice(image_urls)
|
|
|
|
|
346 |
selected_image_base64 = get_image_as_base64(selected_image_url)
|
|
|
347 |
if selected_image_base64 is not None:
|
348 |
with st.sidebar:
|
349 |
st.markdown("""### Word Game AI""")
|
|
|
350 |
st.markdown(f"")
|
|
|
|
|
|
|
|
|
351 |
else:
|
352 |
st.sidebar.write("Failed to load the image.")
|
353 |
# ---- Art Card Sidebar with random selection of image.
|