Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo bugs #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def get_parser():
if len(args.input) == 1:
for k in visualized_output.keys():
os.makedirs(k, exist_ok=True)
out_filename = os.path.join(k, args.output)
out_filename = os.path.join(args.output, k)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @affromero, thanks for the PR!

A question: for a single input, we pass args.output as <FILENAME>.ext where ext can be jpg/png. So, this change would not work for this case. f"{k}_{args.output}" should solve this, IMO.

visualized_output[k].save(out_filename)
else:
for k in visualized_output.keys():
Expand Down
7 changes: 4 additions & 3 deletions demo/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,22 @@ def non_empty_mask(self):
assert (
len(empty_ids) == 1
), ">1 ids corresponds to no labels. This is currently not supported"
return (self._seg != empty_ids[0]).numpy().astype(np.bool)
return (self._seg != empty_ids[0]).numpy().astype(bool)

def semantic_masks(self):
for sid in self._seg_ids:
sinfo = self._sinfo.get(sid)
if sinfo is None or sinfo["isthing"]:
# Some pixels (e.g. id 0 in PanopticFPN) have no instance or semantic predictions.
continue
yield (self._seg == sid).numpy().astype(np.bool), sinfo
yield (self._seg == sid).numpy().astype(bool), sinfo

def instance_masks(self):
for sid in self._seg_ids:
sinfo = self._sinfo.get(sid)
if sinfo is None or not sinfo["isthing"]:
continue
mask = (self._seg == sid).numpy().astype(np.bool)
mask = (self._seg == sid).numpy().astype(bool)
if mask.sum() > 0:
yield mask, sinfo

Expand Down Expand Up @@ -966,6 +966,7 @@ def draw_text(
font_size = self._default_font_size

# since the text background is dark, we don't want the text to be dark
color = tuple(np.clip(color, a_min=0, a_max=1))
color = np.maximum(list(mplc.to_rgb(color)), 0.2)
color[np.argmax(color)] = max(0.8, np.max(color))

Expand Down