Open leichaoyang opened 10 months ago
Have you solved this problem?
Have you solved this problem?
no
also see in this problem, don‘t val in the val data ?
OKAY after searching for a WHILE! found the solution!!!! :D
in file FastSAM/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/validator.py :
modify the
self.loss += trainer.criterion(preds, batch)[1]
for this
self.loss += model.loss(batch, preds)[1]
When using FASTSAM to train your own data, an error is reported:
Traceback (most recent call last): File "/home/feishi/FastSAM/train_and_validation/train_sa.py", line 4, in
model.train(data="sa.yaml", \
File "/home/feishi/FastSAM/train_and_validation/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/model.py", line 373, in train
self.trainer.train()
File "/home/feishi/FastSAM/train_and_validation/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/trainer.py", line 192, in train
self._do_train(world_size)
File "/home/feishi/FastSAM/train_and_validation/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/trainer.py", line 371, in _do_train
self.metrics, self.fitness = self.validate()
File "/home/feishi/FastSAM/train_and_validation/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/trainer.py", line 477, in validate
metrics = self.validator(self)
File "/home/feishi/anaconda3/envs/FastSAM/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/home/feishi/FastSAM/train_and_validation/ultralytics-d8701b42caeb9f7f1de5fd45e7c3f3cf1724ebb6/ultralytics/yolo/engine/validator.py", line 165, in call
self.loss += trainer.criterion(preds, batch)[1]
AttributeError: 'SegmentationTrainer' object has no attribute 'criterion'