Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,10 +48,10 @@ def process_image(image, color, design, design_position, text, text_position, fo
|
|
48 |
if crop_coords:
|
49 |
image = crop_image(image, crop_coords)
|
50 |
return image
|
51 |
-
def get_crop_coords(
|
52 |
-
if
|
53 |
-
x_coords = [point[0] for point in
|
54 |
-
y_coords = [point[1] for point in
|
55 |
return (min(x_coords), min(y_coords), max(x_coords), max(y_coords))
|
56 |
return None
|
57 |
|
@@ -59,21 +59,21 @@ design_position = (100, 100) # Default position for design
|
|
59 |
text_position = (50, 50) # Default position for text
|
60 |
|
61 |
interface = gr.Interface(
|
62 |
-
fn=lambda image, color, design, design_position, text, text_position, font_size, font_color, resize, rotate,
|
63 |
-
image, color, design, design_position, text, text_position, font_size, font_color, resize, rotate, get_crop_coords(
|
64 |
),
|
65 |
inputs=[
|
66 |
gr.Image(type="pil"),
|
67 |
gr.ColorPicker(label="Color"),
|
68 |
gr.File(label="Design"),
|
69 |
-
gr.
|
70 |
gr.Textbox(label="Text"),
|
71 |
-
gr.
|
72 |
gr.Slider(10, 100, step=1, default=20, label="Font Size"),
|
73 |
gr.ColorPicker(label="Font Color"),
|
74 |
gr.Slider(50, 1000, step=1, default=None, label="Resize"),
|
75 |
gr.Slider(0, 360, step=1, default=None, label="Rotate"),
|
76 |
-
gr.
|
77 |
],
|
78 |
outputs=gr.Image(type="pil"),
|
79 |
live=True
|
|
|
48 |
if crop_coords:
|
49 |
image = crop_image(image, crop_coords)
|
50 |
return image
|
51 |
+
def get_crop_coords(crop_sketch):
|
52 |
+
if crop_sketch:
|
53 |
+
x_coords = [point[0] for point in crop_sketch]
|
54 |
+
y_coords = [point[1] for point in crop_sketch]
|
55 |
return (min(x_coords), min(y_coords), max(x_coords), max(y_coords))
|
56 |
return None
|
57 |
|
|
|
59 |
text_position = (50, 50) # Default position for text
|
60 |
|
61 |
interface = gr.Interface(
|
62 |
+
fn=lambda image, color, design, design_position, text, text_position, font_size, font_color, resize, rotate, crop_sketch: process_image(
|
63 |
+
image, color, design, design_position, text, text_position, font_size, font_color, resize, rotate, get_crop_coords(crop_sketch)
|
64 |
),
|
65 |
inputs=[
|
66 |
gr.Image(type="pil"),
|
67 |
gr.ColorPicker(label="Color"),
|
68 |
gr.File(label="Design"),
|
69 |
+
gr.Sketchpad(label="Design Position", shape=(256, 256)),
|
70 |
gr.Textbox(label="Text"),
|
71 |
+
gr.Sketchpad(label="Text Position", shape=(256, 256)),
|
72 |
gr.Slider(10, 100, step=1, default=20, label="Font Size"),
|
73 |
gr.ColorPicker(label="Font Color"),
|
74 |
gr.Slider(50, 1000, step=1, default=None, label="Resize"),
|
75 |
gr.Slider(0, 360, step=1, default=None, label="Rotate"),
|
76 |
+
gr.Sketchpad(label="Crop Area", shape=(256, 256))
|
77 |
],
|
78 |
outputs=gr.Image(type="pil"),
|
79 |
live=True
|