Spaces:
Runtime error
Runtime error
crop image at the beginning
Browse files- 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_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 =
|
65 |
# image_ori = pad_image(image_ori)
|
66 |
# mask = pad_image(Image.fromarray(grd_mask[0] * 255).convert('RGB'))
|
67 |
image_and_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_ori = image_ori.convert('RGB')
|
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_ori = pad_image(image_ori)
|
66 |
# mask = pad_image(Image.fromarray(grd_mask[0] * 255).convert('RGB'))
|
67 |
image_and_mask = {
|