Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -136,7 +136,8 @@ def create_gradio_app(api_spec, api_url):
|
|
136 |
print(json_response)
|
137 |
if "status" in json_response and json_response["status"] == "failed":
|
138 |
raise gr.Error("Failed to generate output")
|
139 |
-
|
|
|
140 |
outputs = parse_outputs(json_response["output"])
|
141 |
print(outputs)
|
142 |
for output in outputs:
|
@@ -144,13 +145,13 @@ def create_gradio_app(api_spec, api_url):
|
|
144 |
continue
|
145 |
if output.startswith("data:image"):
|
146 |
# Process as image
|
147 |
-
base64_data =
|
148 |
image_data = base64.b64decode(base64_data)
|
149 |
image_stream = io.BytesIO(image_data)
|
150 |
image = Image.open(image_stream)
|
151 |
return gr.update(visible=True, value=image), gr.update(visible=False), gr.update(visible=False), keys
|
152 |
elif output.startswith("data:audio"):
|
153 |
-
base64_data =
|
154 |
audio_data = base64.b64decode(base64_data)
|
155 |
audio_stream = io.BytesIO(audio_data)
|
156 |
# Here you can save the audio or return the stream for further processing
|
|
|
136 |
print(json_response)
|
137 |
if "status" in json_response and json_response["status"] == "failed":
|
138 |
raise gr.Error("Failed to generate output")
|
139 |
+
|
140 |
+
print(json_response["output"])
|
141 |
outputs = parse_outputs(json_response["output"])
|
142 |
print(outputs)
|
143 |
for output in outputs:
|
|
|
145 |
continue
|
146 |
if output.startswith("data:image"):
|
147 |
# Process as image
|
148 |
+
base64_data = output.split(",", 1)[1]
|
149 |
image_data = base64.b64decode(base64_data)
|
150 |
image_stream = io.BytesIO(image_data)
|
151 |
image = Image.open(image_stream)
|
152 |
return gr.update(visible=True, value=image), gr.update(visible=False), gr.update(visible=False), keys
|
153 |
elif output.startswith("data:audio"):
|
154 |
+
base64_data = output.split(",", 1)[1]
|
155 |
audio_data = base64.b64decode(base64_data)
|
156 |
audio_stream = io.BytesIO(audio_data)
|
157 |
# Here you can save the audio or return the stream for further processing
|