Skip to content

Commit 79ae3ea

Browse files
committed
First commit
0 parents  commit 79ae3ea

File tree

99 files changed

+7523
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+7523
-0
lines changed

CONTRIBUTING.md

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# How to contribute to lightly?
2+
3+
Everyone is welcome to contribute, and we value everybody's contribution. Code is thus not the only way to help the community. Answering questions, helping others, reaching out and improving the documentations are immensely valuable to the community.
4+
5+
It also helps us if you spread the word: reference the library from blog posts on the awesome projects it made possible, shout out on Twitter every time it has helped you, or simply star the repo to say "thank you".
6+
7+
## You can contribute in so many ways!
8+
9+
There are 4 ways you can contribute to lightly:
10+
* Fixing outstanding issues with the existing code;
11+
* Implementing new models;
12+
* Contributing to the examples or to the documentation;
13+
* Submitting issues related to bugs or desired new features.
14+
15+
*All are equally valuable to the community.*
16+
17+
## Submitting a new issue or feature request
18+
19+
Do your best to follow these guidelines when submitting an issue or a feature
20+
request. It will make it easier for us to come back to you quickly and with good
21+
feedback.
22+
23+
### Did you find a bug?
24+
25+
First, **please make sure the bug was not already reported** (use the search bar on Github under Issues).
26+
27+
* Include your **OS type and version**, the versions of **Python**, **PyTorch**, and **PyTorch Lightning**.
28+
* A code snippet that allows us to reproduce the bug in less than 30s.
29+
* Provide the *full* traceback if an exception is raised.
30+
31+
### Do you want to implement a new self-supervised model?
32+
33+
Awesome! Please provide the following information:
34+
35+
* Short description of the model and link to the paper;
36+
* Link to the implementation if it's open source;
37+
38+
If you are willing to contribute the model yourself, let us know so we can best
39+
guide you.
40+
41+
### Do you want a new feature (that is not a model)?
42+
43+
A world-class feature request addresses the following points:
44+
45+
1. Motivation first:
46+
* Is it related to a problem/frustration with the library? If so, please explain
47+
why. Providing a code snippet that demonstrates the problem is best.
48+
* Is it related to something you would need for a project? We'd love to hear
49+
about it!
50+
* Is it something you worked on and think could benefit the community?
51+
Awesome! Tell us what problem it solved for you.
52+
2. Provide a **code snippet** that demonstrates its future use;
53+
3. Attach any additional information (drawings, screenshots, etc.) you think may help.
54+
55+
56+
## Pull Requests
57+
58+
Before writing code, we strongly advise you to search through the exising PRs or
59+
issues to make sure that nobody is already working on the same thing. If you are
60+
unsure, it is always a good idea to open an issue to get some feedback.
61+
62+
Follow these steps to start contributing:
63+
64+
1. Fork the [repository](https://github.com/lightly-ai/lightly/) by
65+
clicking on the 'Fork' button on the repository's page. This creates a copy of the code
66+
under your GitHub user account.
67+
68+
2. Clone your fork to your local disk, and add the base repository as a remote:
69+
70+
```bash
71+
$ git clone [email protected]:lightly-ai/lightly.git
72+
$ cd lightly
73+
$ git remote add upstream https://github.com/lightly-ai/lightly.git
74+
```
75+
76+
3. Create a new branch to hold your development changes:
77+
78+
```bash
79+
$ git checkout -b a_descriptive_name_for_my_changes
80+
```
81+
82+
**do not** work on the `master` branch.
83+
84+
4. Set up a development environment by running the following command in a virtual environment:
85+
86+
```bash
87+
$ pip install -e ".[dev]"
88+
```
89+
90+
5. Develop the features on your branch.
91+
92+
As you work on the features, you should make sure that the test suite
93+
passes:
94+
95+
```bash
96+
$ make test
97+
```
98+
99+
If you're modifying documents under `docs/source`, make sure to validate that
100+
they can still be built. This check also runs in CI.
101+
102+
```bash
103+
$ cd docs
104+
$ make html
105+
```
106+
Once you're happy with your changes, add changed files using `git add` and
107+
make a commit with `git commit` to record your changes locally:
108+
109+
```bash
110+
$ git add modified_file.py
111+
$ git commit
112+
```
113+
114+
Please write [good commit messages](https://chris.beams.io/posts/git-commit/).
115+
116+
It is a good idea to sync your copy of the code with the original
117+
repository regularly. This way you can quickly account for changes:
118+
119+
```bash
120+
$ git fetch upstream
121+
$ git rebase upstream/master
122+
```
123+
124+
Push the changes to your account using:
125+
126+
```bash
127+
$ git push -u origin a_descriptive_name_for_my_changes
128+
```
129+
130+
6. Once you are satisfied, go to the webpage of your fork on GitHub.
131+
Click on 'Pull request' to send your changes to the project maintainers for review.
132+
133+
7. It's ok if maintainers ask you for changes. It happens to core contributors
134+
too! So everyone can see the changes in the Pull request, work in your local
135+
branch and push the changes to your fork. They will automatically appear in
136+
the pull request.
137+
138+
### Style guide
139+
140+
`lightly` follows the [Google styleguide](https://google.github.io/styleguide/pyguide.html) and the [PyTorch styleguide](https://github.com/IgorSusmelj/pytorch-styleguide) by Igor Susmelj.
141+
Check our [documentation writing guide](https://github.com/lightly-ai/lightly/docs/README.md) for more information.
142+
143+
#### This guide was inspired by Transformers [transformers guide to contributing](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) which was influenced by Scikit-learn [scikit-learn guide to contributing](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md).

DOCS.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Lightly
2+
3+
Lightly is a PIP package for self-supervised active learning.
4+
5+
> We, at [Lightly](https://www.lightly.ai), are passionate engineers who want to make deep learning more efficient. We want to help popularize the use of self-supervised methods to understand and filter raw image data. Our solution can be applied before any data annotation step and the learned representations can be used to analyze and visualize datasets as well as for selecting a core set of samples.
6+
7+
> Coming soon: Our active-learning library is powered by state-of-the-art algorithms to help you with interactive learning loops.
8+
9+
If you are curious to learn more about our work - check out [Lightly](https://www.lightly.ai)!
10+
11+
## Installation
12+
13+
```
14+
pip install lightly
15+
```
16+
17+
## Dependencies
18+
- hydra-core >= 1.0.0
19+
- numpy >= 1.18.1
20+
- pytorch_lightning
21+
- requests >= 2.23.0
22+
- torchvision
23+
- tqdm
24+
25+
26+
## Links
27+
- [Homepage](https://www.lightly.ai)
28+
- [Web-App](https://app.lightly.ai)
29+
- [Documentation](https://www.notion.so/whattolabel/WhatToLabel-Documentation-28e645f5564a453e807d0a384a4e6ea7)
30+
- [Github](https://github.com/lightly-ai/lightly)
31+
- [Discord](https://discord.gg/xvNJW94)

LICENSE.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 The Python Packaging Authority
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# include config files for command-line interface
2+
recursive-include lightly/cli *.yaml
3+
# exclude tests
4+
recursive-exclude tests *

Makefile

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright (c) 2020. Lightly AG and its affiliates.
2+
# All Rights Reserved
3+
4+
.PHONY: clean clean-build clean-pyc clean-out docs help
5+
.DEFAULT_GOAL := help
6+
7+
# TODO
8+
help:
9+
10+
## make clean
11+
clean: clean-tox clean-build clean-pyc clean-out
12+
13+
## remove build artifacts
14+
clean-build:
15+
rm -fr build/
16+
rm -fr dist/
17+
rm -fr .eggs/
18+
find . -name '*.egg-info' -exec rm -fr {} +
19+
find . -name '*.egg' -exec rm -f {} +
20+
21+
## remove python file artifacts
22+
clean-pyc:
23+
find . -name '__pycache__' -exec rm -fr {} +
24+
25+
## remove hydra outputs
26+
clean-out:
27+
rm -fr outputs/
28+
rm -fr lightning_logs/
29+
rm -fr lightly_epoch_*.ckpt
30+
31+
## remove tox cache
32+
clean-tox:
33+
rm -fr .tox
34+
35+
# check style with flake8
36+
lint: lint-lightly lint-tests
37+
38+
## check lightly style with flake8
39+
lint-lightly:
40+
flake8 lightly
41+
42+
## check tests style with flake8
43+
lint-tests:
44+
flake8 tests
45+
46+
## run tests
47+
test:
48+
pytest tests -n 20
49+
50+
## build source and wheel package
51+
dist: clean
52+
python setup.py sdist bdist_wheel
53+
ls -l dist
54+
55+
## install the package to active site
56+
install: clean
57+
pip install .
58+
59+
# uninstall package from active site
60+
uninstall: clean
61+
pip uninstall lightly
62+
63+
## run tests in tox envs
64+
tox: uninstall
65+
tox
66+
67+
## helper for renaming
68+
find:
69+
@read -p "Enter Term: " term; \
70+
grep -rnw ./ -e "$$term"

PRECOMMITHOOKS.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Pre-Commit Hooks
2+
We use pre-commit hooks to identify simple issues before submission to code review. In particular, our hooks currently check for:
3+
* Private keys in the commit
4+
* Large files in the commit (>500kB)
5+
* Units which don't pass their unit tests (on push only)
6+
7+
## Install Pre-Commit
8+
9+
`pre-commit` comes as a pip package and is specified in `requirements/dev.txt`.
10+
11+
To install it either run:
12+
```
13+
$ pip install .[dev]
14+
```
15+
Or, to install it separately:
16+
```
17+
$ pip install pre-commit
18+
```
19+
20+
Test your installation:
21+
```
22+
$ pre-commit --version
23+
```
24+
If the installation failed, try
25+
```
26+
$ curl https://pre-commit.com/install-local.py | python -
27+
```
28+
or see the [documentation of pre-commit](https://pre-commit.com/) for more information.
29+
30+
## Install Pre-Commit Hooks
31+
To install the pre-commit hooks specified in `.pre-commit-hooks.yaml`, simply run
32+
```
33+
$ pre-commit install
34+
```
35+
Install the pre-push hooks like this
36+
```
37+
$ pre-commit install --hook-type pre-push
38+
```
39+
40+
You can verify that the hooks were installed correctly with
41+
```
42+
$ pre-commit run --all-files
43+
```
44+
The output should look like this:
45+
```
46+
$ pre-commit run --all-files
47+
Detect Private Key................................Passed
48+
Check for added large files.......................Passed
49+
```
50+
51+
## Usage
52+
With the new setup, checks for private keys and large files are made before every commit and all tests must pass for a push.

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
![Lightly Logo](docs/logos/lightly_logo_crop.png)
3+
4+
Lightly is a computer vision framework for self-supervised learning.
5+
6+
> We, at [Lightly](https://www.lightly.ai), are passionate engineers who want to make deep learning more efficient. We want to help popularize the use of self-supervised methods to understand and filter raw image data. Our solution can be applied before any data annotation step and the learned representations can be used to analyze and visualize datasets as well as for selecting a core set of samples.
7+
8+
- [Homepage](https://www.lightly.ai)
9+
- [Web-App](https://app.lightly.ai)
10+
- [Documentation](https://www.notion.so/whattolabel/WhatToLabel-Documentation-28e645f5564a453e807d0a384a4e6ea7)
11+
- [Github](https://github.com/lightly-ai/lightly)
12+
- [Discord](https://discord.gg/xvNJW94)
13+
14+
## Terminology
15+
- **Dataset:** A collection of raw images.
16+
- **Embedding:** Representation of an image in a vector space.
17+
- **Embedding Model:** Function (typically a convolutional neural network) to create embeddings from images.
18+
- **Self-supervised Learning:** A form of unsupervised learning where the data provides the supervision.
19+
20+
## Quick Start
21+
22+
Lightly requires Python 3.5+. We recommend installing Lightly in a Linux or OSX environment.
23+
24+
### Installation
25+
You can install Lightly and its dependencies from PyPI with:
26+
```
27+
pip install lightly
28+
```
29+
30+
We strongly recommend that you install Lightly in a dedicated virtualenv, to avoid conflicting with your system packages.
31+
32+
### Next Steps
33+
Head to the [documentation](https://www.notion.so/whattolabel/WhatToLabel-Documentation-28e645f5564a453e807d0a384a4e6ea7) and see the things you can achieve with Lightly!
34+
35+
36+
## Further Reading
37+
38+
**Self-supervised Learning:**
39+
- [A Simple Framework for Contrastive Learning of Visual Representations (2020)](https://arxiv.org/abs/2002.05709)
40+
- [Momentum Contrast for Unsupervised Visual Representation Learning (2020)](https://arxiv.org/abs/1911.05722)
41+
- [Unsupervised Learning of Visual Features by Contrasting Cluster Assignments (2020)](https://arxiv.org/abs/2006.09882)
42+
- [What Should Not Be Contrastive in Contrastive Learning (2020)](https://arxiv.org/abs/2008.05659)
43+
44+
## FAQ
45+
46+
- Why should I care about self-supervised learning? Aren't pre-trained models from ImageNet much better for transfer learning?
47+
- Self-supervised learning has become increasingly popular among scientists over the last year because the learned representations perform extraordinarily well on downstream tasks. This means that they capture the important information in an image better than other types of pre-trained models. By training a self-supervised model on *your* dataset, you can make sure that the representations have all the necessary information about your images.
48+
49+
- How can I contribute?
50+
- Create an issue if you encounter bugs or have ideas for features we should implement. You can also add your own code by forking this repository and creating a PR. More details about how to contribute with code is in our contribution guide.
51+
52+
- Is this framework for free?
53+
- Yes, this framework completely free to use and we provide the code. We believe that
54+
we need to make training deep learning models more data efficient to achieve widespread adoption. One step to achieve this goal is by leveraging self-supervised learning. The company behind lightly commited to keep this framework open-source.
55+
56+
- If this framework is free, how is the company behind lightly making money?
57+
- Training self-supervised models is only part of the solution. The company behind lightly focuses on processing and analyzing embeddings created by self-supervised models.
58+
By building, what we call a self-supervised active learning loop we help companies understand and work with their data more efficiently. This framework acts as an interface
59+
for our platform to easily upload and download datasets, embeddings and models. Whereas
60+
the platform will cost for additional features this frameworks will always remain free of charge (even for commercial use).

0 commit comments

Comments
 (0)