Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import cv2
|
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
from PIL import Image, ImageDraw, ImageFont
|
5 |
-
import io
|
6 |
|
7 |
def generate_text_image(text, style, width, height):
|
8 |
"""Generate an image of the input text with the selected style."""
|
@@ -67,13 +66,14 @@ def overlay_text_on_clothing(clothing_image, text_input, style, strength=20, alp
|
|
67 |
for c in range(3):
|
68 |
clothing_img[:, :, c] = (1 - alpha_channel) * clothing_img[:, :, c] + alpha_channel * text_warped[:, :, c]
|
69 |
|
70 |
-
|
71 |
-
|
|
|
72 |
|
73 |
interface = gr.Interface(
|
74 |
fn=overlay_text_on_clothing,
|
75 |
inputs=[
|
76 |
-
gr.Image(type="filepath", label="Upload Clothing Image", interactive=True),
|
77 |
gr.Textbox(label="Enter Text for Design"),
|
78 |
gr.Radio(["Bold", "Italic", "Graffiti", "Calligraphy"], label="Select Style", value="Bold"),
|
79 |
gr.Slider(10, 50, step=5, value=20, label="Displacement Strength"),
|
|
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
4 |
from PIL import Image, ImageDraw, ImageFont
|
|
|
5 |
|
6 |
def generate_text_image(text, style, width, height):
|
7 |
"""Generate an image of the input text with the selected style."""
|
|
|
66 |
for c in range(3):
|
67 |
clothing_img[:, :, c] = (1 - alpha_channel) * clothing_img[:, :, c] + alpha_channel * text_warped[:, :, c]
|
68 |
|
69 |
+
# Convert the final blended image back to a PIL Image and return
|
70 |
+
blended_img = Image.fromarray(cv2.cvtColor(clothing_img, cv2.COLOR_BGR2RGB))
|
71 |
+
return blended_img
|
72 |
|
73 |
interface = gr.Interface(
|
74 |
fn=overlay_text_on_clothing,
|
75 |
inputs=[
|
76 |
+
gr.Image(type="filepath", label="Upload Clothing Image", interactive=True),
|
77 |
gr.Textbox(label="Enter Text for Design"),
|
78 |
gr.Radio(["Bold", "Italic", "Graffiti", "Calligraphy"], label="Select Style", value="Bold"),
|
79 |
gr.Slider(10, 50, step=5, value=20, label="Displacement Strength"),
|