The first program, I think there is a connection between the top and bottom.
`import torch
import torch.nn as nn
import pytorch_lightning as pl
class LightningSegformerForSemanticSegmentation(pl.LightningModule):
def init(self, segformer):
super().init()
self.segformer = segformer # 初始化時儲存一個 Segformer 模型
self.criterion = nn.CrossEntropyLoss() # 定義損失函數為交叉熵損失
1 frames
/usr/local/lib/python3.9/dist-packages/pytorch_lightning/utilities/compile.py in _maybe_unwrap_optimized(model)
123 if isinstance(model, pl.LightningModule):
124 return model
--> 125 raise TypeError(
126 f"model must be a LightningModule or torch._dynamo.OptimizedModule, got {type(model).__qualname__}"
127 )
TypeError: model must be a LightningModule or torch._dynamo.OptimizedModule, got `SegformerForSemanticSegmentation``
[https://roboflow.com/models/semantic-segmentation]
I referred to this URL to do semantic segmentation.
Please can the original author answer my question? Thank you.
The first program, I think there is a connection between the top and bottom. `import torch import torch.nn as nn import pytorch_lightning as pl class LightningSegformerForSemanticSegmentation(pl.LightningModule): def init(self, segformer): super().init() self.segformer = segformer # 初始化時儲存一個 Segformer 模型 self.criterion = nn.CrossEntropyLoss() # 定義損失函數為交叉熵損失
`early_stop_callback = EarlyStopping( monitor="val_loss", min_delta=0.00, patience=10, verbose=False, mode="min", )
checkpoint_callback = ModelCheckpoint(save_top_k=1, monitor="val_loss")
trainer = pl.Trainer(
gpus='1',
) trainer.fit(segformer_finetuner)`
error message `INFO:pytorch_lightning.utilities.rank_zero:GPU available: True (cuda), used: True INFO:pytorch_lightning.utilities.rank_zero:TPU available: False, using: 0 TPU cores INFO:pytorch_lightning.utilities.rank_zero:IPU available: False, using: 0 IPUs INFO:pytorch_lightning.utilities.rank_zero:HPU available: False, using: 0 HPUs
TypeError Traceback (most recent call last) in <cell line: 18>()
16 val_check_interval=len(train_dataloader),
17 )
---> 18 trainer.fit(segformer_finetuner)
1 frames /usr/local/lib/python3.9/dist-packages/pytorch_lightning/utilities/compile.py in _maybe_unwrap_optimized(model) 123 if isinstance(model, pl.LightningModule): 124 return model --> 125 raise TypeError( 126 f"
model
must be aLightningModule
ortorch._dynamo.OptimizedModule
, got{type(model).__qualname__}
" 127 )TypeError:
model
must be aLightningModule
ortorch._dynamo.OptimizedModule
, got `SegformerForSemanticSegmentation`` [https://roboflow.com/models/semantic-segmentation] I referred to this URL to do semantic segmentation. Please can the original author answer my question? Thank you.