Skip to content

Commit

Permalink
Fix "Resize Human masks" option (#21)
Browse files Browse the repository at this point in the history
* fix resize

* change method

* remove arg

* fix array not resizing

* fix wrong shape
  • Loading branch information
vorozhkog authored Nov 20, 2024
1 parent 9c4652b commit ccfe178
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"modal_template_state": {
"humanMasks": true,
"resizeHumanMasks": false,
"resizePercent": 100,
"resizePercent": 50,
"machineMasks": true,
"instanceMasks": false,
"thickness": 2
Expand Down
9 changes: 5 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ def export_as_masks(api: sly.Api):

if g.RESIZE_HUMAN_MASKS:
new_dimensions = (
int(overlay.shape[0] * (g.RESIZE_PERCENT / 100)),
int(overlay.shape[1] * (g.RESIZE_PERCENT / 100)),
overlay.shape[2],
int(array_to_write.shape[1] * (g.RESIZE_PERCENT / 100)),
int(array_to_write.shape[0] * (g.RESIZE_PERCENT / 100)),
)
array_to_write = cv2.resize(
array_to_write, new_dimensions, interpolation=cv2.INTER_AREA
)
array_to_write.resize(new_dimensions)

sly.image.write(
os.path.join(human_masks_dir, mask_img_name),
Expand Down

0 comments on commit ccfe178

Please sign in to comment.