osmr / imgclsmob

Sandbox for training deep learning networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple outputs using PSPNet pre-trained model on Cityscapes

Swaraj-72 opened this issue · comments

Hello,
When the PSPNet pre-trained model is used, the output is a tuple of 2 tensors. Can someone clarify what they are and how to achieve 1 output among them such that computation time can be saved?

net = get_model('pspnet_resnetd101b_cityscapes',pretrained_backbone=True,pretrained = True)
yp = net(X)
yp.size()

This throws an error:
AttributeError Traceback (most recent call last)
in
1 yp = net(X) # model outputs 2 different learning rates
----> 2 yp.size()

AttributeError: 'tuple' object has no attribute 'size'

Check the following:

from pytorchcv.model_provider import get_model as ptcv_get_model
import torch
net = ptcv_get_model("pspnet_resnetd101b_cityscapes", pretrained=True, aux=False)
net.eval()
x = torch.randn(1, 3, 480, 480)
y = net(x)

Thanks for the response. It really helped me. One another thing I would like to know is about other input sizes which can be used.

I would like to use multi-scale processing which needs (3,240,240) and (3,120,120) as inputs to the network. Is it possible to achieve that using the model? Thank you.

Technically, yes:

net = ptcv_get_model("pspnet_resnetd101b_cityscapes", pretrained=True, in_size=(120, 120), aux=False)

Thank you for the reply. It helped me a lot with my project.

The pretrained_backbone option provided hasn't seemed to be having a major effect on the predictions. I have tried both booleans and the results did not differ much.
Could you please let me know whether it is to be used any differently to improve the predictions. Thank you.

The pretrained_backbone option is for training.

Thank you for the quick response.