Skip to content

Commit

Permalink
Removed check if input is image
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus committed Nov 16, 2020
1 parent 04bf716 commit c416771
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions retinaface/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
tensor_from_rgb_image,
)
from iglovikov_helper_functions.utils.image_utils import pad_to_size, unpad_from_size
from PIL import Image, UnidentifiedImageError
from PIL import Image
from torch.nn import functional as F
from torch.utils.data import Dataset
from torch.utils.data.distributed import DistributedSampler
Expand Down Expand Up @@ -183,17 +183,6 @@ def process_predictions(
return result


def check_if_image(file_list: List[Path]) -> List[Path]:
result: List[Path] = []
for file_path in tqdm(file_list):
try:
Image.open(file_path)
except UnidentifiedImageError:
continue
result += [file_path]
return result


def main():
args = get_args()
torch.distributed.init_process_group(backend="nccl")
Expand Down Expand Up @@ -240,10 +229,7 @@ def main():
model, device_ids=[args.local_rank], output_device=args.local_rank
)

file_paths = []

for regexp in ["*"]:
file_paths += check_if_image(list(args.input_path.rglob(regexp)))
file_paths = list(args.input_path.rglob("*.jpg"))

dataset = InferenceDataset(file_paths, max_size=args.max_size, transform=from_dict(hparams["test_aug"]))

Expand Down

0 comments on commit c416771

Please sign in to comment.