Pavithiran commited on
Commit
9b1a6d3
·
verified ·
1 Parent(s): 3badfd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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
- # Check if the response is in the correct format (e.g., image)
 
 
106
  try:
107
- # Assuming the response is an image in base64 format
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" # You can return some confirmation or process the image further
117
  else:
118
- return "Error: No valid image returned from the model."
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