Spaces:
No application file
No application file
Download App.py from Nickib2023/app.py: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/Nickib2023/app.py/resolve/main/App.py
- Command line
-
hf download hf://spaces/Nickib2023/app.py/App.py
-
curl -L -o App.py https://huggingface.co/spaces/Nickib2023/app.py/resolve/main/App.py
1.12 kB
| ```python id="g7r5g0" | |
| import gradio as gr | |
| from PIL import Image, ImageDraw | |
| import random | |
| def generate_image(prompt): | |
| width = 768 | |
| height = 768 | |
| img = Image.new( | |
| "RGB", | |
| (width, height), | |
| color=(15, 15, 25) | |
| ) | |
| draw = ImageDraw.Draw(img) | |
| colors = [ | |
| (255, 0, 140), | |
| (125, 44, 255), | |
| (0, 255, 200), | |
| (255, 120, 0), | |
| ] | |
| for i in range(40): | |
| x1 = random.randint(0, width) | |
| y1 = random.randint(0, height) | |
| x2 = random.randint(0, width) | |
| y2 = random.randint(0, height) | |
| draw.rectangle( | |
| [x1, y1, x2, y2], | |
| outline=random.choice(colors), | |
| width=3 | |
| ) | |
| draw.text( | |
| (30, 30), | |
| prompt, | |
| fill=(255, 255, 255) | |
| ) | |
| return img | |
| demo = gr.Interface( | |
| fn=generate_image, | |
| inputs=gr.Textbox( | |
| label="Enter Prompt", | |
| placeholder="luxury AI influencer photoshoot" | |
| ), | |
| outputs=gr.Image(label="Generated Image"), | |
| title="Squirt4Daddy AI Generator", | |
| description="AI creator image generator demo" | |
| ) | |
| demo.launch() | |
| ``` | |