Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,14 +17,9 @@ st.set_page_config(
|
|
| 17 |
}
|
| 18 |
)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
import base64
|
| 25 |
import requests
|
| 26 |
-
|
| 27 |
-
# Function to fetch and encode the image to base64
|
| 28 |
def get_image_as_base64(url):
|
| 29 |
response = requests.get(url)
|
| 30 |
if response.status_code == 200:
|
|
@@ -32,34 +27,24 @@ def get_image_as_base64(url):
|
|
| 32 |
return base64.b64encode(response.content).decode("utf-8")
|
| 33 |
else:
|
| 34 |
return None
|
| 35 |
-
|
| 36 |
-
# Function to create a download link for the image
|
| 37 |
def create_download_link(filename, base64_str):
|
| 38 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
| 39 |
return href
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
image_url = "https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/
|
| 43 |
-
image_base64 = get_image_as_base64(image_url)
|
| 44 |
|
|
|
|
| 45 |
if image_base64 is not None:
|
| 46 |
-
# Display the image using the base64 string
|
| 47 |
with st.sidebar:
|
|
|
|
| 48 |
st.markdown(f"")
|
| 49 |
-
|
| 50 |
-
#
|
| 51 |
-
download_link = create_download_link("downloaded_image.png", image_base64)
|
| 52 |
-
st.markdown(download_link, unsafe_allow_html=True)
|
| 53 |
else:
|
| 54 |
st.sidebar.write("Failed to load the image.")
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
with st.sidebar:
|
| 58 |
-
st.markdown("""
|
| 59 |
-
### Mixable Card Game AI
|
| 60 |
-
|
| 61 |
-
""")
|
| 62 |
-
|
| 63 |
|
| 64 |
|
| 65 |
# Ensure the directory for storing scores exists
|
|
|
|
| 17 |
}
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# -----------------------------------------------------------------Art Card Sidebar:
|
|
|
|
|
|
|
|
|
|
| 21 |
import base64
|
| 22 |
import requests
|
|
|
|
|
|
|
| 23 |
def get_image_as_base64(url):
|
| 24 |
response = requests.get(url)
|
| 25 |
if response.status_code == 200:
|
|
|
|
| 27 |
return base64.b64encode(response.content).decode("utf-8")
|
| 28 |
else:
|
| 29 |
return None
|
| 30 |
+
|
|
|
|
| 31 |
def create_download_link(filename, base64_str):
|
| 32 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
| 33 |
return href
|
| 34 |
|
| 35 |
+
# Get this from paste into markdown feature
|
| 36 |
+
image_url = "https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/6ld4w73-KcAE1pYV-suZV.png"
|
|
|
|
| 37 |
|
| 38 |
+
image_base64 = get_image_as_base64(image_url)
|
| 39 |
if image_base64 is not None:
|
|
|
|
| 40 |
with st.sidebar:
|
| 41 |
+
st.markdown("""### Mixable Card Game AI""")
|
| 42 |
st.markdown(f"")
|
| 43 |
+
#download_link = create_download_link("downloaded_image.png", image_base64)
|
| 44 |
+
#st.markdown(download_link, unsafe_allow_html=True)
|
|
|
|
|
|
|
| 45 |
else:
|
| 46 |
st.sidebar.write("Failed to load the image.")
|
| 47 |
+
# ------------------------------------------------------------- Art Card Sidebar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
# Ensure the directory for storing scores exists
|