-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
added initial semantic segmentation example #751
Conversation
@akshaykvnit awesome. can you get the tests to pass and update the docs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for this example, and apology for the delay...
Could you pls have look at comments and
- get the tests to pass
- add general docstring t the file root with reference to resources
@williamFalcon a bit more general thought is it would be better to write examples as ipython notebooks which we can transform to nice pages in Docs even with images as I did here |
@Borda @williamFalcon I have made most of the changes suggested by @Borda in the last review (with the exception of inference usage) and got the tests to pass. I haven't been able to implement the inference usage properly. That will take some more time.
I had initially implemented this in a Jupyter Notebook, but then the usage of |
@akshaykvnit do you want to do it here in this PR or would you prefer to make a follow-up PR?
In this case, I have in mind to create a kind of lightning ZOO with the models and their particular trainers and then having notebook would be nice as an extra example with hparams can be simple derived without duplicating extra code... just building from prefabricated bricks... @williamFalcon ? |
Yes, I'll make a follow-up PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there 🚀 pls add documentation to the classes (better also to methods) as we are generating Docs from all examples...
|
||
|
||
class SegModel(pl.LightningModule): | ||
def __init__(self, hparams): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as examples are becoming part of the Docs, we shall add at least basic documentation with a brief description and reference to resources...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what documentation you need here. Because none of the other examples have documentation for the LightningModule
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ment someting like:
"""Image segmentation model.
This is a basic image segmentation model implemented with Lightning ...
References
- <link to source / publication>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the latest commit
btw, just curious how did you verify without inference? just see the validation/test curve? |
Hello @akshaykvnit! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-02-16 12:52:52 UTC |
@Borda I implemented the reference using normal PyTorch and it works. You can see the results here in the last block of the notebook. I added the same code after However, I figured that you needed inference to work when |
@williamFalcon how about the docs for examples? I would say it shall contain them as it is part of Docs but probably it is not a blocker... :] |
@akshaykvnit awesome tutorial! |
@akshaykvnit @Borda
oops, looks like this test fails. Need to fix asap |
Yeah I have noticed that almost all examples are not tested at all... We shall run them with a minimal data.... |
Before submitting
What does this PR do?
Fixes #635 (Semantic Segmentation example).
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Some additional info
I tried to add a
test_step
in theLightningModule
which logs the predicted segmentation output. Since the default logger is TensorBoard, I expected the images to show up when I usetensorboard logdir=lightning_logs
(at the default save path). But, they don't show up. I couldn't find any example which uses the logger properly. So, if someone can point me to an example, then I'll finish that (right now it's commented out).Also, I have kind of followed the GAN example as a template, so I have put all of the code in a single file. If you prefer, then I can separate the
Dataset
class into another file. And I have added this as afull_example
, so please let me know if you want it indomain_examples
or something.Also, I have used the KITTI dataset (since it is small and enough for an example) but it is not available directly in
torchvision
. So, it needs to be downloaded separately and the path needs to be given in thehparams
. Note that the segmentation datasets available in torchvision (like Pascal VOC) are too large for a simple example.Also, I couldn't figure out what documentation or tests are required, because none of the other examples have any documentation or tests (that I could find). Please point out if anything is required.