Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
import gradio as gr
|
3 |
from groq import Groq
|
4 |
import os
|
|
|
|
|
5 |
from deep_translator import GoogleTranslator
|
6 |
from deep_translator import GoogleTranslator # Import the GoogleTranslator class
|
7 |
import whisper
|
@@ -104,11 +106,14 @@ def generate_image_from_prompt(prompt):
|
|
104 |
d.text((10, 150), "Image Generation Failed", fill=(255, 255, 255))
|
105 |
return error_img
|
106 |
|
|
|
|
|
|
|
107 |
try:
|
108 |
image = Image.open(io.BytesIO(image_bytes))
|
109 |
return image
|
110 |
except Exception as e:
|
111 |
-
print(f"Error: {e}")
|
112 |
error_img = Image.new('RGB', (300, 300), color=(255, 0, 0))
|
113 |
d = ImageDraw.Draw(error_img)
|
114 |
d.text((10, 150), "Invalid Image Data", fill=(255, 255, 255))
|
|
|
2 |
import gradio as gr
|
3 |
from groq import Groq
|
4 |
import os
|
5 |
+
from PIL import Image, ImageDraw
|
6 |
+
import io
|
7 |
from deep_translator import GoogleTranslator
|
8 |
from deep_translator import GoogleTranslator # Import the GoogleTranslator class
|
9 |
import whisper
|
|
|
106 |
d.text((10, 150), "Image Generation Failed", fill=(255, 255, 255))
|
107 |
return error_img
|
108 |
|
109 |
+
# Debug: Check the type of image_bytes
|
110 |
+
print(f"Received image_bytes type: {type(image_bytes)}")
|
111 |
+
|
112 |
try:
|
113 |
image = Image.open(io.BytesIO(image_bytes))
|
114 |
return image
|
115 |
except Exception as e:
|
116 |
+
print(f"Error while opening image: {e}")
|
117 |
error_img = Image.new('RGB', (300, 300), color=(255, 0, 0))
|
118 |
d = ImageDraw.Draw(error_img)
|
119 |
d.text((10, 150), "Invalid Image Data", fill=(255, 255, 255))
|