Spaces:
Sleeping
Sleeping
fix output
Browse files
app.py
CHANGED
@@ -1,26 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
from PIL import Image # Make sure PIL or Pillow is installed
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
image = model.generate(prompt, seed=random_seed)
|
12 |
-
|
13 |
-
# Ensure the image is in a format compatible with Gradio
|
14 |
-
if isinstance(image, Image.Image):
|
15 |
-
return image
|
16 |
-
else:
|
17 |
-
# If image is not in PIL format, convert or handle it
|
18 |
-
return "Error: Image not in expected format"
|
19 |
-
except Exception as e:
|
20 |
-
return f"Error: {e}"
|
21 |
-
|
22 |
-
# Load the model
|
23 |
-
model = gr.load("models/black-forest-labs/FLUX.1-schnell")
|
24 |
|
25 |
# Create Gradio interface
|
26 |
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image")
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image, ImageDraw
|
|
|
3 |
|
4 |
def generate_image(prompt):
|
5 |
+
# Create a simple image for testing
|
6 |
+
img = Image.new('RGB', (100, 100), color='red')
|
7 |
+
draw = ImageDraw.Draw(img)
|
8 |
+
draw.text((10, 10), prompt, fill='white')
|
9 |
+
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Create Gradio interface
|
12 |
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image")
|