Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line 9~20 in train.py may not work #40

Closed
violet17 opened this issue Nov 30, 2018 · 5 comments
Closed

line 9~20 in train.py may not work #40

violet17 opened this issue Nov 30, 2018 · 5 comments

Comments

@violet17
Copy link

violet17 commented Nov 30, 2018

line 24 in train.py import test makes line 9~20 may not work.
And it outputs two namespaces, which are

Namespace(batch_report=False, batch_size=16, cfg='cfg/yolov2.cfg', data_config_path='cfg/coco.data', epochs=100, freeze_darknet53=False, img_size=416, optimizer='SGD', resume=False, var=0)

Namespace(batch_size=32, cfg='cfg/yolov3.cfg', class_path='data/coco.names', conf_thres=0.3, data_config_path='cfg/coco.data', img_size=416, iou_thres=0.5, n_cpu=0, nms_thres=0.45, weights_path='weights/yolov3.pt')

Maybe put line 7~19 in test.py inside if __name__ == '__main__': could be better.

@glenn-jocher
Copy link
Member

Oh, thats an interesting comment @violet17. Yes at first this did not work, which is why I added line 23 before importing test.py, to prevent the first namespace from impacting the second.

yolov3/train.py

Lines 22 to 24 in 35e445c

# Import test.py to get mAP after each epoch
sys.argv[1:] = [] # delete any train.py command-line arguments before they reach test.py
import test # must follow sys.argv[1:] = []

I did not think about your solution, but yes this could work also. Which one is better from a 'best-practices' standpoint do you think?

@violet17
Copy link
Author

violet17 commented Dec 2, 2018

Thanks for your reply. Yes, the namespace in the test.py is used in your code.

@glenn-jocher
Copy link
Member

I was thinking about doing what you said, but I realied if we moved the parser arguments inside test.py into the if __name__ == '__main__': statement, we still need to tell it to use latest.pt instead of the default yolov3.pt. I do this now by redefining the the test.py -weights_path in line 205, but if the namespace were not defined yet I wouldn't be able to do this.

yolov3/train.py

Lines 204 to 206 in f05934f

# Calculate mAP
test.opt.weights_path = 'weights/latest.pt'
mAP, R, P = test.main(test.opt)

@violet17
Copy link
Author

violet17 commented Dec 4, 2018

So sorry about that. And thank you for the reply. I was confused about the scope of the namespace before. Now I realize that the first namespace could be used in train.py, and would be used in test.py. And the scope of the second namespace is test.py.

@glenn-jocher
Copy link
Member

Resolved with PR #45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants