ahmetyaylalioglu commited on
Commit
80a267a
·
verified ·
1 Parent(s): 0685b0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -21,8 +21,11 @@ def mask_to_rgb(mask):
21
  return bg_transparent
22
 
23
  def get_processed_inputs(image, points_str):
24
- points = [list(map(int, point.split(','))) for point in points_str.split()]
25
- input_points = [points]
 
 
 
26
  inputs = processor(image, input_points=input_points, return_tensors="pt").to(device)
27
  with torch.no_grad():
28
  outputs = model(**inputs)
@@ -63,7 +66,7 @@ iface = gr.Interface(
63
  fn=gradio_interface,
64
  inputs=[
65
  gr.Image(type="numpy", label="Input Image"),
66
- gr.Textbox(label="Points (format: x1,y1 x2,y2 ...)", placeholder="e.g., 100,100 200,200"),
67
  gr.Textbox(label="Positive Prompt", placeholder="Enter positive prompt here"),
68
  gr.Textbox(label="Negative Prompt", placeholder="Enter negative prompt here")
69
  ],
@@ -72,7 +75,7 @@ iface = gr.Interface(
72
  gr.Image(label="Segmentation Mask")
73
  ],
74
  title="Interactive Image Inpainting",
75
- description="Enter points as 'x1,y1 x2,y2 ...' for segmentation, provide prompts, and see the inpainted result."
76
  )
77
 
78
  iface.launch(share=True)
 
21
  return bg_transparent
22
 
23
  def get_processed_inputs(image, points_str):
24
+ # Parse the input string into a list of points
25
+ points = list(map(int, points_str.split(',')))
26
+ # Reshape the points into pairs
27
+ input_points = [[points[i:i+2]] for i in range(0, len(points), 2)]
28
+
29
  inputs = processor(image, input_points=input_points, return_tensors="pt").to(device)
30
  with torch.no_grad():
31
  outputs = model(**inputs)
 
66
  fn=gradio_interface,
67
  inputs=[
68
  gr.Image(type="numpy", label="Input Image"),
69
+ gr.Textbox(label="Points (format: x1,y1,x2,y2,...)", placeholder="e.g., 100,100,200,200"),
70
  gr.Textbox(label="Positive Prompt", placeholder="Enter positive prompt here"),
71
  gr.Textbox(label="Negative Prompt", placeholder="Enter negative prompt here")
72
  ],
 
75
  gr.Image(label="Segmentation Mask")
76
  ],
77
  title="Interactive Image Inpainting",
78
+ description="Enter points as 'x1,y1,x2,y2,...' for segmentation, provide prompts, and see the inpainted result."
79
  )
80
 
81
  iface.launch(share=True)