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

Theano Support #47

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

alecGraves
Copy link
Contributor

@alecGraves alecGraves commented Jun 30, 2017

I got yad2k.py, test_yolo.py, and the training part of retrain_yolo.py to work using theano backend.

The main issue I have come across is converting the output features to final boxes without using the tf session. Also, I could not figure out a way to make non max supression elegantly using the keras backend, so I ended up using a python/numpy implementation someone else made. After doing that, I just converted most of the final box processing code to numpy.

I am not sure if this is a path you want to take, as using numpy to do the final box processing may not be as fast as using custom layers.

This breaks some stuff, so It is not ready to merge yet. The final box prediction parts of retrain_yolo.py need to be updated, and I did not touch the train_overfit.py demo.

Mostly, I just wanted to share my progress and get some feedback. I did this because I needed to run this on ARM, and TensorFlow does not have support for that architecture.

@alecGraves alecGraves changed the title Theano upport (not ready yet) Theano Support (not ready yet) Jun 30, 2017
@alecGraves
Copy link
Contributor Author

Addresses #1

@allanzelener
Copy link
Owner

Hi shadySource, thanks for this comprehensive PR that hits a lot of the todos I've put off!

I've been super busy lately (just moved and got a new job) and so it will probably take me another few weeks to get around to reviewing and testing your PR. But giving it a quick look, it looks quite nice and like what I had in mind.

@alecGraves
Copy link
Contributor Author

alecGraves commented Jul 12, 2017

The changes I made seem to have made running the model 3x slower (probably due to converting all of the post-processing to numpy). It could just be how I set up the final evaluation, but converting final processing to a backend/layers is probably a good idea.

edit: I was building a new computation graph and evaluating it for every image, which takes 0.2 seconds. To avoid this, I made yolo_head_np(), which is about 200x faster than the silliness I was doing before.

@alecGraves
Copy link
Contributor Author

alecGraves commented Jul 19, 2017

Still need to fix the paths in retrain_yolo so it does not look for model stuff in cwd. Besides this, it seems pretty ok.
Edit: Documentation for retraining should be added to the readme, and switching back to hdf5 for training data might be good.

(Future) Adding support for fit generator with full data augmentation for boxes would be cool. (right after that custom loss function)

@alecGraves alecGraves changed the title Theano Support (not ready yet) Theano Support Jul 19, 2017
x = DarknetConv2D_BN_Leaky(1024, (3, 3))(x)
x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x)
return Model(inputs, x)


def yolo_head(feats, anchors, num_classes):
def yolo_head(feats, anchors, num_classes): # TODO: Turn this into a layer?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

3 participants