Problem Description:
When using pytorch to load the pre training model, an error occurs: modulenotfounderror: no module named ‘models’. The pre training model is yolov5s.pt downloaded from the official
Solution:
Build the directory structure of yolov5 under the wrong file directory. That is, you need to exist yolov5 models and utils, and copy these two folders to the file directory. For example, at this time, the location where I report an error is yolov5/train.py. Because I use yolov5 for transplantation, the yolov5 directory is not a real yolov5, so I will report missing models. The deeper reason is that the following method is used to save weights (there is another way to save and load models, which can be viewed in the official document of pytorch. That method will not cause this problem and is more conducive to migration):
The weights saved in this way will also save the relative position of the source code of your model by default (here refers to the models folder and utils folder in yolov5).Yolo5s.pt downloaded from the official must be trained under this directory structure, so we can build this directory structure.
Similar Posts:
- Detailed explanation of yolo2 — yolo9000, better, faster, stronger
- [Solved] module ‘keras.engine.topology’ has no attribute ‘load_weights_from_hdf5_group_by_name…
- [Solved] yolov3 Error: cuda error: out of memory darknet: ./src/cuda.c:36: check_error: Assertion `0′ failed.
- Name Error: name ‘yolo_head’ is not defined [How to Solve]
- What are hyperparameters in machine learning?
- python Warning: OverflowError: Python int too large to convert to C long
- Preservation and recovery of TF. Train. Saver () model of tensorflow
- [How to Solve Pytorch Error] EOFError: Ran out of input
- Paddlepaddle uses multi process error reporting “(External) CUDA error (3), initialization error.” solution.
- [Solved] Keras loads the model Error: attributeerror: ‘STR’ object has no attribute ‘decode’