Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from huggingface_hub import InferenceClient, AsyncInferenceClient
|
|
3 |
from PIL import Image
|
4 |
from pathlib import Path
|
5 |
import os, subprocess
|
|
|
6 |
|
7 |
st.set_page_config(page_title='HG Inference Client Demo',layout="wide")
|
8 |
# Cache the header of the app to prevent re-rendering on each load
|
@@ -223,7 +224,10 @@ if selected_task :
|
|
223 |
st.audio(os.path.join(cwd,"audio.flac"))
|
224 |
with col2:
|
225 |
if dict_hg_tasks_params[task]["output"] == "image,text":
|
226 |
-
|
|
|
|
|
|
|
227 |
st.image(image)
|
228 |
elif dict_hg_tasks_params[task]["output"] == "image":
|
229 |
response.save(os.path.join(cwd,"generated_image.png"))
|
|
|
3 |
from PIL import Image
|
4 |
from pathlib import Path
|
5 |
import os, subprocess
|
6 |
+
import requests
|
7 |
|
8 |
st.set_page_config(page_title='HG Inference Client Demo',layout="wide")
|
9 |
# Cache the header of the app to prevent re-rendering on each load
|
|
|
224 |
st.audio(os.path.join(cwd,"audio.flac"))
|
225 |
with col2:
|
226 |
if dict_hg_tasks_params[task]["output"] == "image,text":
|
227 |
+
if not(isinstance(input, str)):
|
228 |
+
image = Image.open(input)
|
229 |
+
else:
|
230 |
+
image = Image.open(requests.get(input, stream=True).raw)
|
231 |
st.image(image)
|
232 |
elif dict_hg_tasks_params[task]["output"] == "image":
|
233 |
response.save(os.path.join(cwd,"generated_image.png"))
|