WoodratTradeCo / crop-rows-detection

It is an real-time crop rows detection method using YOLOv5
GNU General Public License v3.0
20 stars 2 forks source link

I have trained my data. But it doesn't work with your code. #4

Open Filmimagine opened 1 year ago

Filmimagine commented 1 year ago

❔Question

I have trained my data. But it doesn't work with your code.

Additional context

PS D:\project-crop-row> python detect.py --img 320 --weights cropbest.pt --source "test1.mp4" --conf 0.4 Traceback (most recent call last): File "D:\project-crop-row\detect.py", line 358, in detect() File "D:\project-crop-row\detect.py", line 63, in detect model = attempt_load(weights, map_location=device) # load FP32 model File "D:\project-crop-row\models\experimental.py", line 118, in attempt_load ckpt = torch.load(w, map_location=map_location) # load File "C:\Users\NITRO\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 712, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "C:\Users\NITRO\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1049, in _load result = unpickler.load() File "C:\Users\NITRO\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1042, in find_class return super().find_class(mod_name, name) AttributeError: Can't get attribute 'DetectionModel' on <module 'models.yolo' from 'D:\project-crop-row\models\yolo.py'>

WoodratTradeCo commented 1 year ago

This is because the new and old versions of YOLOv5 are incompatible, and the yolo.py file under models is missing the DetectionModel module code. It is recommended that you make changes in the model by comparing the latest Yolo source code as following URL: https://blog.csdn.net/weixin_46389664/article/details/129306692

Filmimagine commented 1 year ago

@WoodratTradeCo Thank you very much, I'll try it, do you have a way to contact you? in case i encounter a problem

Filmimagine commented 1 year ago

@WoodratTradeCo I can train my data from your code? how do you configure

I tried training from your file and it crashes.

D:\UAV\project-crop-row>python train.py --img 640 --batch 8 --epochs 100 --data config.yaml --weights yolov5.pt --workers 4 --cache --device 0 Traceback (most recent call last): File "C:\Program Files\Python39\lib\logging\config.py", line 618, in configure self.configure_logger(name, loggers[name]) File "C:\Program Files\Python39\lib\logging\config.py", line 794, in configure_logger logger = logging.getLogger(name) File "C:\Program Files\Python39\lib\logging__init.py", line 2042, in getLogger return Logger.manager.getLogger(name) File "C:\Program Files\Python39\lib\logging\init__.py", line 1297, in getLogger raise TypeError('A logger name must be a string') TypeError: A logger name must be a string

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "D:\UAV\project-crop-row\train.py", line 497, in set_logging(opt.global_rank) File "D:\UAV\project-crop-row\utils\general.py", line 42, in set_logging logging.config.dictConfig({ File "C:\Program Files\Python39\lib\logging\config.py", line 809, in dictConfig dictConfigClass(config).configure() File "C:\Program Files\Python39\lib\logging\config.py", line 620, in configure raise ValueError('Unable to configure logger ' ValueError: Unable to configure logger -1