gaur3009 commited on
Commit
7430fac
1 Parent(s): 9ee7b39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
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(crop_points):
52
- if crop_points:
53
- x_coords = [point[0] for point in crop_points]
54
- y_coords = [point[1] for point in crop_points]
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, crop_points: process_image(
63
- image, color, design, design_position, text, text_position, font_size, font_color, resize, rotate, get_crop_coords(crop_points)
64
  ),
65
  inputs=[
66
  gr.Image(type="pil"),
67
  gr.ColorPicker(label="Color"),
68
  gr.File(label="Design"),
69
- gr.Image(tool="sketch", label="Design Position"),
70
  gr.Textbox(label="Text"),
71
- gr.Image(tool="sketch", label="Text Position"),
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.Image(tool="sketch", label="Crop Area")
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