qAp/sartorius_cell_instance_segmentation_kaggle

Cannot convert to torchscript when model's forward function instantiates a nn.Module.

Opened this issue · 0 comments

qAp commented

This occurs when running pl.LightningModule.to_torchscript, when, in the forward method of the model, there is an instantiation of a nn class, like nn.Upsample. Perhaps, the instantiation needs to happen in the model's __init__ method.

FrontendError: Cannot instantiate class 'Upsample' in a script function:
  File "/kaggle/sartorius_cell_instance_segmentation_kaggle/seggit/models/watershed_transform_net.py", line 47
        x = self.fcn(x)
    
        x = nn.Upsample(input_size)(x)
            ~~~~~~~~~~~ <--- HERE
    
        return x