Practical overview
When it fits
Use it when building a PyTorch image-classification workflow that starts from a supported pretrained CNN and needs a classifier tailored to a new class count or other documented model settings.
Who it is for
- Python developers building image-classification models with PyTorch
- Practitioners adapting ImageNet-pretrained CNNs to datasets with different class counts
- Developers who need configurable input sizes, dropout, pooling or classifier layers
Documented uses
- Create a classifier with a chosen number of output classes from a pretrained CNN.
- Select a supported CNN architecture from torchvision or the Pretrained models for PyTorch package.
- Configure dropout, pooling, input resolution or a custom classifier.
- Review preprocessing details associated with the original pretrained model.
Requirements & limits
The project is a public GitHub repository with an MIT license. The README documents installation as a Python package and lists Python 3.5+ and PyTorch 1.1+ as requirements.
- Supported architectures come from torchvision and the separate Pretrained models for PyTorch package.
- VGG and AlexNet require an explicit input size when constructing a model.
- The documented examples focus on model construction; they do not provide a complete training workflow.
- The README exposes original-model preprocessing information that can guide input preparation.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Create a pretrained ResNet classifier for a chosen class count
Construct an ImageNet-pretrained ResNet-18 with a replacement classifier for 10 classes.
Before you start
- Python 3.5 or newer
- PyTorch 1.1 or newer
- The cnn_finetune package
Steps
Install the package with the command below.
pip install cnn_finetuneImport
make_modelfromcnn_finetune.Call
make_model('resnet18', num_classes=10, pretrained=True).
Expected outcome
A ResNet-18 model initialized with pretrained weights and configured for 10 output classes.
Guide limitations
- This recipe constructs the model; the documented example does not cover training it.
- Preparing a dataset, training loop and evaluation process are outside the shown steps.
Set an input resolution for VGG16
Construct a pretrained VGG16 classifier configured for 10 classes and 256×256-pixel inputs.
Before you start
- Python 3.5 or newer
- PyTorch 1.1 or newer
- The cnn_finetune package
Steps
Install the package with the command below.
pip install cnn_finetuneImport
make_modelfromcnn_finetune.Call
make_model('vgg16', num_classes=10, pretrained=True, input_size=(256, 256)).
Expected outcome
A pretrained VGG16 model configured for 10 classes and the specified input dimensions.
Guide limitations
- VGG and AlexNet require
input_sizewhen constructing a model because their fully connected layers depend on the input dimensions. - The documented steps create the model but do not train it.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 7 November 2026
- Original website title
- creafz/pytorch-cnn-finetune · Official homepage title · retained in its source language

