|
@@ -6,7 +6,8 @@ import logging
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
|
from annotations import NAB_Annotations, CUB_Annotations
|
|
from annotations import NAB_Annotations, CUB_Annotations
|
|
-from dataset import Dataset, reveal_parts, \
|
|
|
|
|
|
+from dataset import Dataset
|
|
|
|
+from dataset.utils import reveal_parts, \
|
|
visible_part_locs, visible_crops, \
|
|
visible_part_locs, visible_crops, \
|
|
uniform_part_locs, crops
|
|
uniform_part_locs, crops
|
|
|
|
|
|
@@ -50,27 +51,29 @@ def main(args):
|
|
|
|
|
|
fig1 = plt.figure(figsize=(16,9))
|
|
fig1 = plt.figure(figsize=(16,9))
|
|
ax = fig1.add_subplot(2,1,1)
|
|
ax = fig1.add_subplot(2,1,1)
|
|
-
|
|
|
|
ax.imshow(im)
|
|
ax.imshow(im)
|
|
ax.scatter(*xy, marker="x", c=idxs)
|
|
ax.scatter(*xy, marker="x", c=idxs)
|
|
|
|
+ ax.axis("off")
|
|
|
|
|
|
ax = fig1.add_subplot(2,1,2)
|
|
ax = fig1.add_subplot(2,1,2)
|
|
ax.imshow(reveal_parts(im, xy, ratio=args.ratio))
|
|
ax.imshow(reveal_parts(im, xy, ratio=args.ratio))
|
|
ax.scatter(*xy, marker="x", c=idxs)
|
|
ax.scatter(*xy, marker="x", c=idxs)
|
|
-
|
|
|
|
- fig2 = plt.figure(figsize=(16,9))
|
|
|
|
|
|
+ ax.axis("off")
|
|
|
|
|
|
if args.uniform_parts:
|
|
if args.uniform_parts:
|
|
part_crops = crops(im, xy, ratio=args.ratio)
|
|
part_crops = crops(im, xy, ratio=args.ratio)
|
|
else:
|
|
else:
|
|
part_crops = visible_crops(im, parts, ratio=args.ratio)
|
|
part_crops = visible_crops(im, parts, ratio=args.ratio)
|
|
|
|
|
|
|
|
+ fig2 = plt.figure(figsize=(16,9))
|
|
n_crops = len(part_crops)
|
|
n_crops = len(part_crops)
|
|
rows = int(np.ceil(np.sqrt(n_crops)))
|
|
rows = int(np.ceil(np.sqrt(n_crops)))
|
|
cols = int(np.ceil(n_crops / rows))
|
|
cols = int(np.ceil(n_crops / rows))
|
|
|
|
+
|
|
for j, crop in enumerate(part_crops, 1):
|
|
for j, crop in enumerate(part_crops, 1):
|
|
ax = fig2.add_subplot(rows, cols, j)
|
|
ax = fig2.add_subplot(rows, cols, j)
|
|
ax.imshow(crop)
|
|
ax.imshow(crop)
|
|
|
|
+ ax.axis("off")
|
|
|
|
|
|
middle_h, middle_w = crop.shape[0] / 2, crop.shape[1] / 2
|
|
middle_h, middle_w = crop.shape[0] / 2, crop.shape[1] / 2
|
|
ax.scatter(middle_w, middle_h, marker="x")
|
|
ax.scatter(middle_w, middle_h, marker="x")
|
|
@@ -109,6 +112,10 @@ parser.add_argument("--ratio",
|
|
help="Part extraction ratio",
|
|
help="Part extraction ratio",
|
|
type=float, default=.2)
|
|
type=float, default=.2)
|
|
|
|
|
|
|
|
+parser.add_argument("--rnd",
|
|
|
|
+ help="select random subset of present parts",
|
|
|
|
+ action="store_true")
|
|
|
|
+
|
|
parser.add_argument("--uniform_parts", "-u",
|
|
parser.add_argument("--uniform_parts", "-u",
|
|
help="Do not use GT parts, but sample parts uniformly from the image",
|
|
help="Do not use GT parts, but sample parts uniformly from the image",
|
|
action="store_true")
|
|
action="store_true")
|