diff --git a/bob/paper/mccnn/tifs2018/config/FASNet_config.py b/bob/paper/mccnn/tifs2018/config/FASNet_config.py index 861bbd3016d700ab7fbe220607678d8e998bd60c..86978a92822c2744fb4d70bfef6f833dface8377 100644 --- a/bob/paper/mccnn/tifs2018/config/FASNet_config.py +++ b/bob/paper/mccnn/tifs2018/config/FASNet_config.py @@ -96,24 +96,31 @@ from bob.learn.pytorch.extractor.image import FASNetExtractor from bob.bio.video.extractor import Wrapper -# MODEL_FILE= None # Replace with '<PATH_TO_MODEL>' -# #################################################################### - # If you want to use the pretrained model -import pkg_resources +USE_PRETRAINED_MODEL=True + +if USE_PRETRAINED_MODEL: + + import pkg_resources + + MODEL_FILE = pkg_resources.resource_filename('bob.paper.mccnn.tifs2018', 'models/fasnet.pth') + + URL = 'https://www.idiap.ch/software/bob/data/bob/bob.paper.mccnn.tifs2018/master/fasnet.pth' + + if not os.path.exists(MODEL_FILE): + + logger.info('Downloading the FASNet model') -MODEL_FILE = pkg_resources.resource_filename('bob.paper.mccnn.tifs2018', 'models/fasnet.pth') + bob.extension.download.download_file(URL, MODEL_FILE) -URL = 'https://www.idiap.ch/software/bob/data/bob/bob.paper.mccnn.tifs2018/master/fasnet.pth' + logger.info('Downloaded FASNet model to location: {}'.format(MODEL_FILE)) -if not os.path.exists(MODEL_FILE): +else: - logger.info('Downloading the FASNet model') + MODEL_FILE= None # Replace with '<PATH_TO_MODEL>' - bob.extension.download.download_file(URL, MODEL_FILE) - logger.info('Downloaded FASNet model to location: {}'.format(MODEL_FILE)) _img_transform = transforms.Compose([transforms.ToPILImage(), transforms.Resize(224, interpolation=2), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], diff --git a/bob/paper/mccnn/tifs2018/config/MCCNN_config.py b/bob/paper/mccnn/tifs2018/config/MCCNN_config.py index b36b5b7ca4b51db19eac46730e50c5dc28cab3b5..93efd159ad4c505d5ee0832fad7ab26d6fe8706a 100644 --- a/bob/paper/mccnn/tifs2018/config/MCCNN_config.py +++ b/bob/paper/mccnn/tifs2018/config/MCCNN_config.py @@ -15,6 +15,8 @@ from torchvision import transforms from bob.learn.pytorch.datasets import ChannelSelect +import os + # names of the channels to process: _channel_names = ['color', 'depth', 'infrared', 'thermal'] @@ -92,24 +94,32 @@ from bob.learn.pytorch.extractor.image import MCCNNExtractor from bob.bio.video.extractor import Wrapper -# MODEL_FILE= None # Replace with '<PATH_TO_MODEL>' -# #################################################################### + # If you want to use the pretrained model -import pkg_resources +USE_PRETRAINED_MODEL=True + +if USE_PRETRAINED_MODEL: + + import pkg_resources + + MODEL_FILE = pkg_resources.resource_filename('bob.paper.mccnn.tifs2018', 'models/mccnn_best_C1-B1-FFC.pth') + + URL = 'http://www.idiap.ch/software/bob/data/bob/bob.paper.mccnn.tifs2018/master/mccnn_best_C1-B1-FFC.pth' + + if not os.path.exists(MODEL_FILE): -MODEL_FILE = pkg_resources.resource_filename('bob.paper.mccnn.tifs2018', 'models/mccnn_best_C1-B1-FFC.pth') + logger.info('Downloading the MCCNN model') -URL = 'http://www.idiap.ch/software/bob/data/bob/bob.paper.mccnn.tifs2018/master/mccnn_best_C1-B1-FFC.pth' + bob.extension.download.download_file(URL, MODEL_FILE) -if not os.path.exists(MODEL_FILE): + logger.info('Downloaded MCCNN model to location: {}'.format(MODEL_FILE)) +else: - logger.info('Downloading the MCCNN model') + MODEL_FILE= None # Replace with '<PATH_TO_MODEL>' - bob.extension.download.download_file(URL, MODEL_FILE) - logger.info('Downloaded MCCNN model to location: {}'.format(MODEL_FILE)) ADAPTED_LAYERS = 'conv1-group1-ffc'