Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Add a few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vedanuj committed Feb 7, 2020
1 parent 9158751 commit 188e375
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions script/extract_features_from_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_batch_proposals(self, images, im_scales, im_infos, proposals):
proposals_batch = []
for idx, img_info in enumerate(im_infos):
boxes_tensor = torch.from_numpy(
proposals[idx]["bbox"][: int(proposals[idx]["num_box"]), 0:]
proposals[idx]["bbox"][: int(proposals[idx]["num_box"]), 1:]
).to("cuda")
orig_image_size = (img_info["width"], img_info["height"])
boxes = BoxList(boxes_tensor, orig_image_size)
Expand Down Expand Up @@ -224,16 +224,15 @@ def _chunks(self, array, chunk_size):
yield array[i : i + chunk_size]

def _save_feature(self, file_name, feature, info):
file_base_name = os.path.basename(file_name)
file_base_name = file_base_name.split(".")[0]
file_base_name = str(file_name).split(".")[0]
info["image_id"] = file_base_name
info["features"] = feature.cpu().numpy()
file_base_name = str(file_base_name) + ".npy"

np.save(os.path.join(self.args.output_folder, file_base_name), info)

def extract_features(self):
files = np.load(args.imdb_gt_file, allow_pickle=True)
files = np.load(self.args.imdb_gt_file, allow_pickle=True)
# files = sorted(files)
# files = [files[i: i+1000] for i in range(0, len(files), 1000)][self.args.partition]
for chunk in self._chunks(files, self.args.batch_size):
Expand Down

0 comments on commit 188e375

Please sign in to comment.