Spaces:
Sleeping
Sleeping
Pavithiran
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -102,20 +102,20 @@ def respond(
|
|
102 |
# Pass the base64-encoded image as the input
|
103 |
response_data = client.text_to_image(images=image_base64, prompt=message) # Pass the base64 string as 'images'
|
104 |
|
105 |
-
#
|
|
|
|
|
106 |
try:
|
107 |
-
# Assuming the response is
|
108 |
-
if 'image' in response_data:
|
109 |
image_response = response_data['image']
|
110 |
-
print("Image Res:")
|
111 |
-
print(image_response)
|
112 |
# Decode the base64 image back into an image object
|
113 |
image_bytes = base64.b64decode(image_response)
|
114 |
image = Image.open(io.BytesIO(image_bytes))
|
115 |
image.show() # Or return the image in Gradio
|
116 |
-
return "Image processed successfully"
|
117 |
else:
|
118 |
-
return "Error:
|
119 |
except Exception as e:
|
120 |
return f"Error processing image: {e}"
|
121 |
|
|
|
102 |
# Pass the base64-encoded image as the input
|
103 |
response_data = client.text_to_image(images=image_base64, prompt=message) # Pass the base64 string as 'images'
|
104 |
|
105 |
+
# Debug: print the response data to check its content
|
106 |
+
print("Response Data: ", response_data)
|
107 |
+
|
108 |
try:
|
109 |
+
# Assuming the response is in the correct format, check for image content
|
110 |
+
if isinstance(response_data, dict) and 'image' in response_data:
|
111 |
image_response = response_data['image']
|
|
|
|
|
112 |
# Decode the base64 image back into an image object
|
113 |
image_bytes = base64.b64decode(image_response)
|
114 |
image = Image.open(io.BytesIO(image_bytes))
|
115 |
image.show() # Or return the image in Gradio
|
116 |
+
return "Image processed successfully"
|
117 |
else:
|
118 |
+
return f"Error: Unexpected response format or no image data found. Response: {response_data}"
|
119 |
except Exception as e:
|
120 |
return f"Error processing image: {e}"
|
121 |
|