Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
from utils import generate_thumbnail
|
| 4 |
+
|
| 5 |
+
def process(image, text, font_size, position, text_color):
|
| 6 |
+
result = generate_thumbnail(image, text, font_size=font_size, position=position, text_color=text_color)
|
| 7 |
+
return result
|
| 8 |
+
|
| 9 |
+
demo = gr.Interface(
|
| 10 |
+
fn=process,
|
| 11 |
+
inputs=[
|
| 12 |
+
gr.Image(type="pil", label="Upload Background Image"),
|
| 13 |
+
gr.Textbox(label="Thumbnail Text"),
|
| 14 |
+
gr.Slider(20, 100, step=5, value=60, label="Font Size"),
|
| 15 |
+
gr.Radio(["top", "center", "bottom"], label="Text Position", value="bottom"),
|
| 16 |
+
gr.ColorPicker(label="Text Color", value="#FFFFFF"),
|
| 17 |
+
],
|
| 18 |
+
outputs=gr.Image(label="Generated Thumbnail"),
|
| 19 |
+
title="🖼️ AI Thumbnail Generator",
|
| 20 |
+
description="Upload an image and generate a custom thumbnail with your text.",
|
| 21 |
+
allow_flagging="never"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
demo.launch()
|