fabrice-eberle / mpt_faces_fab_fou_til

Framework for lecture "Machine Perception and Tracking" Task 1
3 stars 0 forks source link

Error during Model Saving #6

Closed fabrice-eberle closed 3 months ago

fabrice-eberle commented 3 months ago

While training the network, after some epochs I get following error code. Something seems off while opening and writing on the model.pt or with the zo writer???

Traceback (most recent call last): File "C:\Users\fabri\OneDrive\DAISY\4. Semester\MPT\MPT Faces\mpt_faces_fab_fou_til\train.py", line 91, in train(args) File "C:\Users\fabri\OneDrive\DAISY\4. Semester\MPT\MPT Faces\mpt_faces_fab_fou_til\train.py", line 83, in train torch.save({"model": net.state_dict(), "classes": trainset.classes}, "model.pt") File "C:\Users\fabri\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\serialization.py", line 627, in save with _open_zipfile_writer(f) as opened_zipfile: ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabri\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\serialization.py", line 501, in _open_zipfile_writer return container(name_or_buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabri\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\serialization.py", line 472, in init super().init(torch._C.PyTorchFileWriter(self.name))

fabrice-eberle commented 3 months ago

Solved issue 6 by adding .jit. I don´t know why, but I found the solution

https://stackoverflow.com/questions/74925031/runtime-error-while-saving-a-pytorch-model-file-path-to-be-saved-cannot-be-op Here is the new line:

torch.jit.save({"model": net.state_dict(), "classes": trainset.classes}, "model.pt")