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.08k forks source link

Training complete, but can't test the neural net #1127

Closed Mikkochu closed 4 years ago

Mikkochu commented 4 years ago

Hi, I'm following this tutorial, but I'm not sure I understand what is happening in the end of the tutorial. I'm using a custom dataset (pictures of playing cards) that I have trained already.

https://github.com/thtrieu/darkflow

I have successfully trained the model and there is now a checkpoint file in the ckpt folder. Also I have created a small video that captures the screen which has a still image, which I'm trying to detect. Here a picture of the card that appears in the video: https://ibb.co/T8dBGH7

Should I run one of these commands to test my network against the video?

For a demo that entirely runs on the CPU:

flow --model cfg/yolo-new.cfg --load bin/yolo-new.weights --demo videofile.avi For a demo that runs 100% on the GPU:

flow --model cfg/yolo-new.cfg --load bin/yolo-new.weights --demo videofile.avi --gpu 1.0

I've understood that the checkpoint file is my new weight file, so can I just rename the checkpoint file name to match "yolo-new.weights"?

What is the yolo-new.cfg file? Where can I find it or how do I create it? This is not explained in the tutorial

Thank you so much. I'd love to get this to work

ankitAMD commented 4 years ago

Checkpoint is new file.... but ....you have to use .meta file you have to use .pb file for testing.

When you train the model on terminal you have to add in your command "--savepb " which can save your .pb file in your built_graph folder.

    Command Example 

            "python flow  --model cfg/yolo-1c.cfg --load bin/yolo.weights --train --annotation new_model_data/annotations --dataset new_model_data/images  --epoch 40 --savepb" 

After training two new files created in the form of .meta and .pb extension in the built_graph folder. Use these two files(.meta and .pb extension files) after training in your testing code of Yolo project.

Use this link to see how to use ............

https://github.com/ankitAMD/Darkflow-object-detection/blob/master/Custom%20Automated%20Testing%20images%20of%20Solar_Panel%20(using%20tiny-yolo.cfg%20and%20weights).ipynb

Your new weight file are .meta and new configuration file are in .pb form extension.

I think your issues are cleared.Please like My comment and close both issues after solved.

Mikkochu commented 4 years ago

Thank you for the reply. I ran the training again with --savepb and now I got the built graph folder with .meta and .pb files

Then I tried to start copying code from your link, but I couldn't figure out how to import TFNet

https://imgur.com/a/FZcMVdH

from darkflow.net.build import TFNet

Any tips?

Thank you. I'll close the issue asap

ankitAMD commented 4 years ago

Thank you for the reply. I ran the training again with --savepb and now I got the built graph folder with .meta and .pb files

Then I tried to start copying code from your link, but I couldn't figure out how to import TFNet

https://imgur.com/a/FZcMVdH

from darkflow.net.build import TFNet

Any tips?

Thank you. I'll close the issue asap

Can you send Error to me ?........

ankitAMD commented 4 years ago

Thank you for the reply. I ran the training again with --savepb and now I got the built graph folder with .meta and .pb files

Then I tried to start copying code from your link, but I couldn't figure out how to import TFNet

https://imgur.com/a/FZcMVdH

from darkflow.net.build import TFNet

Any tips?

Thank you. I'll close the issue asap

Thank you for the reply. I ran the training again with --savepb and now I got the built graph folder with .meta and .pb files

Then I tried to start copying code from your link, but I couldn't figure out how to import TFNet

https://imgur.com/a/FZcMVdH

from darkflow.net.build import TFNet

Any tips?

Thank you. I'll close the issue asap

While running your code Check are you in the right or main (in My case My folder name is Darkflow-object-detection) folder. TFNet is a class which are in build.py python file. Location -----Darkflow-object-detection ->darkflow-->net--->build.py. Please Like my comment and replies. Feel free to Ask any Doubt or issue .Close this issue if it solved.

Mikkochu commented 4 years ago

Hi,

Thank for the reply. I'm still trying to understand why I can't find the subfolder/class. I made a post in stackoverflow

https://stackoverflow.com/questions/59810226/python-3-6-import-subdirectorys-not-working-in-pycharm

ankitAMD commented 4 years ago

I don't know why not showing in your system. There may be two possibilities : 1.You didn't install properly and completely this project from github. 2.You install any wrong Github (which are issues).

Download again this github project (https://github.com/thtrieu/darkflow) and check and compare it these files are present in present github file(Don't replace it first match and if file are missing then copy and paste on that section.) Remember i am using darkflow version not darknet version.

andre-almd commented 4 years ago

Checkpoint is new file.... but ....you have to use .meta file you have to use .pb file for testing.

When you train the model on terminal you have to add in your command "--savepb " which can save your .pb file in your built_graph folder.

    Command Example 

            "python flow  --model cfg/yolo-1c.cfg --load bin/yolo.weights --train --annotation new_model_data/annotations --dataset new_model_data/images  --epoch 40 --savepb" 

After training two new files created in the form of .meta and .pb extension in the built_graph folder. Use these two files(.meta and .pb extension files) after training in your testing code of Yolo project.

Use this link to see how to use ............

https://github.com/ankitAMD/Darkflow-object-detection/blob/master/Custom%20Automated%20Testing%20images%20of%20Solar_Panel%20(using%20tiny-yolo.cfg%20and%20weights).ipynb

Your new weight file are .meta and new configuration file are in .pb form extension.

I think your issues are cleared.Please like My comment and close both issues after solved.

Hello! I did that, but when I run the code the boundbox is not appearing on the image. I dont know if the training was unsufficent to recognize or if there is another problema.

Mikkochu commented 4 years ago

Hi, so I managed to solve to problem by using absolute paths. I'm still having problems but this is solved

import cv2 #Open Source Computer Vision is a library which helps in real-time computer vision and used for Image Processing from darkflow.net.build import TFNet #Tfnet is a class in build.py python files through which Translate darknet to tensorflow. import matplotlib.pyplot as plt #it is used for data visualization

import built_graph

%config InlineBackend.figure_format = 'svg'

define the model options and run

Training the model

define the model options and run

This step involves training your model based on dataset and labels you generated*

options = { 'metaLoad':r"C:\Users\Mikko\PycharmProjects\Darknet_project\darkflow-master\built_graph\tiny-yolo-voc-52c.meta", 'pbLoad':r"C:\Users\Mikko\PycharmProjects\Darknet_project\darkflow-master\built_graph\tiny-yolo-voc-52c.pb", 'threshold': 0.07, 'cpu': 1.0

 }

tfnet = TFNet(options)