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

feat: input files check (filter the unreadable files) #38

Open
wants to merge 1 commit into
base: master
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
47 changes: 25 additions & 22 deletions datasets/simple_extractor_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,31 @@ def __getitem__(self, index):
img_name = self.file_list[index]
img_path = os.path.join(self.root, img_name)
img = cv2.imread(img_path, cv2.IMREAD_COLOR)
h, w, _ = img.shape
if np.any(img):
h, w, _ = img.shape

# Get person center and scale
person_center, s = self._box2cs([0, 0, w - 1, h - 1])
r = 0
trans = get_affine_transform(person_center, s, r, self.input_size)
input = cv2.warpAffine(
img,
trans,
(int(self.input_size[1]), int(self.input_size[0])),
flags=cv2.INTER_LINEAR,
borderMode=cv2.BORDER_CONSTANT,
borderValue=(0, 0, 0))
# Get person center and scale
person_center, s = self._box2cs([0, 0, w - 1, h - 1])
r = 0
trans = get_affine_transform(person_center, s, r, self.input_size)
input = cv2.warpAffine(
img,
trans,
(int(self.input_size[1]), int(self.input_size[0])),
flags=cv2.INTER_LINEAR,
borderMode=cv2.BORDER_CONSTANT,
borderValue=(0, 0, 0))

input = self.transform(input)
meta = {
'name': img_name,
'center': person_center,
'height': h,
'width': w,
'scale': s,
'rotation': r
}
input = self.transform(input)
meta = {
'name': img_name,
'center': person_center,
'height': h,
'width': w,
'scale': s,
'rotation': r
}

return input, meta
return 0

return input, meta
2 changes: 2 additions & 0 deletions simple_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def main():
palette = get_palette(num_classes)
with torch.no_grad():
for idx, batch in enumerate(tqdm(dataloader)):
if len(batch) == 1:
continue
image, meta = batch
img_name = meta['name'][0]
c = meta['center'].numpy()[0]
Expand Down