Fix incorrect task when loading saved checkpoint (#20966)
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
This commit is contained in:
parent
6b12046694
commit
58ccf00ea5
@ -293,7 +293,7 @@ class Model(torch.nn.Module):
|
||||
|
||||
if str(weights).rpartition(".")[-1] == "pt":
|
||||
self.model, self.ckpt = attempt_load_one_weight(weights)
|
||||
self.task = self.model.args["task"]
|
||||
self.task = self.model.task
|
||||
self.overrides = self.model.args = self._reset_ckpt_args(self.model.args)
|
||||
self.ckpt_path = self.model.pt_path
|
||||
else:
|
||||
|
||||
@ -1505,7 +1505,7 @@ def attempt_load_weights(weights, device=None, inplace=True, fuse=False):
|
||||
# Model compatibility updates
|
||||
model.args = args # attach args to model
|
||||
model.pt_path = w # attach *.pt file path to model
|
||||
model.task = guess_model_task(model)
|
||||
model.task = getattr(model, "task", guess_model_task(model))
|
||||
if not hasattr(model, "stride"):
|
||||
model.stride = torch.tensor([32.0])
|
||||
|
||||
@ -1553,7 +1553,7 @@ def attempt_load_one_weight(weight, device=None, inplace=True, fuse=False):
|
||||
# Model compatibility updates
|
||||
model.args = {k: v for k, v in args.items() if k in DEFAULT_CFG_KEYS} # attach args to model
|
||||
model.pt_path = weight # attach *.pt file path to model
|
||||
model.task = guess_model_task(model)
|
||||
model.task = getattr(model, "task", guess_model_task(model))
|
||||
if not hasattr(model, "stride"):
|
||||
model.stride = torch.tensor([32.0])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user