Skip to content

Commit e74696c

Browse files
author
Mike Lambeta
committed
Initial commit
0 parents  commit e74696c

Some content is hidden

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

86 files changed

+14196
-0
lines changed

.circleci/config.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2.1
2+
3+
jobs:
4+
py37_linux:
5+
docker:
6+
- image: circleci/python:3.7
7+
steps:
8+
- checkout
9+
- run:
10+
name: "Preparing environment"
11+
command: |
12+
sudo pip install nox
13+
- run:
14+
name: "Testing PyTouch"
15+
command: |
16+
pip install nox
17+
nox
18+
19+
workflows:
20+
version: 2
21+
build:
22+
jobs:
23+
- py37_linux

.flake8

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
exclude =
3+
.git
4+
,.nox
5+
,__init__.py
6+
max-line-length = 119
7+
copyright-check = True
8+
select = E,F,W,C
9+
copyright-regexp=Copyright \(c\) Facebook, Inc. and its affiliates. All Rights Reserved
10+
ignore=W503,E203

.gitignore

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
#hydra outputs
10+
outputs/
11+
multirun/
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
pip-wheel-metadata/
28+
share/python-wheels/
29+
*.egg-info/
30+
.installed.cfg
31+
*.egg
32+
MANIFEST
33+
34+
# PyInstaller
35+
# Usually these files are written by a python script from a template
36+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
37+
*.manifest
38+
*.spec
39+
40+
# Installer logs
41+
pip-log.txt
42+
pip-delete-this-directory.txt
43+
44+
# Unit test / coverage reports
45+
htmlcov/
46+
.tox/
47+
.nox/
48+
.coverage
49+
.coverage.*
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
*.cover
54+
*.py,cover
55+
.hypothesis/
56+
.pytest_cache/
57+
cover/
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Django stuff:
64+
*.log
65+
local_settings.py
66+
db.sqlite3
67+
db.sqlite3-journal
68+
69+
# Flask stuff:
70+
instance/
71+
.webassets-cache
72+
73+
# Scrapy stuff:
74+
.scrapy
75+
76+
# Sphinx documentation
77+
docs/_build/
78+
79+
# PyBuilder
80+
.pybuilder/
81+
target/
82+
83+
# Jupyter Notebook
84+
.ipynb_checkpoints
85+
86+
# IPython
87+
profile_default/
88+
ipython_config.py
89+
90+
# pyenv
91+
# For a library or package, you might want to ignore these files since the code is
92+
# intended to run in multiple environments; otherwise, check them in:
93+
# .python-version
94+
95+
# pipenv
96+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
98+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
99+
# install all needed dependencies.
100+
#Pipfile.lock
101+
102+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103+
__pypackages__/
104+
105+
# Celery stuff
106+
celerybeat-schedule
107+
celerybeat.pid
108+
109+
# SageMath parsed files
110+
*.sage.py
111+
112+
# Environments
113+
.env
114+
.venv
115+
env/
116+
venv/
117+
ENV/
118+
env.bak/
119+
venv.bak/
120+
121+
# Spyder project settings
122+
.spyderproject
123+
.spyproject
124+
125+
# Rope project settings
126+
.ropeproject
127+
128+
# mkdocs documentation
129+
/site
130+
131+
# mypy
132+
.mypy_cache/
133+
.dmypy.json
134+
dmypy.json
135+
136+
# Pyre type checker
137+
.pyre/
138+
139+
# pytype static type analyzer
140+
.pytype/
141+
142+
# Cython debug symbols
143+
cython_debug/
144+
145+
# static files generated from Django application using `collectstatic`
146+
media
147+
static
148+
149+
# Pycharm
150+
.idea/

.isort.cfg

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[settings]
2+
multi_line_output=3
3+
include_trailing_comma=True
4+
force_grid_wrap=0
5+
use_parentheses=True
6+
line_length=88
7+
ensure_newline_before_comments=True
8+
known_third_party=hydra,torch,torchvision,pytorch_lightning,boto3
9+
known_first_party=pytouch

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: master
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/psf/black
9+
rev: stable
10+
hooks:
11+
- id: black
12+
language_version: python3

CODE_OF_CONDUCT.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Open Source Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
Using welcoming and inclusive language
12+
Being respectful of differing viewpoints and experiences
13+
Gracefully accepting constructive criticism
14+
Focusing on what is best for the community
15+
Showing empathy towards other community members
16+
Examples of unacceptable behavior by participants include:
17+
18+
The use of sexualized language or imagery and unwelcome sexual attention or advances
19+
Trolling, insulting/derogatory comments, and personal or political attacks
20+
Public or private harassment
21+
Publishing others’ private information, such as a physical or electronic address, without explicit permission
22+
Other conduct which could reasonably be considered inappropriate in a professional setting
23+
24+
## Our Responsibilities
25+
26+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
27+
28+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
29+
30+
## Scope
31+
32+
This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
33+
34+
## Enforcement
35+
36+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
37+
38+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership.
39+
40+
## Attribution
41+
42+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
43+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
44+
45+
[homepage]: https://www.contributor-covenant.org

CONTRIBUTING.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Contributing
2+
We want to make contributing to this project as easy and transparent as possible.
3+
4+
## Pull Requests
5+
We actively welcome your pull requests.
6+
7+
1. Fork the repo and create your branch from `master`.
8+
2. If you have added code that should be tested, add tests.
9+
3. If you have changed APIs, update the documentation.
10+
4. Ensure the test suite passes.
11+
5. Make sure your code lints.
12+
6. If you have not already, complete the Contributor License Agreement ("CLA").
13+
14+
## Contributor License Agreement ("CLA")
15+
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects.
16+
17+
Complete your CLA here: <https://code.facebook.com/cla>
18+
19+
## Issues
20+
We use GitHub issues for general feature discussion, Q&A and tracking public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue or understand the problem.
21+
22+
## License
23+
By contributing to this project, you agree that your contributions will be licensed under the [LICENSE file](LICENSE) in the root directory of this source tree.

LICENSE

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

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h1 align="center">PyTouch</h1>
2+
3+
<p align="center">
4+
<a href="#">
5+
<img src="https://circleci.com/gh/facebookresearch/PyTouch.svg?style=shield&circle-token=1633dac9daf88db4d3dbf10e1312663538f10bb4" alt="CircleCI" />
6+
</a>
7+
<a href="#">
8+
<img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT" />
9+
</a>
10+
<a href="#">
11+
<img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style: Black" />
12+
</a>
13+
</p>
14+
15+
<p align="center">
16+
<i>PyTouch is a machine learning library for tactile touch sensing.</i>
17+
</p>
18+
<p align="center">
19+
<i>Check the <a href="xyz">website</a> for more information.</i>
20+
</p>
21+
22+
### Releases
23+
24+
#### Stable
25+
26+
**PyTouch 0.4.0** is a beta version of PyTouch.
27+
- [Documentation](https://xyz/docs/intro)
28+
- Installation : `pip install pytouch --upgrade`
29+
30+
### License
31+
PyTouch is licensed under [MIT License](LICENSE).
32+
33+
## Community
34+
See the following links to similar projects and to the Touch Sensing Community:
35+
* [Touch Sensing Community](https://www.touch-sensing.org)
36+
* [TACTO](https://github.com/facebookresearch/tacto)
37+
* [DIGIT](https://digit.ml)
38+
39+
40+
### Citing PyTouch
41+
If you use PyTouch in your research please use the following BibTeX entry:
42+
```BibTeX
43+
@Article{Lambeta2021PyTouch,
44+
author = {Lambeta, Mike and Xu, Huazhe and Xu, Jingwei and Chou, Po-Wei and Wang, Shaoxiong and Darrell, Trevor and Calandra, Roberto},
45+
journal = {IEEE International Conference on Robotics and Automation (ICRA)},
46+
title = {{PyTouch}: A Machine Learning Library for Touch Processing},
47+
year = {2021},
48+
}
49+
```

environment.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: pytouch
2+
dependencies:
3+
- python=3.7.*
4+
- pip
5+
- pip:
6+
- ipython
7+
- ipdb
8+
- -r file:requirements.txt

examples/contact_area.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
2+
3+
import pytouch
4+
from pytouch.handlers import ImageHandler
5+
from pytouch.sensors import DigitSensor
6+
from pytouch.tasks import ContactArea
7+
8+
9+
def extract_surface_contact():
10+
base_img_path = "./path/to/img/"
11+
sample_img_path = "./path/to/img"
12+
13+
base_img = ImageHandler(base_img_path).nparray
14+
sample_img = ImageHandler(sample_img_path).nparray
15+
sample_img_2 = sample_img.copy()
16+
17+
# initialize with default configuration of ContactArea task
18+
pt = pytouch.PyTouch(DigitSensor, tasks=[ContactArea])
19+
major, minor = pt.ContactArea(sample_img, base=base_img)
20+
21+
print("Major Axis: {0}, minor axis: {1}".format(*major, *minor))
22+
ImageHandler.save("surface_contact_1.png", sample_img)
23+
24+
# initialize with custom configuration of ContactArea task
25+
contact_area = ContactArea(base=base_img, contour_threshold=10)
26+
major, minor = contact_area(sample_img_2)
27+
28+
print("Major Axis: {0}, minor axis: {1}".format(*major, *minor))
29+
ImageHandler.save("surface_contact_2.png", sample_img_2)
30+
31+
32+
if __name__ == "__main__":
33+
extract_surface_contact()

0 commit comments

Comments
 (0)