From 42185c4beb9ab256c8b38bb46f6331d6e6286353 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 19 Jan 2022 09:25:20 +0100 Subject: [PATCH] FeatureExtractor: avoid loading weights twice When passing a model_path to the FeatureExtractor, weights are loaded twice. One the pretrained once and then the given ones. Avoid the unnecessary load. --- torchreid/utils/feature_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchreid/utils/feature_extractor.py b/torchreid/utils/feature_extractor.py index 3fb9d90..83635fd 100644 --- a/torchreid/utils/feature_extractor.py +++ b/torchreid/utils/feature_extractor.py @@ -71,7 +71,7 @@ class FeatureExtractor(object): model = build_model( model_name, num_classes=1, - pretrained=True, + pretrained=not (model_path and check_isfile(model_path)), use_gpu=device.startswith('cuda') ) model.eval()