thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.07k forks source link

How to train a model using Full_Yolo weights? #778

Open mohamedabdallah1996 opened 6 years ago

mohamedabdallah1996 commented 6 years ago

I trained a model for 32 class withtiny yoloBut the accuracy was not good enough. I want to train the model using full yolo weights.

What I did:

I tried to train the model with a new cfg modified fromyolo-full.cfg. and when I created a new file and changed the number of classes and filter of the last layer, I get this error

/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py:54: UserWarning: ./cfg/yolo-full.cfg not found, use cfg/v1/new-yolo-full.cfg instead
  cfg_path, FLAGS.model))
Parsing cfg/v1/yolo-full.cfg
Loading bin/yolo-full.weights ...
Traceback (most recent call last):
  File "/usr/local/bin/flow", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/content/drive/CoLab/YOLO/darkflow/flow", line 6, in <module>
    cliHandler(sys.argv)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/cli.py", line 26, in cliHandler
    tfnet = TFNet(FLAGS)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py", line 27, in __init__
    self.load_weights()
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py", line 82, in load_weights
    wgts_loader = loader.create_loader(*args)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 105, in create_loader
    return load_type(path, cfg)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 19, in __init__
    self.load(*args)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 77, in load
    walker.offset, walker.size)
AssertionError: expect 382319340 bytes, found 1086814216

what I understand from this error that it needs the cfg file has the same name of the weights. so I changed it to yolo-full.cfg But I get the same error:

/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py:54: UserWarning: ./cfg/yolo-full.cfg not found, use cfg/v1/yolo-full.cfg instead
  cfg_path, FLAGS.model))
Parsing cfg/v1/yolo-full.cfg
Loading bin/yolo-full.weights ...
Traceback (most recent call last):
  File "/usr/local/bin/flow", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/content/drive/CoLab/YOLO/darkflow/flow", line 6, in <module>
    cliHandler(sys.argv)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/cli.py", line 26, in cliHandler
    tfnet = TFNet(FLAGS)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py", line 27, in __init__
    self.load_weights()
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/dark/darknet.py", line 82, in load_weights
    wgts_loader = loader.create_loader(*args)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 105, in create_loader
    return load_type(path, cfg)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 19, in __init__
    self.load(*args)
  File "/content/drive/CoLab/YOLO/darkflow/darkflow/utils/loader.py", line 77, in load
    walker.offset, walker.size)
AssertionError: expect 382319340 bytes, found 1086814216

What does this mean ? and please if anyone has more clarified steps about how to train a model using full yolo it would be appreciated !

Any suggestions please ..

youyuge34 commented 6 years ago

Just use the full yolo model trained by voc or the tiny yolo model by coco, combined the .weights file on the darknet official site, they fit well. Remember that all the .cfg files under the ~/cfg/ mean to YOLOv2. So u should use the v2 weights on the darknet official site. And all the .cfg files under the ~/cfg/v1 mean to YOLOv1 which is out of time.

mohamedabdallah1996 commented 6 years ago

Thank you so much for your response. I'll try that