|
@@ -14,11 +14,11 @@ from utils import parser, plot_crops
|
|
|
|
|
|
def main(args):
|
|
|
assert args.dataset in AnnotationType, \
|
|
|
- "AnnotationType is not known: \"{}\"".format(args.dataset)
|
|
|
+ f"AnnotationType is not known: \"{args.dataset}\""
|
|
|
|
|
|
annotation_cls = AnnotationType[args.dataset].value
|
|
|
|
|
|
- logging.info("Loading \"{}\" annnotations from \"{}\"".format(args.dataset, args.data))
|
|
|
+ logging.info(f"Loading \"{args.dataset}\" annnotations from \"{args.data}\"")
|
|
|
annot = annotation_cls(args.data, args.parts, args.feature_model)
|
|
|
|
|
|
kwargs = {}
|
|
@@ -46,7 +46,7 @@ def main(args):
|
|
|
**kwargs
|
|
|
)
|
|
|
|
|
|
- logging.info("Loaded {} {} images".format(len(data), args.subset))
|
|
|
+ logging.info(f"Loaded {len(data)} {args.subset} images")
|
|
|
|
|
|
start = max(args.start, 0)
|
|
|
n_images = min(args.n_images, len(data) - start)
|
|
@@ -55,18 +55,19 @@ def main(args):
|
|
|
for i in idxs:
|
|
|
im, parts, label = data[i]
|
|
|
|
|
|
- fig1, axs = plt.subplots(2, 1, figsize=(16,9))
|
|
|
+ fig1, axs = plt.subplots(1, 1, figsize=(16,9))
|
|
|
+ axs = [axs]
|
|
|
|
|
|
axs[0].axis("off")
|
|
|
axs[0].set_title("Visible Parts")
|
|
|
axs[0].imshow(im)
|
|
|
if not args.crop_to_bb and not args.no_bboxes:
|
|
|
data.plot_bounding_box(i, axs[0])
|
|
|
- parts.plot(im=im, ax=axs[0], ratio=data.ratio)
|
|
|
+ parts.plot(im=im, ax=axs[0], ratio=data.ratio, linewidth=3)
|
|
|
|
|
|
- axs[1].axis("off")
|
|
|
- axs[1].set_title("{}selected parts".format("randomly " if args.rnd else ""))
|
|
|
- axs[1].imshow(parts.reveal(im, ratio=data.ratio))
|
|
|
+ # axs[1].axis("off")
|
|
|
+ # axs[1].set_title("{}selected parts".format("randomly " if args.rnd else ""))
|
|
|
+ # axs[1].imshow(parts.reveal(im, ratio=data.ratio))
|
|
|
|
|
|
if data.uniform_parts:
|
|
|
crop_names = None
|
|
@@ -78,10 +79,10 @@ def main(args):
|
|
|
parts.invert_selection()
|
|
|
action_crops = parts.visible_crops(im, ratio=data.ratio)
|
|
|
|
|
|
- plot_crops(part_crops, "Selected parts", names=crop_names)
|
|
|
+ plot_crops(part_crops, f"{args.parts}: Selected parts", names=crop_names)
|
|
|
|
|
|
if args.rnd:
|
|
|
- plot_crops(action_crops, "Actions", names=crop_names)
|
|
|
+ plot_crops(action_crops, f"{args.parts}: Actions", names=crop_names)
|
|
|
|
|
|
plt.show()
|
|
|
plt.close()
|