Download clean/video/mintime/models/efficientnet/hubconf.py from deepsafe/model-code: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/deepsafe/model-code/resolve/main/clean/video/mintime/models/efficientnet/hubconf.py
- Command line
-
hf download hf://deepsafe/model-code/clean/video/mintime/models/efficientnet/hubconf.py
-
curl -L -o hubconf.py https://huggingface.co/deepsafe/model-code/resolve/main/clean/video/mintime/models/efficientnet/hubconf.py
1.71 kB
| from efficientnet_pytorch import EfficientNet as _EfficientNet | |
| dependencies = ['torch'] | |
| def _create_model_fn(model_name): | |
| def _model_fn(num_classes=1000, in_channels=3, pretrained='imagenet'): | |
| """Create Efficient Net. | |
| Described in detail here: https://arxiv.org/abs/1905.11946 | |
| Args: | |
| num_classes (int, optional): Number of classes, default is 1000. | |
| in_channels (int, optional): Number of input channels, default | |
| is 3. | |
| pretrained (str, optional): One of [None, 'imagenet', 'advprop'] | |
| If None, no pretrained model is loaded. | |
| If 'imagenet', models trained on imagenet dataset are loaded. | |
| If 'advprop', models trained using adversarial training called | |
| advprop are loaded. It is important to note that the | |
| preprocessing required for the advprop pretrained models is | |
| slightly different from normal ImageNet preprocessing | |
| """ | |
| model_name_ = model_name.replace('_', '-') | |
| if pretrained is not None: | |
| model = _EfficientNet.from_pretrained( | |
| model_name=model_name_, | |
| advprop=(pretrained == 'advprop'), | |
| num_classes=num_classes, | |
| in_channels=in_channels) | |
| else: | |
| model = _EfficientNet.from_name( | |
| model_name=model_name_, | |
| override_params={'num_classes': num_classes}, | |
| ) | |
| model._change_in_channels(in_channels) | |
| return model | |
| return _model_fn | |
| for model_name in ['efficientnet_b' + str(i) for i in range(9)]: | |
| locals()[model_name] = _create_model_fn(model_name) | |