jw2yang commited on
Commit
d2729fc
1 Parent(s): 289b7df

Update tasks/ref_in.py

Browse files
Files changed (1) hide show
  1. tasks/ref_in.py +3 -3
tasks/ref_in.py CHANGED
@@ -37,7 +37,7 @@ def crop_image(input_image):
37
  def referring_inpainting(model, image, texts, inpainting_text, *args, **kwargs):
38
  model.model.metadata = metadata
39
  texts = [[texts if texts.strip().endswith('.') else (texts.strip() + '.')]]
40
- image_ori = transform(image)
41
 
42
  with torch.no_grad():
43
  width = image_ori.size[0]
@@ -58,10 +58,10 @@ def referring_inpainting(model, image, texts, inpainting_text, *args, **kwargs):
58
 
59
  if inpainting_text not in ['no', '']:
60
  # if we want to do inpainting
61
- image_crop = crop_image(image_ori)
62
  struct2 = ndimage.generate_binary_structure(2, 2)
63
  mask_dilated = ndimage.binary_dilation(grd_mask[0], structure=struct2, iterations=3).astype(grd_mask[0].dtype)
64
- mask = crop_image(Image.fromarray(mask_dilated * 255).convert('RGB'))
65
  image_and_mask = {
66
  "image": image_crop,
67
  "mask": mask,
37
  def referring_inpainting(model, image, texts, inpainting_text, *args, **kwargs):
38
  model.model.metadata = metadata
39
  texts = [[texts if texts.strip().endswith('.') else (texts.strip() + '.')]]
40
+ image_ori = crop_image(transform(image))
41
 
42
  with torch.no_grad():
43
  width = image_ori.size[0]
58
 
59
  if inpainting_text not in ['no', '']:
60
  # if we want to do inpainting
61
+ image_crop = image_ori
62
  struct2 = ndimage.generate_binary_structure(2, 2)
63
  mask_dilated = ndimage.binary_dilation(grd_mask[0], structure=struct2, iterations=3).astype(grd_mask[0].dtype)
64
+ mask = Image.fromarray(mask_dilated * 255).convert('RGB')
65
  image_and_mask = {
66
  "image": image_crop,
67
  "mask": mask,