kinsung commited on
Commit
aaf25f8
1 Parent(s): c35cdc9
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -8,8 +8,8 @@ feature_extractor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-101
8
  dmodel = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-101")
9
 
10
  i1 = gr.inputs.Image(type="pil", label="Input image")
11
- i2 = gr.inputs.Number(default=400, label="Custom Width (optional)")
12
- i3 = gr.inputs.Number(default=400, label="Custom Height (optional)")
13
  o1 = gr.outputs.Image(type="pil", label="Cropped part")
14
 
15
  def extract_image(image, custom_width, custom_height):
@@ -45,13 +45,10 @@ def extract_image(image, custom_width, custom_height):
45
  ymax = min(image.height, ymax)
46
 
47
  cropped_image = image.crop((xmin, ymin, xmax, ymax))
48
-
49
- # Return the coordinates of the cropped area
50
- coordinates = f"xmin: {xmin}, ymin: {ymin}, xmax: {xmax}, ymax: {ymax}"
51
 
52
  return cropped_image
53
 
54
- title = "Social Media Crop"
55
- description = "<p style='color:white'>Crop an image with the area containing the most detected objects while maintaining custom dimensions and adding a 10-pixel bleed. The area is centralized within the custom dimensions.</p>"
56
  examples = [['ex3.jpg', 800, 400], ['cat.png', 400, 400]]
57
  gr.Interface(fn=extract_image, inputs=[i1, i2, i3], outputs=[o1], title=title, description=description, examples=examples, enable_queue=True).launch()
 
8
  dmodel = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-101")
9
 
10
  i1 = gr.inputs.Image(type="pil", label="Input image")
11
+ i2 = gr.inputs.Number(default=400, label="Custom Width")
12
+ i3 = gr.inputs.Number(default=400, label="Custom Height")
13
  o1 = gr.outputs.Image(type="pil", label="Cropped part")
14
 
15
  def extract_image(image, custom_width, custom_height):
 
45
  ymax = min(image.height, ymax)
46
 
47
  cropped_image = image.crop((xmin, ymin, xmax, ymax))
 
 
 
48
 
49
  return cropped_image
50
 
51
+ title = "Auto Crop"
52
+ description = "<p style='color:black'>Crop an image with the area containing the most detected objects. </p>"
53
  examples = [['ex3.jpg', 800, 400], ['cat.png', 400, 400]]
54
  gr.Interface(fn=extract_image, inputs=[i1, i2, i3], outputs=[o1], title=title, description=description, examples=examples, enable_queue=True).launch()