Spaces:
Runtime error
Runtime error
Pedro Cuenca
commited on
Commit
·
2d6dbdd
1
Parent(s):
13caa60
Style: run black.
Browse files- app/streamlit/app.py +7 -3
- app/streamlit/backend.py +4 -4
app/streamlit/app.py
CHANGED
|
@@ -79,11 +79,15 @@ if prompt != "":
|
|
| 79 |
|
| 80 |
version_url = st.secrets["BACKEND_SERVER"] + "/version"
|
| 81 |
version = get_model_version(version_url)
|
| 82 |
-
st.sidebar.markdown(
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
st.markdown(
|
|
|
|
| 85 |
These results have been obtained using model `{version}` from [an ongoing training run](https://wandb.ai/dalle-mini/dalle-mini/runs/mheh9e55).
|
| 86 |
-
"""
|
|
|
|
| 87 |
|
| 88 |
st.button("Again!", key="again_button")
|
| 89 |
|
|
|
|
| 79 |
|
| 80 |
version_url = st.secrets["BACKEND_SERVER"] + "/version"
|
| 81 |
version = get_model_version(version_url)
|
| 82 |
+
st.sidebar.markdown(
|
| 83 |
+
f"<small><center>{version}</center></small>", unsafe_allow_html=True
|
| 84 |
+
)
|
| 85 |
|
| 86 |
+
st.markdown(
|
| 87 |
+
f"""
|
| 88 |
These results have been obtained using model `{version}` from [an ongoing training run](https://wandb.ai/dalle-mini/dalle-mini/runs/mheh9e55).
|
| 89 |
+
"""
|
| 90 |
+
)
|
| 91 |
|
| 92 |
st.button("Again!", key="again_button")
|
| 93 |
|
app/streamlit/backend.py
CHANGED
|
@@ -5,15 +5,14 @@ from io import BytesIO
|
|
| 5 |
import base64
|
| 6 |
from PIL import Image
|
| 7 |
|
|
|
|
| 8 |
class ServiceError(Exception):
|
| 9 |
def __init__(self, status_code):
|
| 10 |
self.status_code = status_code
|
| 11 |
|
|
|
|
| 12 |
def get_images_from_backend(prompt, backend_url):
|
| 13 |
-
r = requests.post(
|
| 14 |
-
backend_url,
|
| 15 |
-
json={"prompt": prompt}
|
| 16 |
-
)
|
| 17 |
if r.status_code == 200:
|
| 18 |
images = r.json()["images"]
|
| 19 |
images = [Image.open(BytesIO(base64.b64decode(img))) for img in images]
|
|
@@ -21,6 +20,7 @@ def get_images_from_backend(prompt, backend_url):
|
|
| 21 |
else:
|
| 22 |
raise ServiceError(r.status_code)
|
| 23 |
|
|
|
|
| 24 |
def get_model_version(url):
|
| 25 |
r = requests.get(url)
|
| 26 |
if r.status_code == 200:
|
|
|
|
| 5 |
import base64
|
| 6 |
from PIL import Image
|
| 7 |
|
| 8 |
+
|
| 9 |
class ServiceError(Exception):
|
| 10 |
def __init__(self, status_code):
|
| 11 |
self.status_code = status_code
|
| 12 |
|
| 13 |
+
|
| 14 |
def get_images_from_backend(prompt, backend_url):
|
| 15 |
+
r = requests.post(backend_url, json={"prompt": prompt})
|
|
|
|
|
|
|
|
|
|
| 16 |
if r.status_code == 200:
|
| 17 |
images = r.json()["images"]
|
| 18 |
images = [Image.open(BytesIO(base64.b64decode(img))) for img in images]
|
|
|
|
| 20 |
else:
|
| 21 |
raise ServiceError(r.status_code)
|
| 22 |
|
| 23 |
+
|
| 24 |
def get_model_version(url):
|
| 25 |
r = requests.get(url)
|
| 26 |
if r.status_code == 200:
|