Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
+
|
| 4 |
+
def generate(prompt):
|
| 5 |
+
img = Image.new("RGB", (512, 512), "white")
|
| 6 |
+
draw = ImageDraw.Draw(img)
|
| 7 |
+
|
| 8 |
+
text = "AI Image:\n\n" + prompt
|
| 9 |
+
|
| 10 |
+
draw.text(
|
| 11 |
+
(20, 200),
|
| 12 |
+
text,
|
| 13 |
+
fill="black"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
return img
|
| 17 |
+
|
| 18 |
+
app = gr.Interface(
|
| 19 |
+
fn=generate,
|
| 20 |
+
inputs=gr.Textbox(
|
| 21 |
+
label="Describe your image"
|
| 22 |
+
),
|
| 23 |
+
outputs=gr.Image(
|
| 24 |
+
label="Result"
|
| 25 |
+
),
|
| 26 |
+
title="My AI Image Generator"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
app.launch()
|