Skip to content

Commit a2c97fb

Browse files
committed
Small fixes
1 parent 22ea895 commit a2c97fb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

demos/python_demos/image_inpainting_demo/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ to fill holes in images.
77
This demo can work in 2 modes:
88

99
* GUI mode: areas for inpainting can be marked interactively using mouse painting
10-
* Auto mode (use -a option for it): image will be processed automatically using randomly applied mask (-r option) or using specific color-based mask (-mc option to set mask color)
10+
* Auto mode (use -am or -ar option for it): image will be processed automatically using randomly applied mask (-ar option) or using specific color-based mask (-am option)
1111

1212
Running the application with the `-h` option yields the following usage message:
1313

1414
```
1515
usage: image_inpainting_demo.py [-h] -m MODEL [-i INPUT] [-d DEVICE]
1616
[-p PARTS] [-mbw MAX_BRUSH_WIDTH]
1717
[-ml MAX_LENGTH] [-mv MAX_VERTEX] [--no_show]
18-
[-o OUTPUT]
19-
[-am AUTO_MASK AUTO_MASK AUTO_MASK] [-ar]
18+
[-o OUTPUT] [-am C C C] [-ar]
2019
2120
Options:
2221
-h, --help Show this help message and exit.
@@ -46,12 +45,13 @@ Options:
4645
-o OUTPUT, --output OUTPUT
4746
Optional. Save output to the file with provided
4847
filename. Ignored in GUI mode
49-
-am AUTO_MASK AUTO_MASK AUTO_MASK, --auto_mask AUTO_MASK AUTO_MASK AUTO_MASK
48+
-am C C C, --auto_mask_color C C C
5049
Optional. Use automatic (non-interactive) mode with
5150
color mask.Provide color to be treated as mask (3 RGB
5251
components in range of 0...255). Cannot be used
5352
together with -ar.
54-
-ar, --auto_rnd Optional. Use automatic (non-interactive) mode with
53+
-ar, --auto_mask_random
54+
Optional. Use automatic (non-interactive) mode with
5555
random mask for inpainting (with parameters set by -p,
5656
-mbw, -mk and -mv). Cannot be used together with -am.
5757
```

demos/python_demos/image_inpainting_demo/image_inpainting_demo.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def build_arg_parser():
4545
args.add_argument("--no_show", help="Optional. Don't show output. Cannot be used in GUI mode", action='store_true')
4646
args.add_argument("-o", "--output", help="Optional. Save output to the file with provided filename."
4747
" Ignored in GUI mode", default="", type=str)
48-
args.add_argument("-am", "--auto_mask", help="Optional. Use automatic (non-interactive) mode with color mask."
48+
args.add_argument("-am", "--auto_mask_color", help="Optional. Use automatic (non-interactive) mode with color mask."
4949
"Provide color to be treated as mask (3 RGB components in range of 0...255). "
5050
"Cannot be used together with -ar.",
51-
default=None, type=int, nargs=3)
52-
args.add_argument("-ar", "--auto_rnd",
51+
metavar='C', default=None, type=int, nargs=3)
52+
args.add_argument("-ar", "--auto_mask_random",
5353
help="Optional. Use automatic (non-interactive) mode with random mask for inpainting"
5454
" (with parameters set by -p, -mbw, -mk and -mv). Cannot be used together with -am.",
5555
action='store_true')
@@ -86,20 +86,20 @@ def inpaint_auto(img, args):
8686

8787
inpainting_processor = ImageInpainting(ie, args.model, args.device)
8888

89-
#--- Resize to model input and generate random mask
90-
if args.auto_rnd:
89+
#--- Generating mask
90+
if args.auto_mask_random:
9191
mask = create_random_mask(args.parts, args.max_vertex, args.max_length, args.max_brush_width,
9292
inpainting_processor.input_height, inpainting_processor.input_width)
9393
else:
9494
# argument comes in RGB mode, but we will use BGR notation below
95-
top = np.full(img.shape, args.auto_mask[::-1], np.uint8)
95+
top = np.full(img.shape, args.auto_mask_color[::-1], np.uint8)
9696
mask = cv2.inRange(img, top, top)
9797
mask = cv2.resize(mask, (inpainting_processor.input_width, inpainting_processor.input_height))
9898
_, mask = cv2.threshold(mask, 1, 1, cv2.THRESH_BINARY)
9999
mask = np.expand_dims(mask, 2)
100100

101+
#--- Resizing image and removing masked areas from it
101102
img = cv2.resize(img, (inpainting_processor.input_width, inpainting_processor.input_height))
102-
103103
masked_image = (img * (1 - mask) + 255 * mask).astype(np.uint8)
104104

105105
#--- Inpaint and show results
@@ -117,11 +117,11 @@ def main():
117117
print("Cannot load image " + args.input)
118118
return -1
119119

120-
if args.auto_mask and args.auto_rnd:
120+
if args.auto_mask_color and args.auto_mask_random:
121121
print("Error: -ar and -am options cannot be used together...")
122122
return -1
123123

124-
if args.auto_mask or args.auto_rnd:
124+
if args.auto_mask_color or args.auto_mask_random:
125125
# Command-line inpaining for just one image
126126
concat_image, result = inpaint_auto(img,args)
127127
if args.output != "":

0 commit comments

Comments
 (0)