qAp / sartorius_cell_instance_segmentation_kaggle

Solution for Sartorius Cell Instance Segmentation Kaggle
0 stars 0 forks source link

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

Open qAp opened 2 years ago

qAp commented 2 years ago

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