zhanghang1989 / zhanghang1989/PyTorch-Encoding

Transfer learning unable to do

Open
#391 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
448
PR merge metrics
No merged PRs in 30d

Description

Hi @zhanghang1989
I am unable to do transfer learning on the model
i have downloaded get_deeplab_resnest101_ade and
when i changed the no of classes in ade20k.py (no of classes 8)
pre trained model is not loading ( getting error )

So I have changed the code for Transfer learning

Code changes:
  1. deeplab.py
    in get_deeplab_resnest101_ade function changed from
    from
    #model = DeepLabV3(datasets[dataset.lower()].NUM_CLASS, backbone=backbone, root=root, **kwargs)
    to
    no_of_classes = 150
    model = DeepLabV3(no_of_classes, backbone=backbone, root=root, **kwargs)

so i can load pretrained model with 150 classes
then
2) In train_dist.py file

Model loading

model_ft = get_deeplab_resnest101_ade(pretrained=True)

for param in model.parameters():
param.requires_grad = False

model_ft.head.block = Sequential(
(Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)),
(BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)),
(ReLU(inplace=True)),
(Dropout(p=0.1, inplace=False)),
(Conv2d(256, 8, kernel_size=(1, 1), stride=(1, 1))))

for param in model_ft.head.parameters():
param.requires_grad = True

Training

python train_dist.py --dataset ade20k --model deeplab --aux --backbone resnest101 --ft --epochs 100

after successful training
i am getting 150 classes output not 8 classes(i have given 8 classes in last layer)
i need 8 classes output

can you help me with this

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing get_deeplab_resnest101_ade in deeplab.py, the class count in ade20k.py, and model loading and head replacement in train_dist.py. Run the provided train_dist.py command and inspect where the output class count is determined. Done means the trained model produces 8 classes rather than 150.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.