解决YOLO 3训练出现Couldn't open file:.names train.txt valid.txt

11518 ワード

YOLO 3は自分のデータを訓練する


データ処理後、trainとvalidおよびdataを生成

traintxt = '../dataset/random_save-2020-04-15-17-46-54.train.txt'
validtxt = '../dataset/random_save-2020-04-15-17-46-54.valid.txt'

dataFile = ''
dataFile += 'class=5\r
'
dataFile += f"train=.{traintxt.split('..')[1]}\r
"
dataFile += f"valid=.{validtxt.split('..')[1]}\r
"
dataFile += f'names=./dataset/names_{task_name}.names\r
'
dataFile += f'backup=./output/random\r
'
dataFile += f'eval=coco\r
'
with open(f'../dataset/random_{task_name}.data', 'w+') as F: F.write(dataFile) print(f'data ../dataset/random_{task_name}.data') dataFile = '' dataFile += 'cat\r
'
dataFile += 'dog\r
'
dataFile += 'horse\r
'
dataFile += 'tiger\r
'
dataFile += 'bear\r
'
with open(f'../dataset/names_{task_name}.names', 'w+') as F: F.write(dataFile) print(f'names ../dataset/names_{task_name}.names')

問題は次のとおりです。

yolov3-tiny-5clf
layer     filters    size              input                output
    0 conv     16  3 x 3 / 1   608 x 608 x   3   ->   608 x 608 x  16  0.319 BFLOPs
    1 max          2 x 2 / 2   608 x 608 x  16   ->   304 x 304 x  16
    2 conv     32  3 x 3 / 1   304 x 304 x  16   ->   304 x 304 x  32  0.852 BFLOPs
    3 max          2 x 2 / 2   304 x 304 x  32   ->   152 x 152 x  32
    4 conv     64  3 x 3 / 1   152 x 152 x  32   ->   152 x 152 x  64  0.852 BFLOPs
    5 max          2 x 2 / 2   152 x 152 x  64   ->    76 x  76 x  64
    6 conv    128  3 x 3 / 1    76 x  76 x  64   ->    76 x  76 x 128  0.852 BFLOPs
    7 max          2 x 2 / 2    76 x  76 x 128   ->    38 x  38 x 128
    8 conv    256  3 x 3 / 1    38 x  38 x 128   ->    38 x  38 x 256  0.852 BFLOPs
    9 max          2 x 2 / 2    38 x  38 x 256   ->    19 x  19 x 256
   10 conv    512  3 x 3 / 1    19 x  19 x 256   ->    19 x  19 x 512  0.852 BFLOPs
   11 max          2 x 2 / 1    19 x  19 x 512   ->    19 x  19 x 512
   12 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   13 conv    256  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 256  0.189 BFLOPs
   14 conv    512  3 x 3 / 1    19 x  19 x 256   ->    19 x  19 x 512  0.852 BFLOPs
   15 conv     30  1 x 1 / 1    19 x  19 x 512   ->    19 x  19 x  30  0.011 BFLOPs
   16 yolo
   17 route  13
   18 conv    128  1 x 1 / 1    19 x  19 x 256   ->    19 x  19 x 128  0.024 BFLOPs
   19 upsample            2x    19 x  19 x 128   ->    38 x  38 x 128
   20 route  19 8
   21 conv    256  3 x 3 / 1    38 x  38 x 384   ->    38 x  38 x 256  2.555 BFLOPs
   22 conv     30  1 x 1 / 1    38 x  38 x 256   ->    38 x  38 x  30  0.022 BFLOPs
   23 yolo
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: ../dataset/random_save-2020-04-15-17-46-54.train.txt

???
(base) xx@xxx:~/projects/object$ ls ./dataset/random_save-2020-04-15-17-46-54.train.txt -lh
-rw-rw-r-- 1 xxx xxx 2.1K 4   22 15:43 ./dataset/random_save-2020-04-15-17-46-54.train.txt

ファイルは確かにあります。では問題はどこにあるのでしょうか???


ちょっと
(base) xx@xxx:~/projects/object$ diff dataset/random_Save-2020-04-15-17-46-54.data dataset/random_save-2020-04-15-17-46-54.data 
1,6c1,6
< class=5
< train=./dataset/random_Save-2020-04-15-17-46-54.train.txt
< valid=./dataset/random_Save-2020-04-15-17-46-54.valid.txt
< names=./dataset/names_Save-2020-04-15-17-46-54.names
< backup=./output/random
< eval=coco
---
> class=5
> train=./dataset/random_save-2020-04-15-17-46-54.train.txt
> valid=./dataset/random_save-2020-04-15-17-46-54.valid.txt
> names=./dataset/names_save-2020-04-15-17-46-54.names
> backup=./output/random
> eval=coco


2つのファイルが1行もないことに気づいたのは同じです!!!ghost inside? ではトップページに戻り、この2つのファイルが生成した「r」?

解決策は、すべてのrを

traintxt = '../dataset/random_save-2020-04-15-17-46-54.train.txt'
validtxt = '../dataset/random_save-2020-04-15-17-46-54.valid.txt'

dataFile = ''
dataFile += 'class=5
'
dataFile += f"train=.{traintxt.split('..')[1]}
"
dataFile += f"valid=.{validtxt.split('..')[1]}
"
dataFile += f'names=./dataset/names_{task_name}.names
'
dataFile += f'backup=./output/random
'
dataFile += f'eval=coco
'
with open(f'../dataset/random_{task_name}.data', 'w+') as F: F.write(dataFile) print(f'data ../dataset/random_{task_name}.data') dataFile = '' dataFile += 'cat
'
dataFile += 'dog
'
dataFile += 'horse
'
dataFile += 'tiger
'
dataFile += 'bear
'
with open(f'../dataset/names_{task_name}.names', 'w+') as F: F.write(dataFile) print(f'names ../dataset/names_{task_name}.names')

END