日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

ubuntu上训练yolov3: Caught ValueError in DataLoader worker process 0. string indices must be integers.

發布時間:2024/9/30 Ubuntu 122 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu上训练yolov3: Caught ValueError in DataLoader worker process 0. string indices must be integers. 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最后train的代碼:
python3 train.py --model_def config/yolov3-custom.cfg --data_config config/custom.data

按資料下載yolov3進行模型訓練和檢測,下載了好幾份代碼,有一份官方的一直有問題。有一份很快跑起來了(網址忘記了,可以百度網盤分享),明明都是yolov3的pytorch版本但代碼差別很大。記錄遇到的問題和一些測試。

遇到的報錯有:

pip’s dependency resolver does not currently take into account all the
packages that are installed. This behaviour is the source of the
following dependency conflicts. launchpadlib 1.10.6 requires
testresources, which is not installed.

正在保存至: “train2014.zip”

train2014.zip 17%[+++ ] 2.17G 15.7KB/s 剩余
8d 11hget_coco_dataset.sh: 行 13: 31298 段錯誤 (核心已轉儲) wget
-c “https://pjreddie.com/media/files/train2014.zip” --header “Referer: pjreddie.com”
–2021-03-14 10:04:08-- https://pjreddie.com/media/files/val2014.zip 正在解析主機 pjreddie.com (pjreddie.com)… 128.208.4.108 正在連接 pjreddie.com
(pjreddie.com)|128.208.4.108|:443… 已連接。 已發出 HTTP 請求,正在等待回應… 206
Partial Content 長度: 6645013297 (6.2G),剩余 6628416607 (6.2G)
[application/zip] 正在保存至: “val2014.zip”

val2014.zip 0%[ ] 19.08M 2.01KB/s 用時
7m 15sh

2021-03-14 10:11:34 (7.66 KB/s) - 在 20004216 字節處連接關閉。 重試中。

python3 test.py --weights_path weights/yolov3.weights Namespace(batch_size=8, class_path='data/coco.names', conf_thres=0.5, data_config='config/coco.data', img_size=416, iou_thres=0.5, model_def='config/yolov3.cfg', n_cpu=8, nms_thres=0.5, weights_path='weights/yolov3.weights') Compute mAP... Traceback (most recent call last):File "test.py", line 109, in <module>batch_size=opt.batch_size,File "test.py", line 28, in evaluatedataset = ListDataset(path, img_size=img_size, multiscale=False, transform=DEFAULT_TRANSFORMS)File "/home/heziyi/桌面/PyTorch-YOLOv3/utils/datasets.py", line 68, in __init__with open(list_path, "r") as file: FileNotFoundError: [Errno 2] No such file or directory: 'data/coco/5k.txt'

推測上面的報錯是因為train2014.zip和val2014.zip 一直沒法下載的原因,可能是占的空間太大下載不了?
測試時:python3 detect.py --image_folder data/samples/

報錯:
QObject::moveToThread: Current thread (0x42dc8a0) is not the object’s thread (0x6442460).
Cannot move to target thread (0x42dc8a0)
原因:opencv-python版本高。辦法:
sudo pip uninstall opencv-python
Successfully uninstalled opencv-python-4.5.1.48
heziyi@heziyi-ZenBook-UX425IA-U4700IA:~/桌面/PyTorch-YOLOv3$ pip install opencv-python==4.1.0.25 -i https://pypi.tuna.tsinghua.edu.cn/simple

再次運行python3 detect.py --image_folder data/samples/
且可以看到輸出:

pip install pyqt -i https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement pyqt
ERROR: No matching distribution found for pyqt
改為:pip install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple

ubuntu的輸入法打字容易錯字,還是截圖把。
試圖訓練自己引入的圖片。過程:

bash create_custom_model.sh
create_custom_model.sh: 行 1: [net]: 未找到命令
原因:bash格式錯誤,應該加:
#!/bin/bash

NUM_CLASSES=$1

echo "

改為了用yolov3-tiny.cfg
key, value = line.split("=")
ValueError: not enough values to unpack (expected 2, got 1)
推測是自己的config寫的錯誤之類的,把空行和多余的符號都刪掉了。
目前的config:
create_custom_model.sh
執行 bash create_custom_model.sh
可以看到生成了yolov3-custom.cfg

#!/bin/bashNUM_CLASSES=$1echo "[net] # Testing batch=1 subdivisions=1 # Training # batch=64 # subdivisions=2 width=416 height=416 channels=3 momentum=0.9 decay=0.0005 angle=0 saturation = 1.5 exposure = 1.5 hue=.1 learning_rate=0.001 burn_in=1000 max_batches = 500200 policy=steps steps=400000,450000 scales=.1,.1 [convolutional] batch_normalize=1 filters=16 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=32 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=64 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=128 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=1 [convolutional] batch_normalize=1 filters=1024 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=256 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky [convolutional] size=1 stride=1 pad=1 filters=18 activation=linear [yolo] mask = 3,4,5 anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 classes=1 num=6 jitter=.3 ignore_thresh = .7 truth_thresh = 1 random=1 [route] layers = -4 [convolutional] batch_normalize=1 filters=128 size=1 stride=1 pad=1 activation=leaky [upsample] stride=2 [route] layers = -1, 8 [convolutional] batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky [convolutional] size=1 stride=1 pad=1 filters=18 activation=linear [yolo] mask = 0,1,2 anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 classes=1 num=6 jitter=.3 ignore_thresh = .7 truth_thresh = 1 random=1 " >> yolov3-custom.cfg `



Could not read image ‘data/images/BloodImage_00274.jpg’.
Could not read image ‘data/images/BloodImage_00308.jpg’.
這問題找了很久,終于知道了還是圖片位置的原因,需要放在custom下才行,預測是代碼中有設定讀取的是同級文件夾。
只能讀取這個里面的images而不能讀取下面這個images文件夾的:


于是把train.txt內容改為:
現在能運行成功了:

最后一輪epoch
---- mAP 0.6698849929680083
還是挺低的,估計跟圖片過少有關系。
輸入
tensorboard --logdir=‘logs’ --port=6006
打開6006:

總結

以上是生活随笔為你收集整理的ubuntu上训练yolov3: Caught ValueError in DataLoader worker process 0. string indices must be integers.的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。