Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .circleci/config.yml +145 -0
- .circleci/config.yml.old +72 -0
- .codecov.yml +51 -0
- .deepsource.toml +14 -0
- .gitattributes +10 -0
- .gitconfig +19 -0
- .github/CODEOWNERS +33 -0
- .github/FUNDING.yml +5 -0
- .github/ISSUE_TEMPLATE/bug-report.yml +68 -0
- .github/ISSUE_TEMPLATE/config.yml +14 -0
- .github/ISSUE_TEMPLATE/documentation.md +9 -0
- .github/ISSUE_TEMPLATE/feature-request.md +36 -0
- .github/configurations/changelog-ci-config.json +38 -0
- .github/dependabot.yml +17 -0
- .github/emoji.yml +19 -0
- .github/pull-request-template.md +26 -0
- .github/stale.yml +22 -0
- .github/workflows/add_emoji.yml +14 -0
- .github/workflows/changelog.yml +18 -0
- .github/workflows/docs.yml +28 -0
- .github/workflows/format.yml +68 -0
- .github/workflows/pypi-release.yml +100 -0
- .github/workflows/python_package.yml +27 -0
- .github/workflows/tests_cpu.yml +43 -0
- .github/workflows/tests_cuda.yml +29 -0
- .github/workflows/tests_nightly.yml +34 -0
- .gitignore +21 -0
- .pre-commit-config.yaml +70 -0
- BACKERS.md +5 -0
- CHANGELOG.md +275 -0
- CITATION.md +44 -0
- CODE_OF_CONDUCT.md +76 -0
- CONTRIBUTING.rst +220 -0
- COPYRIGHT +14 -0
- LICENSE +176 -0
- Makefile +63 -0
- README.md +137 -0
- README_zh-CN.md +145 -0
- conftest.py +108 -0
- docker/Dockerfile +18 -0
- docker/Dockerfile.travis +13 -0
- docker/build.sh +13 -0
- docker/tpu-tests/Dockerfile +64 -0
- docker/tpu-tests/docker-entrypoint.sh +8 -0
- docker/tpu-tests/tpu_test_cases.jsonnet +34 -0
- docs/.gitignore +5 -0
- docs/Makefile +27 -0
- docs/generate_example_images.py +348 -0
- docs/requirements.txt +16 -0
- docs/source/_extra/googlef1b16a85a18694bd.html +1 -0
.circleci/config.yml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python CircleCI 2.1 configuration file.
|
| 2 |
+
version: 2.1
|
| 3 |
+
orbs:
|
| 4 |
+
gcp-gke: circleci/gcp-gke@1.0.4
|
| 5 |
+
go: circleci/go@1.3.0
|
| 6 |
+
#codecov: codecov/codecov@1.1.0
|
| 7 |
+
|
| 8 |
+
references:
|
| 9 |
+
|
| 10 |
+
checkout_ml_testing: &checkout_ml_testing
|
| 11 |
+
run:
|
| 12 |
+
name: Checkout ml-testing-accelerators
|
| 13 |
+
command: |
|
| 14 |
+
git clone https://github.com/GoogleCloudPlatform/ml-testing-accelerators.git
|
| 15 |
+
cd ml-testing-accelerators
|
| 16 |
+
git fetch origin 5e88ac24f631c27045e62f0e8d5dfcf34e425e25:stable
|
| 17 |
+
git checkout stable
|
| 18 |
+
cd ..
|
| 19 |
+
build_push_docker: &build_push_docker
|
| 20 |
+
run:
|
| 21 |
+
name: Build and push Docker image
|
| 22 |
+
command: |
|
| 23 |
+
gcloud --quiet auth configure-docker
|
| 24 |
+
cd docker/tpu-tests
|
| 25 |
+
# Update PR refs for testing.
|
| 26 |
+
if [[ -n "${CIRCLE_PR_NUMBER}" ]]
|
| 27 |
+
then
|
| 28 |
+
FETCH_REF="pull/$CIRCLE_PR_NUMBER/head"
|
| 29 |
+
else
|
| 30 |
+
FETCH_REF="refs/heads/master"
|
| 31 |
+
fi
|
| 32 |
+
docker build --tag "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" -f Dockerfile --build-arg "PYTHON_VERSION=$PYTHON_VER" --build-arg "PYTORCH_VERSION=$PYTORCH_VER" --build-arg "GITHUB_REF=$FETCH_REF" .
|
| 33 |
+
docker push "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID"
|
| 34 |
+
|
| 35 |
+
deploy_cluster: &deploy_cluster
|
| 36 |
+
run:
|
| 37 |
+
name: Deploy the job on the kubernetes cluster
|
| 38 |
+
command: |
|
| 39 |
+
go get github.com/google/go-jsonnet/cmd/jsonnet
|
| 40 |
+
export PATH=$PATH:$HOME/go/bin
|
| 41 |
+
python -c "fname = 'docker/tpu-tests/tpu_test_cases.jsonnet' ; fff = open(fname).read().replace('pytorch-VERSION', 'pytorch-$PYTORCH_VER') ; open(fname, 'w').write(fff)"
|
| 42 |
+
job_name=$(jsonnet -J ml-testing-accelerators/ docker/tpu-tests/tpu_test_cases.jsonnet --ext-str image=$GCR_IMAGE_PATH --ext-str image-tag=$CIRCLE_WORKFLOW_JOB_ID | kubectl create -f -)
|
| 43 |
+
job_name=${job_name#job.batch/}
|
| 44 |
+
job_name=${job_name% created}
|
| 45 |
+
echo "Waiting on kubernetes job: $job_name"
|
| 46 |
+
i=0 && \
|
| 47 |
+
# N checks spaced 30s apart = 900s total.
|
| 48 |
+
status_code=2 && \
|
| 49 |
+
# Check on the job periodically. Set the status code depending on what
|
| 50 |
+
# happened to the job in Kubernetes. If we try MAX_CHECKS times and
|
| 51 |
+
# still the job hasn't finished, give up and return the starting
|
| 52 |
+
# non-zero status code.
|
| 53 |
+
printf "Waiting for job to finish: " && \
|
| 54 |
+
while [ $i -lt $MAX_CHECKS ]; do ((i++)); if kubectl get jobs $job_name -o jsonpath='Failed:{.status.failed}' | grep "Failed:1"; then status_code=1 && break; elif kubectl get jobs $job_name -o jsonpath='Succeeded:{.status.succeeded}' | grep "Succeeded:1" ; then status_code=0 && break; else printf "."; fi; sleep $CHECK_SPEEP; done && \
|
| 55 |
+
echo "Done waiting. Job status code: $status_code" && \
|
| 56 |
+
pod_name=$(kubectl get po -l controller-uid=`kubectl get job $job_name -o "jsonpath={.metadata.labels.controller-uid}"` | awk 'match($0,!/NAME/) {print $1}') && \
|
| 57 |
+
echo "GKE pod name: $pod_name" && \
|
| 58 |
+
kubectl logs -f $pod_name --container=train > /tmp/full_output.txt
|
| 59 |
+
if grep -q '<?xml version="1.0" ?>' /tmp/full_output.txt ; then csplit /tmp/full_output.txt '/<?xml version="1.0" ?>/'; else mv /tmp/full_output.txt xx00; fi && \
|
| 60 |
+
# First portion is the test logs. Print these to Github Action stdout.
|
| 61 |
+
cat xx00 && \
|
| 62 |
+
echo "Done with log retrieval attempt." && \
|
| 63 |
+
gcloud container images delete "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" --force-delete-tags && \
|
| 64 |
+
exit $status_code
|
| 65 |
+
|
| 66 |
+
delete_gke_jobs: &delete_gke_jobs
|
| 67 |
+
run:
|
| 68 |
+
name: Delete GKE Jobs
|
| 69 |
+
command: |
|
| 70 |
+
# Match jobs whose age matches patterns like '1h' or '1d', i.e. any job
|
| 71 |
+
# that has been around longer than 1hr. First print all columns for
|
| 72 |
+
# matches, then execute the delete.
|
| 73 |
+
jobs_to_delete=$(kubectl get job | awk 'match($4,/[0-9]+[dh]/) {print $0}')
|
| 74 |
+
echo $jobs_to_delete
|
| 75 |
+
if [ ${#jobs_to_delete} -gt 1 ];
|
| 76 |
+
then kubectl delete job $(kubectl get job | awk 'match($4,/[0-9]+[dh]/) {print $1}');
|
| 77 |
+
fi
|
| 78 |
+
jobs:
|
| 79 |
+
|
| 80 |
+
TPU-tests:
|
| 81 |
+
parameters:
|
| 82 |
+
python:
|
| 83 |
+
type: string
|
| 84 |
+
pytorch:
|
| 85 |
+
type: string
|
| 86 |
+
docker:
|
| 87 |
+
- image: circleci/python:3.7
|
| 88 |
+
environment:
|
| 89 |
+
- PYTHON_VER: << parameters.python >>
|
| 90 |
+
- PYTORCH_VER: << parameters.pytorch >>
|
| 91 |
+
- MAX_CHECKS: 240
|
| 92 |
+
- CHECK_SPEEP: 5
|
| 93 |
+
steps:
|
| 94 |
+
- checkout
|
| 95 |
+
- go/install
|
| 96 |
+
- *checkout_ml_testing
|
| 97 |
+
- gcp-gke/install
|
| 98 |
+
- gcp-gke/update-kubeconfig-with-credentials:
|
| 99 |
+
cluster: $GKE_CLUSTER
|
| 100 |
+
perform-login: true
|
| 101 |
+
- setup_remote_docker
|
| 102 |
+
- *build_push_docker
|
| 103 |
+
- *deploy_cluster
|
| 104 |
+
#- *stats
|
| 105 |
+
#- codecov/upload:
|
| 106 |
+
# file: coverage.xml
|
| 107 |
+
# flags: tpu,pytest
|
| 108 |
+
# upload_name: TPU-coverage
|
| 109 |
+
|
| 110 |
+
#- store_artifacts:
|
| 111 |
+
# path: coverage.xml
|
| 112 |
+
|
| 113 |
+
cleanup-gke-jobs:
|
| 114 |
+
docker:
|
| 115 |
+
- image: circleci/python:3.7
|
| 116 |
+
steps:
|
| 117 |
+
- gcp-gke/install
|
| 118 |
+
- gcp-gke/update-kubeconfig-with-credentials:
|
| 119 |
+
cluster: $GKE_CLUSTER
|
| 120 |
+
perform-login: true
|
| 121 |
+
- *delete_gke_jobs
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
workflows:
|
| 125 |
+
version: 2
|
| 126 |
+
tpu-tests:
|
| 127 |
+
jobs:
|
| 128 |
+
- TPU-tests:
|
| 129 |
+
matrix:
|
| 130 |
+
parameters:
|
| 131 |
+
python: ["3.7"]
|
| 132 |
+
pytorch: ["1.7", "1.8", "nightly"]
|
| 133 |
+
tpu-cleanup:
|
| 134 |
+
triggers:
|
| 135 |
+
- schedule:
|
| 136 |
+
# The cron format is:
|
| 137 |
+
# min (0-59) hour (0-23) monthday (1-31) month (1-12) weekday (0-6, 0=Sun)
|
| 138 |
+
# Set to run at the first minute of every hour.
|
| 139 |
+
cron: "0 * * * *"
|
| 140 |
+
filters:
|
| 141 |
+
branches:
|
| 142 |
+
only:
|
| 143 |
+
- master
|
| 144 |
+
jobs:
|
| 145 |
+
- cleanup-gke-jobs
|
.circleci/config.yml.old
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 2.1
|
| 2 |
+
|
| 3 |
+
commands:
|
| 4 |
+
common:
|
| 5 |
+
steps:
|
| 6 |
+
- checkout
|
| 7 |
+
- run:
|
| 8 |
+
name: install dependencies
|
| 9 |
+
command: ./setup_dev_env.sh
|
| 10 |
+
- run:
|
| 11 |
+
name: activate environment
|
| 12 |
+
command: source path.bash.inc
|
| 13 |
+
- run:
|
| 14 |
+
name: install package
|
| 15 |
+
command: make install
|
| 16 |
+
- run:
|
| 17 |
+
name: lint check
|
| 18 |
+
command: make lint
|
| 19 |
+
- run:
|
| 20 |
+
name: static check
|
| 21 |
+
command: make mypy
|
| 22 |
+
- run:
|
| 23 |
+
name: doctest
|
| 24 |
+
command: make doctest
|
| 25 |
+
- run:
|
| 26 |
+
name: unit tests
|
| 27 |
+
command: make test-cpu
|
| 28 |
+
no_output_timeout: 45m
|
| 29 |
+
- run:
|
| 30 |
+
name: send coverage
|
| 31 |
+
when: on_success
|
| 32 |
+
command: bash <(curl -s https://codecov.io/bash)
|
| 33 |
+
docs:
|
| 34 |
+
steps:
|
| 35 |
+
- run:
|
| 36 |
+
name: docs
|
| 37 |
+
command: make build-docs
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
jobs:
|
| 41 |
+
python_3_6:
|
| 42 |
+
docker:
|
| 43 |
+
- image: circleci/python:3.6.5
|
| 44 |
+
environment:
|
| 45 |
+
- PYTHON_VERSION: "3.6"
|
| 46 |
+
steps:
|
| 47 |
+
- common
|
| 48 |
+
- docs
|
| 49 |
+
|
| 50 |
+
python_3_7:
|
| 51 |
+
docker:
|
| 52 |
+
- image: circleci/python:3.7.3
|
| 53 |
+
environment:
|
| 54 |
+
- PYTHON_VERSION: "3.7"
|
| 55 |
+
steps:
|
| 56 |
+
- common
|
| 57 |
+
|
| 58 |
+
python_3_8:
|
| 59 |
+
docker:
|
| 60 |
+
- image: circleci/python:3.8.0
|
| 61 |
+
environment:
|
| 62 |
+
- PYTHON_VERSION: "3.8"
|
| 63 |
+
steps:
|
| 64 |
+
- common
|
| 65 |
+
|
| 66 |
+
workflows:
|
| 67 |
+
version: 2
|
| 68 |
+
test:
|
| 69 |
+
jobs:
|
| 70 |
+
- python_3_6
|
| 71 |
+
- python_3_7
|
| 72 |
+
- python_3_8
|
.codecov.yml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# see https://docs.codecov.io/docs/codecov-yaml
|
| 2 |
+
# Validation check:
|
| 3 |
+
# $ curl --data-binary @.codecov.yml https://codecov.io/validate
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# https://docs.codecov.io/docs/codecovyml-reference
|
| 7 |
+
codecov:
|
| 8 |
+
bot: "codecov-io"
|
| 9 |
+
strict_yaml_branch: "yaml-config"
|
| 10 |
+
require_ci_to_pass: yes
|
| 11 |
+
notify:
|
| 12 |
+
# after_n_builds: 2
|
| 13 |
+
wait_for_ci: yes
|
| 14 |
+
|
| 15 |
+
coverage:
|
| 16 |
+
precision: 0 # 2 = xx.xx%, 0 = xx%
|
| 17 |
+
round: nearest # how coverage is rounded: down/up/nearest
|
| 18 |
+
range: 70...100 # custom range of coverage colors from red -> yellow -> green
|
| 19 |
+
status:
|
| 20 |
+
# https://codecov.readme.io/v1.0/docs/commit-status
|
| 21 |
+
project:
|
| 22 |
+
default:
|
| 23 |
+
against: auto
|
| 24 |
+
target: 99% # specify the target coverage for each commit status
|
| 25 |
+
threshold: 30% # allow this little decrease on project
|
| 26 |
+
# https://github.com/codecov/support/wiki/Filtering-Branches
|
| 27 |
+
# branches: master
|
| 28 |
+
if_ci_failed: error
|
| 29 |
+
# https://github.com/codecov/support/wiki/Patch-Status
|
| 30 |
+
patch:
|
| 31 |
+
default:
|
| 32 |
+
against: auto
|
| 33 |
+
target: 50% # specify the target "X%" coverage to hit
|
| 34 |
+
# threshold: 50% # allow this much decrease on patch
|
| 35 |
+
changes: false
|
| 36 |
+
|
| 37 |
+
parsers:
|
| 38 |
+
gcov:
|
| 39 |
+
branch_detection:
|
| 40 |
+
conditional: true
|
| 41 |
+
loop: true
|
| 42 |
+
macro: false
|
| 43 |
+
method: false
|
| 44 |
+
javascript:
|
| 45 |
+
enable_partials: false
|
| 46 |
+
|
| 47 |
+
comment:
|
| 48 |
+
layout: header, diff
|
| 49 |
+
require_changes: false
|
| 50 |
+
behavior: default # update if exists else create new
|
| 51 |
+
# branches: *
|
.deepsource.toml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = 1
|
| 2 |
+
|
| 3 |
+
test_patterns = ["test/**"]
|
| 4 |
+
|
| 5 |
+
[[analyzers]]
|
| 6 |
+
name = "python"
|
| 7 |
+
enabled = true
|
| 8 |
+
|
| 9 |
+
[analyzers.meta]
|
| 10 |
+
runtime_version = "3.x.x"
|
| 11 |
+
|
| 12 |
+
[[analyzers]]
|
| 13 |
+
name = "shell"
|
| 14 |
+
enabled = true
|
.gitattributes
CHANGED
|
@@ -35,3 +35,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
b.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
Guernica_reflect_3.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
b.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
Guernica_reflect_3.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
docs/source/_static/img/cn_community_qq.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
docs/source/_static/img/hakuna_matata.gif filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
docs/source/_static/img/registration.gif filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
docs/source/data/epipolar_geometry.svg.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
examples/augmentation/kornia_augmentation.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
examples/depth_regression/Depth_regression.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
examples/feature_detection/img/graffiti.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
examples/feature_detection/img/kpi_winter.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
examples/feature_detection/img/prague.png filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
examples/feature_detection/img/siemens.png filter=lfs diff=lfs merge=lfs -text
|
.gitconfig
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[diff]
|
| 2 |
+
|
| 3 |
+
tool = meld
|
| 4 |
+
|
| 5 |
+
[difftool]
|
| 6 |
+
|
| 7 |
+
prompt = false
|
| 8 |
+
|
| 9 |
+
[difftool "meld"]
|
| 10 |
+
|
| 11 |
+
cmd = meld "$LOCAL" "$REMOTE"
|
| 12 |
+
|
| 13 |
+
[merge]
|
| 14 |
+
|
| 15 |
+
tool = meld
|
| 16 |
+
|
| 17 |
+
[mergetool "meld"]
|
| 18 |
+
|
| 19 |
+
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
|
.github/CODEOWNERS
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This is a comment.
|
| 2 |
+
# Each line is a file pattern followed by one or more owners.
|
| 3 |
+
|
| 4 |
+
# These owners will be the default owners for everything in
|
| 5 |
+
# the repo. Unless a later match takes precedence,
|
| 6 |
+
# @global-owner1 and @global-owner2 will be requested for
|
| 7 |
+
# review when someone opens a pull request.
|
| 8 |
+
* @edgarriba @ducha-aiki @shijianjian @lferraz
|
| 9 |
+
|
| 10 |
+
# CI/CD and configs
|
| 11 |
+
/.github/ @edgarriba @shijianjian
|
| 12 |
+
|
| 13 |
+
# Docs
|
| 14 |
+
/docs/ @edgarriba @shijianjian @ducha-aiki
|
| 15 |
+
/.github/*.md @edgarriba @shijianjian
|
| 16 |
+
/.github/ISSUE_TEMPLATE/ @edgarriba @shijianjian
|
| 17 |
+
/docs/source/conf.py @edgarriba @shijianjian
|
| 18 |
+
|
| 19 |
+
# Packages
|
| 20 |
+
/kornia/augmentation @shijianjian @edgarriba
|
| 21 |
+
/kornia/color @cceyda @edgarriba
|
| 22 |
+
/kornia/contrib @shijianjian @duch-aiki
|
| 23 |
+
/kornia/enhance @lferraz @edgarriba
|
| 24 |
+
/kornia/feature @ducha-aiki @edgarriba
|
| 25 |
+
/kornia/filters @edgarriba @ducha-aiki @lferraz
|
| 26 |
+
/kornia/geometry @edgarriba @ducha-aiki @shijianjian @dkoguciuk @justanhduc
|
| 27 |
+
/kornia/losses @edgarriba @ducha-aiki
|
| 28 |
+
/kornia/morphology @Manza12 @ducha-aiki
|
| 29 |
+
/kornia/utils @edgarriba @shijianjian @ducha-aiki
|
| 30 |
+
|
| 31 |
+
/.github/CODEOWNERS @edgarriba
|
| 32 |
+
/README.rst @edgarriba
|
| 33 |
+
/setup.py @edgarriba @shijianjian
|
.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [edgarriba, shijianjian]
|
| 4 |
+
open_collective: kornia
|
| 5 |
+
custom: # Replace with a single custom sponsorship URL
|
.github/ISSUE_TEMPLATE/bug-report.yml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: 🐛 Bug report
|
| 2 |
+
description: Create a report to help us improve
|
| 3 |
+
labels: bug, help wanted
|
| 4 |
+
|
| 5 |
+
body:
|
| 6 |
+
- type: markdown
|
| 7 |
+
attributes:
|
| 8 |
+
value: |
|
| 9 |
+
Thanks for taking the time to fill out this bug report!
|
| 10 |
+
|
| 11 |
+
- type: textarea
|
| 12 |
+
id: describe-bug
|
| 13 |
+
attributes:
|
| 14 |
+
label: Describe the bug
|
| 15 |
+
description: A clear and concise description of what the bug is.
|
| 16 |
+
validations:
|
| 17 |
+
required: true
|
| 18 |
+
|
| 19 |
+
- type: textarea
|
| 20 |
+
id: reproduction-steps
|
| 21 |
+
attributes:
|
| 22 |
+
label: Reproduction steps
|
| 23 |
+
description: Steps to reproduce the behavior
|
| 24 |
+
value: |
|
| 25 |
+
1.
|
| 26 |
+
2.
|
| 27 |
+
3.
|
| 28 |
+
...
|
| 29 |
+
render: bash
|
| 30 |
+
validations:
|
| 31 |
+
required: true
|
| 32 |
+
|
| 33 |
+
- type: textarea
|
| 34 |
+
id: expected-behavior
|
| 35 |
+
attributes:
|
| 36 |
+
label: Expected behavior
|
| 37 |
+
description: A clear and concise description of what you expected to happen.
|
| 38 |
+
validations:
|
| 39 |
+
required: true
|
| 40 |
+
|
| 41 |
+
- type: textarea
|
| 42 |
+
id: environment
|
| 43 |
+
attributes:
|
| 44 |
+
label: Environment
|
| 45 |
+
description: Please copy and paste the output from our collection script
|
| 46 |
+
value: |
|
| 47 |
+
```
|
| 48 |
+
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
|
| 49 |
+
# For security purposes, please check the contents of collect_env.py before running it.
|
| 50 |
+
python collect_env.py
|
| 51 |
+
```
|
| 52 |
+
- PyTorch Version (e.g., 1.0):
|
| 53 |
+
- OS (e.g., Linux):
|
| 54 |
+
- How you installed PyTorch (`conda`, `pip`, source):
|
| 55 |
+
- Build command you used (if compiling from source):
|
| 56 |
+
- Python version:
|
| 57 |
+
- CUDA/cuDNN version:
|
| 58 |
+
- GPU models and configuration:
|
| 59 |
+
- Any other relevant information:
|
| 60 |
+
render: shell
|
| 61 |
+
validations:
|
| 62 |
+
required: true
|
| 63 |
+
|
| 64 |
+
- type: textarea
|
| 65 |
+
id: additional-context
|
| 66 |
+
attributes:
|
| 67 |
+
label: Additional context
|
| 68 |
+
description: Add any other context about the problem here.
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
| 2 |
+
contact_links:
|
| 3 |
+
- name: ❓ Ask a question
|
| 4 |
+
url: https://github.com/kornia/kornia/discussions
|
| 5 |
+
about: Please post questions related to the library in discussions.
|
| 6 |
+
- name: 💬 Slack
|
| 7 |
+
url: https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ
|
| 8 |
+
about: Chat with our community
|
| 9 |
+
- name: LibreCV
|
| 10 |
+
url: https://librecv.org/
|
| 11 |
+
about: Interact with the Computer Vision community
|
| 12 |
+
- name: Twitter
|
| 13 |
+
url: https://twitter.com/kornia_foss
|
| 14 |
+
about: Interact with the rest of the world
|
.github/ISSUE_TEMPLATE/documentation.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: "\U0001F4DA Documentation"
|
| 3 |
+
about: Report an issue related to https://kornia.readthedocs.io
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 📚 Documentation
|
| 8 |
+
|
| 9 |
+
<!-- A clear and concise description of what content in https://kornia.readthedocs.io is an issue. If this has to do with the general https://kornia.org website, please file an issue at https://github.com/kornia/kornia.github.io/issues/new/choose instead. If this has to do with https://kornia.org/tutorials, please file an issue at https://github.com/kornia/tutorials/issues/new -->
|
.github/ISSUE_TEMPLATE/feature-request.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: "\U0001F680Feature Request"
|
| 3 |
+
about: Suggest an idea for this project
|
| 4 |
+
title: ''
|
| 5 |
+
labels: enhancement, help wanted
|
| 6 |
+
assignees: ''
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 🚀 Feature
|
| 10 |
+
<!-- A clear and concise description of the feature proposal -->
|
| 11 |
+
|
| 12 |
+
## Motivation
|
| 13 |
+
|
| 14 |
+
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->
|
| 15 |
+
|
| 16 |
+
## Pitch
|
| 17 |
+
|
| 18 |
+
<!-- A clear and concise description of what you want to happen. -->
|
| 19 |
+
|
| 20 |
+
## Alternatives
|
| 21 |
+
|
| 22 |
+
<!-- A clear and concise description of any alternative solutions or features you've considered, if any. -->
|
| 23 |
+
|
| 24 |
+
## Additional context
|
| 25 |
+
|
| 26 |
+
<!-- Add any other context or screenshots about the feature request here. -->
|
| 27 |
+
|
| 28 |
+
______________________________________________________________________
|
| 29 |
+
|
| 30 |
+
#### Consider also to contribute to Kornia universe projects :)
|
| 31 |
+
|
| 32 |
+
<sub>
|
| 33 |
+
|
| 34 |
+
- [**Tutorials**](https://github.com/kornia/tutorials): our repository containing the tutorials.
|
| 35 |
+
|
| 36 |
+
</sub>
|
.github/configurations/changelog-ci-config.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"comment_changelog": true,
|
| 3 |
+
"commit_changelog": false,
|
| 4 |
+
"group_config": [
|
| 5 |
+
{
|
| 6 |
+
"labels": [
|
| 7 |
+
"bug",
|
| 8 |
+
"bugfix"
|
| 9 |
+
],
|
| 10 |
+
"title": "Bug Fixes"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"labels": [
|
| 14 |
+
"improvements",
|
| 15 |
+
"enhancement"
|
| 16 |
+
],
|
| 17 |
+
"title": "Code Improvements"
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"labels": [
|
| 21 |
+
"feature",
|
| 22 |
+
"feature request"
|
| 23 |
+
],
|
| 24 |
+
"title": "New Features"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"labels": [
|
| 28 |
+
"docs",
|
| 29 |
+
"documentation",
|
| 30 |
+
"doc"
|
| 31 |
+
],
|
| 32 |
+
"title": "Documentation Updates"
|
| 33 |
+
}
|
| 34 |
+
],
|
| 35 |
+
"header_prefix": "Version:",
|
| 36 |
+
"pull_request_title_regex": "^(?i:release)",
|
| 37 |
+
"version_regex": "v?([0-9]{1,2})[.]([0-9]{1,2})[.]([0-9]{1,2})\\s\\(\\d{1,2}-\\d{1,2}-\\d{4}\\)"
|
| 38 |
+
}
|
.github/dependabot.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# To get started with Dependabot version updates, you'll need to specify which
|
| 2 |
+
# package ecosystems to update and where the package manifests are located.
|
| 3 |
+
# Please see the documentation for all configuration options:
|
| 4 |
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
| 5 |
+
|
| 6 |
+
version: 2
|
| 7 |
+
updates:
|
| 8 |
+
- package-ecosystem: "pip"
|
| 9 |
+
directory: "/"
|
| 10 |
+
open-pull-requests-limit: 10
|
| 11 |
+
schedule:
|
| 12 |
+
interval: weekly
|
| 13 |
+
day: sunday
|
| 14 |
+
reviewers:
|
| 15 |
+
- "edgarriba"
|
| 16 |
+
- "ducha-aiki"
|
| 17 |
+
- "shijianjian"
|
.github/emoji.yml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Configuration for action-emoji - https://github.com/tiena2cva/action-emoji
|
| 2 |
+
|
| 3 |
+
# Include all emoji supported or not
|
| 4 |
+
all: false
|
| 5 |
+
|
| 6 |
+
# Choose what list of emoji you want to use. Support 4 list: people, nature, objects, places.
|
| 7 |
+
# If "all" is true, all of list will be included
|
| 8 |
+
lists:
|
| 9 |
+
- people
|
| 10 |
+
- nature
|
| 11 |
+
- objects
|
| 12 |
+
- places
|
| 13 |
+
|
| 14 |
+
# User custom emoji list
|
| 15 |
+
customs:
|
| 16 |
+
- atom
|
| 17 |
+
- suspect
|
| 18 |
+
- electron
|
| 19 |
+
- england
|
.github/pull-request-template.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Changes
|
| 2 |
+
<!-- Please include a summary of the change and which issue is fixed. -->
|
| 3 |
+
<!-- Please also include relevant motivation and context. -->
|
| 4 |
+
<!-- List any dependencies that are required for this change. -->
|
| 5 |
+
|
| 6 |
+
Fixes # (issue)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
#### Type of change
|
| 10 |
+
<!-- Please delete options that are not relevant. -->
|
| 11 |
+
- [ ] 📚 Documentation Update
|
| 12 |
+
- [ ] 🧪 Tests Cases
|
| 13 |
+
- [ ] 🐞 Bug fix (non-breaking change which fixes an issue)
|
| 14 |
+
- [ ] 🔬 New feature (non-breaking change which adds functionality)
|
| 15 |
+
- [ ] 🚨 Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
| 16 |
+
- [ ] 📝 This change requires a documentation update
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
#### Checklist
|
| 20 |
+
|
| 21 |
+
- [ ] My code follows the style guidelines of this project
|
| 22 |
+
- [ ] I have performed a self-review of my own code
|
| 23 |
+
- [ ] I have commented my code, particularly in hard-to-understand areas
|
| 24 |
+
- [ ] I have made corresponding changes to the documentation
|
| 25 |
+
- [ ] My changes generate no new warnings
|
| 26 |
+
- [ ] Did you update CHANGELOG in case of a major change?
|
.github/stale.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Number of days of inactivity before an issue becomes stale
|
| 2 |
+
daysUntilStale: 60
|
| 3 |
+
# Number of days of inactivity before a stale issue is closed
|
| 4 |
+
daysUntilClose: 7
|
| 5 |
+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
| 6 |
+
onlyLabels:
|
| 7 |
+
- "bug"
|
| 8 |
+
# Issues with these labels will never be considered stale
|
| 9 |
+
exemptLabels:
|
| 10 |
+
- help wanted
|
| 11 |
+
- pinned
|
| 12 |
+
- security
|
| 13 |
+
- priority
|
| 14 |
+
# Label to use when marking an issue as stale
|
| 15 |
+
staleLabel: wontfix
|
| 16 |
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
| 17 |
+
markComment: >
|
| 18 |
+
This issue has been automatically marked as stale because it has not had
|
| 19 |
+
recent activity. It will be closed if no further activity occurs. Thank you
|
| 20 |
+
for your contributions, and happy coding day :sunglasses:
|
| 21 |
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
| 22 |
+
closeComment: false
|
.github/workflows/add_emoji.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Add Emoji
|
| 2 |
+
on: pull_request
|
| 3 |
+
|
| 4 |
+
jobs:
|
| 5 |
+
add-emoji:
|
| 6 |
+
runs-on: ubuntu-latest
|
| 7 |
+
steps:
|
| 8 |
+
- name: Checkout 🛎️
|
| 9 |
+
uses: actions/checkout@v2
|
| 10 |
+
|
| 11 |
+
- name: Add emoji 🥰
|
| 12 |
+
uses: tiena2cva/action-emoji@v1
|
| 13 |
+
with:
|
| 14 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/changelog.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Changelog CI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
types: [opened, reopened]
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
build:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
steps:
|
| 11 |
+
- uses: actions/checkout@v2.3.3
|
| 12 |
+
- name: Run Changelog CI
|
| 13 |
+
uses: saadmk11/changelog-ci@v0.7.0
|
| 14 |
+
with:
|
| 15 |
+
changelog_filename: CHANGELOG.md
|
| 16 |
+
config_file: .github/configurations/changelog-ci-config.json
|
| 17 |
+
env:
|
| 18 |
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
.github/workflows/docs.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: test-docs
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- master
|
| 7 |
+
pull_request:
|
| 8 |
+
schedule:
|
| 9 |
+
- cron: "0 4 * * *"
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
build-docs:
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
steps:
|
| 15 |
+
- uses: actions/checkout@v2
|
| 16 |
+
- name: Setup conda dependencies
|
| 17 |
+
uses: conda-incubator/setup-miniconda@v2
|
| 18 |
+
with:
|
| 19 |
+
auto-update-conda: true
|
| 20 |
+
python-version: 3.6
|
| 21 |
+
- name: Install dependencies
|
| 22 |
+
shell: bash -l {0}
|
| 23 |
+
run: |
|
| 24 |
+
pip install -r docs/requirements.txt
|
| 25 |
+
pip install .[all]
|
| 26 |
+
- name: Build Documentation
|
| 27 |
+
shell: bash -l {0}
|
| 28 |
+
run: make build-docs
|
.github/workflows/format.yml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: code-format
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- master
|
| 7 |
+
pull_request:
|
| 8 |
+
schedule:
|
| 9 |
+
- cron: "0 4 * * *"
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
linter:
|
| 13 |
+
runs-on: [ubuntu-latest]
|
| 14 |
+
steps:
|
| 15 |
+
- uses: actions/checkout@v2
|
| 16 |
+
- name: Install dependencies
|
| 17 |
+
run: |
|
| 18 |
+
pip install torch --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
|
| 19 |
+
pip install -r requirements/dev.txt
|
| 20 |
+
python setup.py develop --user
|
| 21 |
+
|
| 22 |
+
- name: Run linter
|
| 23 |
+
run: make lint
|
| 24 |
+
|
| 25 |
+
static-check:
|
| 26 |
+
runs-on: [ubuntu-latest]
|
| 27 |
+
steps:
|
| 28 |
+
- uses: actions/checkout@v2
|
| 29 |
+
- name: Install dependencies
|
| 30 |
+
run: |
|
| 31 |
+
pip install torch --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
|
| 32 |
+
pip install -r requirements/dev.txt
|
| 33 |
+
python setup.py develop --user
|
| 34 |
+
|
| 35 |
+
- name: Run mypy
|
| 36 |
+
run: make mypy
|
| 37 |
+
|
| 38 |
+
doctest:
|
| 39 |
+
runs-on: [ubuntu-latest]
|
| 40 |
+
steps:
|
| 41 |
+
- uses: actions/checkout@v2
|
| 42 |
+
- name: Install dependencies
|
| 43 |
+
run: |
|
| 44 |
+
pip install torch --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
|
| 45 |
+
pip install -r requirements/dev.txt
|
| 46 |
+
python setup.py develop --user
|
| 47 |
+
|
| 48 |
+
- name: Run doctest
|
| 49 |
+
run: make doctest
|
| 50 |
+
|
| 51 |
+
pre-commit-check:
|
| 52 |
+
runs-on: ubuntu-latest
|
| 53 |
+
steps:
|
| 54 |
+
- uses: actions/checkout@v2
|
| 55 |
+
- uses: actions/setup-python@v2
|
| 56 |
+
|
| 57 |
+
- name: set PY
|
| 58 |
+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
| 59 |
+
- uses: actions/cache@v2
|
| 60 |
+
with:
|
| 61 |
+
path: ~/.cache/pre-commit
|
| 62 |
+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
| 63 |
+
|
| 64 |
+
- uses: pre-commit/action@v2.0.2
|
| 65 |
+
# this action also provides an additional behaviour when used in private repositories
|
| 66 |
+
# when configured with a github token, the action will push back fixes to the pull request branch
|
| 67 |
+
# with:
|
| 68 |
+
# token: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/pypi-release.yml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: PyPI Release
|
| 2 |
+
|
| 3 |
+
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
| 4 |
+
on: # Trigger the workflow on push or pull request, but only for the master branch
|
| 5 |
+
push:
|
| 6 |
+
branches: [master]
|
| 7 |
+
release:
|
| 8 |
+
types: [published]
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
build-sdist:
|
| 12 |
+
runs-on: ubuntu-20.04
|
| 13 |
+
steps:
|
| 14 |
+
- uses: actions/checkout@master
|
| 15 |
+
- uses: actions/setup-python@v2
|
| 16 |
+
with:
|
| 17 |
+
python-version: 3.7
|
| 18 |
+
|
| 19 |
+
- name: Install dependencies
|
| 20 |
+
run: python -m pip install --user --upgrade setuptools wheel
|
| 21 |
+
- name: Build source
|
| 22 |
+
env:
|
| 23 |
+
KORNIA_RELEASE: 1
|
| 24 |
+
run: |
|
| 25 |
+
python setup.py sdist bdist_wheel
|
| 26 |
+
ls -lh dist/
|
| 27 |
+
|
| 28 |
+
- uses: actions/upload-artifact@v2
|
| 29 |
+
with:
|
| 30 |
+
name: pypi-packages-${{ github.sha }}
|
| 31 |
+
path: dist
|
| 32 |
+
|
| 33 |
+
#build-wheels:
|
| 34 |
+
# runs-on: ${{ matrix.os }}
|
| 35 |
+
# needs: build-sdist
|
| 36 |
+
# strategy:
|
| 37 |
+
# fail-fast: true
|
| 38 |
+
# max-parallel: 1
|
| 39 |
+
# matrix:
|
| 40 |
+
# os: [ubuntu-20.04, macOS-10.15, windows-2019]
|
| 41 |
+
# #python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
|
| 42 |
+
# steps:
|
| 43 |
+
# - uses: actions/checkout@master
|
| 44 |
+
# - uses: actions/download-artifact@v2
|
| 45 |
+
# with:
|
| 46 |
+
# name: pypi-packages-${{ github.sha }}
|
| 47 |
+
# path: dist
|
| 48 |
+
#
|
| 49 |
+
# - name: Building wheels
|
| 50 |
+
# uses: pypa/cibuildwheel@v1.11.0
|
| 51 |
+
# env:
|
| 52 |
+
# KORNIA_RELEASE: 1
|
| 53 |
+
# # Disable building PyPy wheels on all platforms
|
| 54 |
+
# CIBW_SKIP: cp27-* cp35-* pp*
|
| 55 |
+
# with:
|
| 56 |
+
# output-dir: dist
|
| 57 |
+
#
|
| 58 |
+
# - uses: actions/upload-artifact@v2
|
| 59 |
+
# with:
|
| 60 |
+
# name: pypi-packages-${{ github.sha }}
|
| 61 |
+
# path: dist
|
| 62 |
+
|
| 63 |
+
upload-packages:
|
| 64 |
+
runs-on: ubuntu-20.04
|
| 65 |
+
needs: build-sdist
|
| 66 |
+
steps:
|
| 67 |
+
- uses: actions/checkout@v2
|
| 68 |
+
- uses: actions/download-artifact@v2
|
| 69 |
+
with:
|
| 70 |
+
name: pypi-packages-${{ github.sha }}
|
| 71 |
+
path: dist
|
| 72 |
+
- run: ls -lh dist/
|
| 73 |
+
|
| 74 |
+
- name: Upload to release
|
| 75 |
+
uses: AButler/upload-release-assets@v2.0
|
| 76 |
+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
|
| 77 |
+
with:
|
| 78 |
+
files: 'dist/*'
|
| 79 |
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
| 80 |
+
|
| 81 |
+
publish-pypi:
|
| 82 |
+
runs-on: ubuntu-20.04
|
| 83 |
+
needs: build-sdist
|
| 84 |
+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
|
| 85 |
+
steps:
|
| 86 |
+
- uses: actions/checkout@master
|
| 87 |
+
- uses: actions/setup-python@v2
|
| 88 |
+
with:
|
| 89 |
+
python-version: 3.7
|
| 90 |
+
- uses: actions/download-artifact@v2
|
| 91 |
+
with:
|
| 92 |
+
name: pypi-packages-${{ github.sha }}
|
| 93 |
+
path: dist
|
| 94 |
+
- run: ls -l dist/
|
| 95 |
+
|
| 96 |
+
- name: Publish distribution 📦 to PyPI
|
| 97 |
+
uses: pypa/gh-action-pypi-publish@v1.4.1
|
| 98 |
+
with:
|
| 99 |
+
user: __token__
|
| 100 |
+
password: ${{ secrets.pypi_password }}
|
.github/workflows/python_package.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Python package
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: '0 4 * * *'
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
build:
|
| 9 |
+
runs-on: ${{ matrix.os }}
|
| 10 |
+
strategy:
|
| 11 |
+
matrix:
|
| 12 |
+
# You can use PyPy versions in python-version.
|
| 13 |
+
# For example, pypy2 and pypy3
|
| 14 |
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
| 15 |
+
python-version: [3.6, 3.7, 3.8]
|
| 16 |
+
|
| 17 |
+
steps:
|
| 18 |
+
- uses: actions/checkout@v2
|
| 19 |
+
- name: Set up Python ${{ matrix.python-version }}
|
| 20 |
+
uses: actions/setup-python@v2
|
| 21 |
+
with:
|
| 22 |
+
python-version: ${{ matrix.python-version }}
|
| 23 |
+
- name: Download Kornia binary
|
| 24 |
+
run: |
|
| 25 |
+
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
|
| 26 |
+
pip install kornia
|
| 27 |
+
python -c "import kornia"
|
.github/workflows/tests_cpu.yml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tests-cpu
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [master]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [master]
|
| 8 |
+
types: [open, reopened, synchronize, review_requested, ready_for_review]
|
| 9 |
+
schedule:
|
| 10 |
+
- cron: "0 4 * * *"
|
| 11 |
+
|
| 12 |
+
jobs:
|
| 13 |
+
tests-cpu:
|
| 14 |
+
runs-on: ${{ matrix.os }}
|
| 15 |
+
strategy:
|
| 16 |
+
fail-fast: false
|
| 17 |
+
matrix:
|
| 18 |
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
| 19 |
+
python-version: [3.6, 3.8, 3.9]
|
| 20 |
+
pytorch-version: [1.8.1, 1.9.1]
|
| 21 |
+
steps:
|
| 22 |
+
- uses: actions/checkout@v2
|
| 23 |
+
- name: Setup conda dependencies
|
| 24 |
+
uses: conda-incubator/setup-miniconda@v2
|
| 25 |
+
with:
|
| 26 |
+
auto-update-conda: true
|
| 27 |
+
python-version: ${{ matrix.python-version }}
|
| 28 |
+
- name: Install dependencies
|
| 29 |
+
shell: bash -l {0}
|
| 30 |
+
run: |
|
| 31 |
+
conda install curl -c conda-forge
|
| 32 |
+
conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c pytorch
|
| 33 |
+
pip install .[all]
|
| 34 |
+
- name: Run Tests
|
| 35 |
+
shell: bash -l {0}
|
| 36 |
+
run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test --flake8 --mypy
|
| 37 |
+
- name: Upload coverage
|
| 38 |
+
uses: codecov/codecov-action@v1
|
| 39 |
+
with:
|
| 40 |
+
token: ${{ secrets.CODECOV_TOKEN }}
|
| 41 |
+
file: coverage.xml
|
| 42 |
+
flags: cpu,pytest, torch${{ matrix.pytorch-version }}
|
| 43 |
+
name: cpu-coverage
|
.github/workflows/tests_cuda.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tests-cuda
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- master
|
| 7 |
+
pull_request:
|
| 8 |
+
branches:
|
| 9 |
+
- master
|
| 10 |
+
schedule:
|
| 11 |
+
- cron: "0 0 * * *"
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
tests-cuda:
|
| 15 |
+
container:
|
| 16 |
+
image: pytorch/pytorch:1.6.0-cuda10.1-cudnn7-runtime
|
| 17 |
+
options: --gpus all
|
| 18 |
+
runs-on: [self-hosted, Linux, x64]
|
| 19 |
+
steps:
|
| 20 |
+
- uses: actions/checkout@v2
|
| 21 |
+
- name: Install dependencies
|
| 22 |
+
shell: bash -l {0}
|
| 23 |
+
run: |
|
| 24 |
+
# NOTE: pytorch image does not include git
|
| 25 |
+
conda install -c anaconda git
|
| 26 |
+
pip install .[all]
|
| 27 |
+
- name: Run Tests
|
| 28 |
+
shell: bash -l {0}
|
| 29 |
+
run: pytest -v --device cuda --dtype float32,float64 ./test
|
.github/workflows/tests_nightly.yml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: test-nightly
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
#push:
|
| 5 |
+
# branches:
|
| 6 |
+
# - master
|
| 7 |
+
#pull_request:
|
| 8 |
+
schedule:
|
| 9 |
+
- cron: "0 4 * * *"
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
test-cpu-versions:
|
| 13 |
+
runs-on: ${{ matrix.os }}
|
| 14 |
+
strategy:
|
| 15 |
+
fail-fast: false
|
| 16 |
+
matrix:
|
| 17 |
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
| 18 |
+
python-version: [3.6, 3.7, 3.8]
|
| 19 |
+
steps:
|
| 20 |
+
- uses: actions/checkout@v2
|
| 21 |
+
- name: Setup conda dependencies
|
| 22 |
+
uses: conda-incubator/setup-miniconda@v2
|
| 23 |
+
with:
|
| 24 |
+
auto-update-conda: true
|
| 25 |
+
python-version: ${{ matrix.python-version }}
|
| 26 |
+
- name: Install dependencies
|
| 27 |
+
shell: bash -l {0}
|
| 28 |
+
run: |
|
| 29 |
+
conda install curl -c conda-forge
|
| 30 |
+
conda install pytorch cpuonly -c pytorch-nightly
|
| 31 |
+
pip install .[all]
|
| 32 |
+
- name: Run Tests
|
| 33 |
+
shell: bash -l {0}
|
| 34 |
+
run: pytest -v --device cpu --dtype float32,float64 ./test --flake8 --mypy
|
.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
build/
|
| 2 |
+
dist/
|
| 3 |
+
kornia.egg-info/
|
| 4 |
+
.idea
|
| 5 |
+
*/**/__pycache__
|
| 6 |
+
*/**/*.pyc
|
| 7 |
+
*/**/*~
|
| 8 |
+
*~
|
| 9 |
+
*.swp
|
| 10 |
+
*.swo
|
| 11 |
+
*.swn
|
| 12 |
+
*.swm
|
| 13 |
+
.eggs/*
|
| 14 |
+
.cache/*
|
| 15 |
+
.pytest_cache/*
|
| 16 |
+
.dev_env
|
| 17 |
+
.mypy_cache/*
|
| 18 |
+
.coverage
|
| 19 |
+
*bak
|
| 20 |
+
*ipynb_checkpoints*
|
| 21 |
+
docs/source/_static/*jpg
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
default_language_version:
|
| 2 |
+
python: python3.8
|
| 3 |
+
|
| 4 |
+
ci:
|
| 5 |
+
autofix_prs: true
|
| 6 |
+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
|
| 7 |
+
# submodules: true
|
| 8 |
+
|
| 9 |
+
repos:
|
| 10 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
| 11 |
+
rev: v4.0.1
|
| 12 |
+
hooks:
|
| 13 |
+
- id: end-of-file-fixer
|
| 14 |
+
- id: trailing-whitespace
|
| 15 |
+
- id: check-yaml
|
| 16 |
+
- id: pretty-format-json
|
| 17 |
+
|
| 18 |
+
- repo: https://github.com/psf/black
|
| 19 |
+
rev: 21.9b0
|
| 20 |
+
hooks:
|
| 21 |
+
- id: black
|
| 22 |
+
args: [--diff]
|
| 23 |
+
|
| 24 |
+
- repo: https://github.com/codespell-project/codespell
|
| 25 |
+
rev: v2.1.0
|
| 26 |
+
hooks:
|
| 27 |
+
- id: codespell
|
| 28 |
+
args:
|
| 29 |
+
- --ignore-words-list
|
| 30 |
+
- "ans,hist"
|
| 31 |
+
- --skip
|
| 32 |
+
- "*.bib,*.ipynb"
|
| 33 |
+
|
| 34 |
+
- repo: https://github.com/PyCQA/isort
|
| 35 |
+
rev: 5.9.3
|
| 36 |
+
hooks:
|
| 37 |
+
- id: isort
|
| 38 |
+
|
| 39 |
+
- repo: https://github.com/PyCQA/flake8
|
| 40 |
+
rev: 4.0.1
|
| 41 |
+
hooks:
|
| 42 |
+
- id: flake8
|
| 43 |
+
|
| 44 |
+
- repo: https://github.com/asottile/pyupgrade
|
| 45 |
+
rev: v2.29.0
|
| 46 |
+
hooks:
|
| 47 |
+
- id: pyupgrade
|
| 48 |
+
args: [--py36-plus]
|
| 49 |
+
|
| 50 |
+
- repo: https://github.com/PyCQA/bandit
|
| 51 |
+
rev: 1.7.0
|
| 52 |
+
hooks:
|
| 53 |
+
- id: bandit
|
| 54 |
+
language_version: python3
|
| 55 |
+
exclude: ^test/
|
| 56 |
+
args:
|
| 57 |
+
- -s
|
| 58 |
+
- "B404,B602,B603,B607"
|
| 59 |
+
|
| 60 |
+
- repo: https://github.com/myint/docformatter
|
| 61 |
+
rev: v1.4
|
| 62 |
+
hooks:
|
| 63 |
+
- id: docformatter
|
| 64 |
+
args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]
|
| 65 |
+
|
| 66 |
+
- repo: https://github.com/asottile/yesqa
|
| 67 |
+
rev: v1.2.3
|
| 68 |
+
hooks:
|
| 69 |
+
- id: yesqa
|
| 70 |
+
name: Unused noqa
|
BACKERS.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<h1 align="center">Sponsors & Backers</h1>
|
| 2 |
+
|
| 3 |
+
Kornia is an Apache-licensed open source project, which is supported by these brilliant [backers](https://github.com/kornia/kornia/blob/master/LICENSE/BACKERS.md). If you'd like to join them, please consider:
|
| 4 |
+
|
| 5 |
+
- [Become a backer or sponsor on OpenCollective](https://opencollective.com/kornia).
|
CHANGELOG.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
All notable changes to this project will be documented in this file.
|
| 3 |
+
|
| 4 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
| 5 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 6 |
+
|
| 7 |
+
****
|
| 8 |
+
## :rocket: [0.6.0] - 2021-10-22
|
| 9 |
+
|
| 10 |
+
### :new: New Features
|
| 11 |
+
- Add Training API (#1307)
|
| 12 |
+
- Added combine patches (#1309)
|
| 13 |
+
- Add semantic segmentation trainer (#1323)
|
| 14 |
+
- Add vanilla LO-RANSAC (#1335)
|
| 15 |
+
- Add Lambda function module (#1346)
|
| 16 |
+
- Add support for YUV420 and YUV422 to complement current YUV444 (#1360)
|
| 17 |
+
- Add raw to rgb color conversion (#1380)
|
| 18 |
+
- Implement separable_filter2d (#1385)
|
| 19 |
+
- Add MobileViT to contrib (#1388)
|
| 20 |
+
- Add solve_pnp_dlt (#1349)
|
| 21 |
+
- Add function image_list_to_tensor to utils (#1393)
|
| 22 |
+
- Add undistort_image function (#1303)
|
| 23 |
+
- Create kormia.metrics submodule (#1325)
|
| 24 |
+
- Add Image Stitching API (#1358)
|
| 25 |
+
- Add Homography Tracker API (#1389)
|
| 26 |
+
|
| 27 |
+
### :exclamation: Changes
|
| 28 |
+
- Refactor library namespaces [pre-release][0.6-rc1] (#1412)
|
| 29 |
+
- deprecate 1.6/1.7 and add 1.9.1 (#1399)
|
| 30 |
+
|
| 31 |
+
### :zap: Improvements
|
| 32 |
+
- Improve bbox_to_mask (#1351)
|
| 33 |
+
- Refactor unfold->conv for morphology backbone (#1107)
|
| 34 |
+
- Improve focal loss for numerical stability (#1362)
|
| 35 |
+
- Add more border_type options for filter2D (#1375)
|
| 36 |
+
- Replace deprecated torch.qr (#1376)
|
| 37 |
+
- Add special case hardcoded implementtion for local features speed up (#1387)
|
| 38 |
+
- Enable non/batched connected components (#1193)
|
| 39 |
+
- Remove warnings during testing (#1401)
|
| 40 |
+
|
| 41 |
+
### :lady_beetle: Bug fixes
|
| 42 |
+
- Fix binary focal loss (#1313)
|
| 43 |
+
- Fix kornia.geometry.subpix.spatial_soft_argmax imports (#1318)
|
| 44 |
+
- Fixed a simple typo in __init__.py (#1319)
|
| 45 |
+
- Fix path to dev requirements file in a setup_dev_env.sh (#1324)
|
| 46 |
+
- Fix bug in create_meshgrid3d along depth (#1330)
|
| 47 |
+
- Fix anisotropic scale error (#1340)
|
| 48 |
+
- Fix rgb_to_hsv for onnx (#1329)
|
| 49 |
+
- Fixed useless return in ransac.py (#1352)
|
| 50 |
+
- Fixed classificationhead typo and leave out some of the guesswork (#1354)
|
| 51 |
+
- Fix clahe differentiability and tests (#1356)
|
| 52 |
+
- Fixes singular matrix inverse/solve for RANSAC and ConvQuad3d (#1408)
|
| 53 |
+
- Change intermediate datatype to fix imgwarp (#1413)
|
| 54 |
+
|
| 55 |
+
## :rocket: [0.5.11] - 2021-08-30
|
| 56 |
+
### :new: New Features
|
| 57 |
+
- Add Vision Transformer (ViT) ([#1296](https://github.com/kornia/kornia/pull/1296))
|
| 58 |
+
- Add ImageRegistrator API ([#1253](https://github.com/kornia/kornia/pull/1253))
|
| 59 |
+
- Add LoFTR inference ([#1218](https://github.com/kornia/kornia/pull/1218))
|
| 60 |
+
- Added differentiable Hausdorff Distance (HD) loss ([#1254](https://github.com/kornia/kornia/pull/1254))
|
| 61 |
+
- Add PadTo to kornia.augmentation ([#1286](https://github.com/kornia/kornia/pull/1286))
|
| 62 |
+
|
| 63 |
+
### :zap: Code refactor
|
| 64 |
+
- Return all learned modules by default in eval() mode ([#1266](https://github.com/kornia/kornia/pull/1266))
|
| 65 |
+
- Enable ImageSequential and VideoSequential to AugmentationSequential (#1231)
|
| 66 |
+
- Specify that angles are in radians ([#1287](https://github.com/kornia/kornia/pull/1287))
|
| 67 |
+
- Removed deprecated codes for v6.0 ([#1281](https://github.com/kornia/kornia/pull/1281))
|
| 68 |
+
|
| 69 |
+
### :lady_beetle: Bug fixes
|
| 70 |
+
- Fix save_pointcloud_ply fn counting point with inf coordinates ([#1263](https://github.com/kornia/kornia/pull/1263))
|
| 71 |
+
- Fixes torch version parse and add temporal packaging dependency ([#1284](https://github.com/kornia/kornia/pull/1284))
|
| 72 |
+
- Fix issue of image_histogram2d ([#1295](https://github.com/kornia/kornia/pull/1295))
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
## [0.5.10] - 2021-08-30
|
| 76 |
+
|
| 77 |
+
### Added
|
| 78 |
+
- Added Basic pool request for DeFMO. ([#1135](https://github.com/kornia/kornia/pull/1135))
|
| 79 |
+
- Added homography error metrics, and improved find_homography_iter ([#1222](https://github.com/kornia/kornia/pull/1222))
|
| 80 |
+
|
| 81 |
+
### Fixed
|
| 82 |
+
- Fixed wrong param name ([#1197](https://github.com/kornia/kornia/pull/1197))
|
| 83 |
+
- Fixed NotImplementedError for the rtvec ([#1215)](https://github.com/kornia/kornia/pull/1215))
|
| 84 |
+
- Fixes warnings and add compatibility stub in torch solve ([#1235](https://github.com/kornia/kornia/pull/1235))
|
| 85 |
+
|
| 86 |
+
### Changed
|
| 87 |
+
- Ensure CenterCrop indices are integers ([#1208](https://github.com/kornia/kornia/pull/1208))
|
| 88 |
+
- Added tests, fixed docstrings and made some other changes ([#1211](https://github.com/kornia/kornia/pull/1211))
|
| 89 |
+
- Upgrade to modern Python syntax ([#1213](https://github.com/kornia/kornia/pull/1213))
|
| 90 |
+
- Code health improvements [#1199, #1200, #1198, #1202, #1203, #1205, #1208, #1210, #1214, #1220]
|
| 91 |
+
- Enable pyupgrade as pre-commit ([#1221](https://github.com/kornia/kornia/pull/1221))
|
| 92 |
+
- Add bandit tool in the pre-commit ([#1228](https://github.com/kornia/kornia/pull/1228))
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
## [0.5.8] - 2021-08-06
|
| 96 |
+
|
| 97 |
+
### Added
|
| 98 |
+
- Add the connected components labeling algorithm ([#1184](https://github.com/kornia/kornia/pull/1184))
|
| 99 |
+
|
| 100 |
+
### Fixed
|
| 101 |
+
- Partial fix for horizontal and vertical flips ([#1166](https://github.com/kornia/kornia/pull/1166))
|
| 102 |
+
- Fix even kernel and add test ([#1183](https://github.com/kornia/kornia/pull/1183))
|
| 103 |
+
- Fix wrong source points for RandomThinPlateSpline ([#1187](https://github.com/kornia/kornia/pull/1187))
|
| 104 |
+
- Fix RandomElasticTransform ignores same_on_batch ([#1189](https://github.com/kornia/kornia/pull/1189))
|
| 105 |
+
- Fixed bugs in patchsequential. Remove fill_diagonal operation for better ONNX support ([#1178](https://github.com/kornia/kornia/pull/1178))
|
| 106 |
+
|
| 107 |
+
### Changed
|
| 108 |
+
- Differentiable image histogram using kernel density estimation ([#1172](https://github.com/kornia/kornia/pull/1172))
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
## [0.5.7] - 2021-07-27
|
| 112 |
+
|
| 113 |
+
### Added
|
| 114 |
+
- Grayscale to RGB image conversion. ([#1162](https://github.com/kornia/kornia/pull/1162))
|
| 115 |
+
- Add keepdim param to tensor_to_image function. ([#1168](https://github.com/kornia/kornia/pull/1168))
|
| 116 |
+
|
| 117 |
+
### Fixed
|
| 118 |
+
- Fix checks on wrong tensor shape condition in depth.py ([#1164](https://github.com/kornia/kornia/pull/1164))
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
## [0.5.6] - 2021-07-12
|
| 122 |
+
|
| 123 |
+
### Added
|
| 124 |
+
- Added mix augmentations in containers ([#1139](https://github.com/kornia/kornia/pull/1139))
|
| 125 |
+
|
| 126 |
+
### Fixed
|
| 127 |
+
- Fixed non-4-dim input error for sequential ([#1146](https://github.com/kornia/kornia/pull/1146))
|
| 128 |
+
|
| 129 |
+
### Changed
|
| 130 |
+
- Moving bbox-related functionality to bbox module ([#1103](https://github.com/kornia/kornia/pull/1103))
|
| 131 |
+
- Optimized version of hls_to_rgb and rgb_to_hls ([#1154](https://github.com/kornia/kornia/pull/1154))
|
| 132 |
+
|
| 133 |
+
### Removed
|
| 134 |
+
- Remove numpy dependency ([#1136](https://github.com/kornia/kornia/pull/1136))
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
## [0.5.5] - 2021-06-26
|
| 138 |
+
|
| 139 |
+
### Added
|
| 140 |
+
- Added Stereo camera class ([#1102](https://github.com/kornia/kornia/pull/1102))
|
| 141 |
+
- Added auto-generated images in docs ([#1105](https://github.com/kornia/kornia/pull/1105)) ([#1108](https://github.com/kornia/kornia/pull/1108)) ([#1127](https://github.com/kornia/kornia/pull/1127)) ([#1128](https://github.com/kornia/kornia/pull/1128)) ([#1129](https://github.com/kornia/kornia/pull/1129)) ([#1131](https://github.com/kornia/kornia/pull/1131))
|
| 142 |
+
- Added chinese version README ([#1112](https://github.com/kornia/kornia/pull/1112))
|
| 143 |
+
- Added random_apply to augmentaton containers ([#1125](https://github.com/kornia/kornia/pull/1125))
|
| 144 |
+
|
| 145 |
+
### Changed
|
| 146 |
+
- Change GaussianBlur to RandomGaussianBlur ([#1118](https://github.com/kornia/kornia/pull/1118))
|
| 147 |
+
- Update ci with pytorch 1.9.0 ([#1120](https://github.com/kornia/kornia/pull/1120))
|
| 148 |
+
- Changed option for mean and std to be tuples in normalization ([#987](https://github.com/kornia/kornia/pull/987))
|
| 149 |
+
- Adopt torch.testing.assert_close ([#1031](https://github.com/kornia/kornia/pull/1031))
|
| 150 |
+
|
| 151 |
+
### Removed
|
| 152 |
+
- Remove numpy import ([#1116](https://github.com/kornia/kornia/pull/1116))
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
## [0.5.4] - 2021-06-11
|
| 156 |
+
|
| 157 |
+
### Added
|
| 158 |
+
- Add Canny edge detection ([#1020](https://github.com/kornia/kornia/pull/1020))
|
| 159 |
+
- Added Batched forward function ([#1058](https://github.com/kornia/kornia/pull/1058))
|
| 160 |
+
- Added denormalize homography function [(#1061](https://github.com/kornia/kornia/pull/1061))
|
| 161 |
+
- Added more augmentations containers ([#1014](https://github.com/kornia/kornia/pull/1014))
|
| 162 |
+
- Added calibration module and Undistort 2D points function ([#1026](https://github.com/kornia/kornia/pull/1026))
|
| 163 |
+
- Added patch augmentation container ([#1095](https://github.com/kornia/kornia/pull/1095))
|
| 164 |
+
|
| 165 |
+
### Fixed
|
| 166 |
+
- Remove lena ([#1059](https://github.com/kornia/kornia/pull/1059)) :)
|
| 167 |
+
|
| 168 |
+
### Changed
|
| 169 |
+
- Resize regardless of number of dims, considering the last two dims as image ([#1047](https://github.com/kornia/kornia/pull/1047))
|
| 170 |
+
- Raise error if converting to unit8 image to gray with float weights ([#1057](https://github.com/kornia/kornia/pull/1057))
|
| 171 |
+
- Filter 2D->2d, 3D->3d ([#1069](https://github.com/kornia/kornia/pull/1069))
|
| 172 |
+
- Removed augmentation functional module. ([#1067](https://github.com/kornia/kornia/pull/1067))
|
| 173 |
+
- Make Morphology compatible with both OpenCV and Scipy ([#1084](https://github.com/kornia/kornia/pull/1084))
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
## [0.5.3] - 2021-05-29
|
| 177 |
+
|
| 178 |
+
### Added
|
| 179 |
+
- Added inverse for augmentations ([#1013](https://github.com/kornia/kornia/pull/1013))
|
| 180 |
+
- Add advanced augmentations: RandomFisheye, RandomElasticTransform, RandomThinPlateSpline, RandomBloxBlur ([#1015](https://github.com/kornia/kornia/pull/1015)
|
| 181 |
+
|
| 182 |
+
### Fixed
|
| 183 |
+
- Correct Sobel test_noncontiguous. Nothing was tested before. ([#1018](https://github.com/kornia/kornia/pull/1018))
|
| 184 |
+
- Fixing #795: find_homography_dlt_iterated sometimes fails ([#1022](https://github.com/kornia/kornia/pull/1022))
|
| 185 |
+
|
| 186 |
+
### Changed
|
| 187 |
+
- Refactorization of the morphology package ([#1034](https://github.com/kornia/kornia/pull/1034))
|
| 188 |
+
- Optimised clipping in clahe and some other minor optimisation ([#1035](https://github.com/kornia/kornia/pull/1035))
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
## [0.5.2] - 2021-05-14
|
| 192 |
+
|
| 193 |
+
## Added
|
| 194 |
+
- Added unsharp mask filtering ([#1004](https://github.com/kornia/kornia/pull/1004))
|
| 195 |
+
|
| 196 |
+
### Fixed
|
| 197 |
+
- Fixed angle axis to quaternion order bug ([#926](https://github.com/kornia/kornia/pull/926))
|
| 198 |
+
- Fixed type error for lab_to_rgb conversion when using coremltools. ([#1002](https://github.com/kornia/kornia/pull/1002))
|
| 199 |
+
|
| 200 |
+
### Changed
|
| 201 |
+
- Mask with unbatched motion from essential choose solution ([#998](https://github.com/kornia/kornia/pull/998))
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
## [0.5.1] - 2021-04-30
|
| 205 |
+
|
| 206 |
+
### Added
|
| 207 |
+
- Added dtype for create_mesh ([#919](https://github.com/kornia/kornia/pull/919))
|
| 208 |
+
- Added Hardnet8 ([#955](https://github.com/kornia/kornia/pull/955))
|
| 209 |
+
- Added normalize boolean for remap ([#921](https://github.com/kornia/kornia/pull/921))
|
| 210 |
+
- Added custom weights option for rgb2gray ([#944](https://github.com/kornia/kornia/pull/944))
|
| 211 |
+
- Added fp16 support ([#963](https://github.com/kornia/kornia/pull/963))
|
| 212 |
+
- Added ImageToTensor module and resize for non-batched images ([#978](https://github.com/kornia/kornia/pull/978))
|
| 213 |
+
- Add more augmentations ([#960](https://github.com/kornia/kornia/pull/960))
|
| 214 |
+
- Anti alias resize ([#989](https://github.com/kornia/kornia/pull/989))
|
| 215 |
+
|
| 216 |
+
## Changed
|
| 217 |
+
- Improve kornia porphology ([#965](https://github.com/kornia/kornia/pull/965))
|
| 218 |
+
- Improve cuda ci workflow speed ([#975](https://github.com/kornia/kornia/pull/975))
|
| 219 |
+
- Refactor augmentation module ([#948](https://github.com/kornia/kornia/pull/948))
|
| 220 |
+
- Implement fast version of crop function in augmentations ([#967](https://github.com/kornia/kornia/pull/967))
|
| 221 |
+
- Implement missing jit ops in kornia.geometry.transform ([#981](https://github.com/kornia/kornia/pull/981))
|
| 222 |
+
|
| 223 |
+
### Fixed
|
| 224 |
+
- Fixed RandomAffine translation range check ([#917](https://github.com/kornia/kornia/pull/917)
|
| 225 |
+
- Fixed the issue of NaN gradients by adding epsilon in focal loss ([#924](https://github.com/kornia/kornia/pull/924))
|
| 226 |
+
- Allow crop size greater than input size. ([#957](https://github.com/kornia/kornia/pull/957))
|
| 227 |
+
- Fixed RandomCrop bug ([#951](https://github.com/kornia/kornia/pull/951))
|
| 228 |
+
|
| 229 |
+
### Removed
|
| 230 |
+
- Deprecate some augmentation functionals ([#943](https://github.com/kornia/kornia/pull/943))
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
## [0.4.1] - 2020-10-20
|
| 234 |
+
### Added
|
| 235 |
+
- Update docs for `get_affine_matrix2d` and `get_affine_matrix3d` ([#618](https://github.com/kornia/kornia/pull/618))
|
| 236 |
+
- Added docs for `solarize`, `posterize`, `sharpness`, `equalize` ([#623](https://github.com/kornia/kornia/pull/623))
|
| 237 |
+
- Added tensor device conversion for solarize params ([#624](https://github.com/kornia/kornia/pull/624))
|
| 238 |
+
- Added rescale functional and transformation ([#631](https://github.com/kornia/kornia/pull/631))
|
| 239 |
+
- Added Mixup data augmentation ([#609](https://github.com/kornia/kornia/pull/609))
|
| 240 |
+
- Added `equalize3d` ([#639](https://github.com/kornia/kornia/pull/639))
|
| 241 |
+
- Added `decompose 3x4projection matrix` ([#650](https://github.com/kornia/kornia/pull/650))
|
| 242 |
+
- Added `normalize_min_max` functionality ([#684](https://github.com/kornia/kornia/pull/684))
|
| 243 |
+
- Added `random equalize3d` ([#653](https://github.com/kornia/kornia/pull/653))
|
| 244 |
+
- Added 3D motion blur ([#713](https://github.com/kornia/kornia/pull/713))
|
| 245 |
+
- Added 3D volumetric crop implementation ([#689](https://github.com/kornia/kornia/pull/689))
|
| 246 |
+
- `warp_affine3d`
|
| 247 |
+
- `warp_perspective3d`
|
| 248 |
+
- `get_perspective_transform3d`
|
| 249 |
+
- `crop_by_boxes3d`
|
| 250 |
+
- `warp_grid3d`
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
### Changed
|
| 254 |
+
- Replace convolution with `unfold` in `contrib.extract_tensor_patches` ([#626](https://github.com/kornia/kornia/pull/626))
|
| 255 |
+
- Updates Affine scale with non-isotropic values ([#646](https://github.com/kornia/kornia/pull/646))
|
| 256 |
+
- Enabled param p for each augmentation ([#664](https://github.com/kornia/kornia/pull/664))
|
| 257 |
+
- Enabled RandomResizedCrop batch mode when same_on_batch=False ([#683](https://github.com/kornia/kornia/pull/683))
|
| 258 |
+
- Increase speed of transform_points ([#687](https://github.com/kornia/kornia/pull/687))
|
| 259 |
+
- Improves `find_homography_dlt` performance improvement and weights params made optional ([#690](https://github.com/kornia/kornia/pull/690))
|
| 260 |
+
- Enable variable side resizing in `kornia.resize` ([#628](https://github.com/kornia/kornia/pull/628))
|
| 261 |
+
- Added `Affine` transformation as `nn.Module` ([#630](https://github.com/kornia/kornia/pull/630))
|
| 262 |
+
- Accelerate augmentations ([#708](https://github.com/kornia/kornia/pull/708))
|
| 263 |
+
|
| 264 |
+
### Fixed
|
| 265 |
+
- Fixed error in normal_transform_pixel3d ([#621](https://github.com/kornia/kornia/pull/621))
|
| 266 |
+
- Fixed pipelining multiple augmentations return wrong transformation matrix (#645)([645](https://github.com/kornia/kornia/pull/645))
|
| 267 |
+
- Fixed flipping returns wrong transformation matrices ([#648](https://github.com/kornia/kornia/pull/648))
|
| 268 |
+
- Fixed 3d augmentations return wrong transformation matrix ([#665](https://github.com/kornia/kornia/pull/665))
|
| 269 |
+
- Fix the SOSNet loading bug ([#668](https://github.com/kornia/kornia/pull/668))
|
| 270 |
+
- Fix/random perspective returns wrong transformation matrix ([#667](https://github.com/kornia/kornia/pull/667))
|
| 271 |
+
- Fixes Zca inverse transform ([#695](https://github.com/kornia/kornia/pull/695))
|
| 272 |
+
- Fixes Affine scale bug ([#714](https://github.com/kornia/kornia/pull/714))
|
| 273 |
+
|
| 274 |
+
## Removed
|
| 275 |
+
- Removed `warp_projective` ([#689](https://github.com/kornia/kornia/pull/689))
|
CITATION.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
## Cite Kornia papers
|
| 3 |
+
1. Kornia: an Open Source Differentiable Computer Vision Library for PyTorch
|
| 4 |
+
2. A survey on Kornia: an Open Source Differentiable Computer Vision Library for PyTorch
|
| 5 |
+
3. Differentiable Data Augmentation with Kornia
|
| 6 |
+
4. torchgeometry: when PyTorch meets geometry
|
| 7 |
+
```bash
|
| 8 |
+
@inproceedings{eriba2019kornia,
|
| 9 |
+
author = {E. Riba, D. Mishkin, D. Ponsa, E. Rublee and G. Bradski},
|
| 10 |
+
title = {Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},
|
| 11 |
+
booktitle = {Winter Conference on Applications of Computer Vision},
|
| 12 |
+
year = {2020},
|
| 13 |
+
url = {https://arxiv.org/pdf/1910.02190.pdf}
|
| 14 |
+
}
|
| 15 |
+
```
|
| 16 |
+
```bash
|
| 17 |
+
@misc{riba2020survey,
|
| 18 |
+
title={A survey on Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},
|
| 19 |
+
author={E. Riba and D. Mishkin and J. Shi and D. Ponsa and F. Moreno-Noguer and G. Bradski},
|
| 20 |
+
year={2020},
|
| 21 |
+
eprint={2009.10521},
|
| 22 |
+
archivePrefix={arXiv},
|
| 23 |
+
primaryClass={cs.CV}
|
| 24 |
+
}
|
| 25 |
+
```
|
| 26 |
+
```bash
|
| 27 |
+
@misc{shi2020differentiable,
|
| 28 |
+
title={Differentiable Data Augmentation with Kornia},
|
| 29 |
+
author={Jian Shi and Edgar Riba and Dmytro Mishkin and Francesc Moreno and Anguelos Nicolaou},
|
| 30 |
+
year={2020},
|
| 31 |
+
eprint={2011.09832},
|
| 32 |
+
archivePrefix={arXiv},
|
| 33 |
+
primaryClass={cs.CV}
|
| 34 |
+
}
|
| 35 |
+
```
|
| 36 |
+
```bash
|
| 37 |
+
@misc{Arraiy2018,
|
| 38 |
+
author = {E. Riba, M. Fathollahi, W. Chaney, E. Rublee and G. Bradski},
|
| 39 |
+
title = {torchgeometry: when PyTorch meets geometry},
|
| 40 |
+
booktitle = {PyTorch Developer Conference},
|
| 41 |
+
year = {2018},
|
| 42 |
+
url = {https://drive.google.com/file/d/1xiao1Xj9WzjJ08YY_nYwsthE-wxfyfhG/view?usp=sharing}
|
| 43 |
+
}
|
| 44 |
+
```
|
CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributor Covenant Code of Conduct
|
| 2 |
+
|
| 3 |
+
## Our Pledge
|
| 4 |
+
|
| 5 |
+
In the interest of fostering an open and welcoming environment, we as
|
| 6 |
+
contributors and maintainers pledge to making participation in our project and
|
| 7 |
+
our community a harassment-free experience for everyone, regardless of age, body
|
| 8 |
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
| 9 |
+
level of experience, education, socio-economic status, nationality, personal
|
| 10 |
+
appearance, race, religion, or sexual identity and orientation.
|
| 11 |
+
|
| 12 |
+
## Our Standards
|
| 13 |
+
|
| 14 |
+
Examples of behavior that contributes to creating a positive environment
|
| 15 |
+
include:
|
| 16 |
+
|
| 17 |
+
* Using welcoming and inclusive language
|
| 18 |
+
* Being respectful of differing viewpoints and experiences
|
| 19 |
+
* Gracefully accepting constructive criticism
|
| 20 |
+
* Focusing on what is best for the community
|
| 21 |
+
* Showing empathy towards other community members
|
| 22 |
+
|
| 23 |
+
Examples of unacceptable behavior by participants include:
|
| 24 |
+
|
| 25 |
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
| 26 |
+
advances
|
| 27 |
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
| 28 |
+
* Public or private harassment
|
| 29 |
+
* Publishing others' private information, such as a physical or electronic
|
| 30 |
+
address, without explicit permission
|
| 31 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
| 32 |
+
professional setting
|
| 33 |
+
|
| 34 |
+
## Our Responsibilities
|
| 35 |
+
|
| 36 |
+
Project maintainers are responsible for clarifying the standards of acceptable
|
| 37 |
+
behavior and are expected to take appropriate and fair corrective action in
|
| 38 |
+
response to any instances of unacceptable behavior.
|
| 39 |
+
|
| 40 |
+
Project maintainers have the right and responsibility to remove, edit, or
|
| 41 |
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
| 42 |
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
| 43 |
+
permanently any contributor for other behaviors that they deem inappropriate,
|
| 44 |
+
threatening, offensive, or harmful.
|
| 45 |
+
|
| 46 |
+
## Scope
|
| 47 |
+
|
| 48 |
+
This Code of Conduct applies within all project spaces, and it also applies when
|
| 49 |
+
an individual is representing the project or its community in public spaces.
|
| 50 |
+
Examples of representing a project or community include using an official
|
| 51 |
+
project e-mail address, posting via an official social media account, or acting
|
| 52 |
+
as an appointed representative at an online or offline event. Representation of
|
| 53 |
+
a project may be further defined and clarified by project maintainers.
|
| 54 |
+
|
| 55 |
+
## Enforcement
|
| 56 |
+
|
| 57 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
| 58 |
+
reported by contacting the project team at edgar.riba@arraiy.com. All
|
| 59 |
+
complaints will be reviewed and investigated and will result in a response that
|
| 60 |
+
is deemed necessary and appropriate to the circumstances. The project team is
|
| 61 |
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
| 62 |
+
Further details of specific enforcement policies may be posted separately.
|
| 63 |
+
|
| 64 |
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
| 65 |
+
faith may face temporary or permanent repercussions as determined by other
|
| 66 |
+
members of the project's leadership.
|
| 67 |
+
|
| 68 |
+
## Attribution
|
| 69 |
+
|
| 70 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
| 71 |
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
| 72 |
+
|
| 73 |
+
[homepage]: https://www.contributor-covenant.org
|
| 74 |
+
|
| 75 |
+
For answers to common questions about this code of conduct, see
|
| 76 |
+
https://www.contributor-covenant.org/faq
|
CONTRIBUTING.rst
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Contributing to Kornia
|
| 2 |
+
======================
|
| 3 |
+
|
| 4 |
+
**Welcome !!** This is the Kornia library contributors corner. If you are reading this, it means that you have interest in **Differentiable Computer Vision**, and willing to contribute to the project.
|
| 5 |
+
|
| 6 |
+
Everyone is welcomed to get involved with the project. There are different ways in how you can put your two cents:
|
| 7 |
+
|
| 8 |
+
1. Ask/Answer questions using the ``#kornia`` tag in `PyTorch Discuss <https://discuss.pytorch.org>`_
|
| 9 |
+
|
| 10 |
+
- Please, don't use GitHub issues for Q&A.
|
| 11 |
+
- In case you are a developer and want to learn more about the PyTorch ecosystem, we suggest you to join the PyTorch slack. You can apply using this form: `https://bit.ly/ptslack <https://bit.ly/ptslack>`_
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
2. Report bugs through `GitHub issues <https://github.com/kornia/kornia/issues>`_:
|
| 15 |
+
|
| 16 |
+
- Do a quick search first to see whether others reported a similar issue.
|
| 17 |
+
- In case you find an unreported bug, please open a new ticket.
|
| 18 |
+
- Try to provide as much information as possible. Some tips:
|
| 19 |
+
|
| 20 |
+
- Clear title and description of the issue.
|
| 21 |
+
- Explain how to reproduce the error.
|
| 22 |
+
- Report your packages versions to facilitate the task.
|
| 23 |
+
- Try to include a code sample/test that raises the error.
|
| 24 |
+
|
| 25 |
+
3. Fix a bug or develop a feature from the roadmap:
|
| 26 |
+
|
| 27 |
+
- We will always have an open ticket showing the current roadmap.
|
| 28 |
+
- Pick an unassigned feature (or potentially propose new one) or an open bug ticket.
|
| 29 |
+
- Follow the instructions from Developing Kornia in order to setup your development environment and start coding.
|
| 30 |
+
- Checkout our coding conventions. See more details below.
|
| 31 |
+
- Run the test framework locally and make sure all works as expected before sending a pull request.
|
| 32 |
+
- Open a Pull Request, get the green light from the CI and get your code merged.
|
| 33 |
+
|
| 34 |
+
4. Donate resources to the project:
|
| 35 |
+
|
| 36 |
+
- In case you are an organization/institution that want to give support, sponsor or just use the project, please contact us.
|
| 37 |
+
- We are open to start any kind of collaboration and hear feedback from you.
|
| 38 |
+
- We pretend to provide features on demand. Reach us !
|
| 39 |
+
- Currently looking for some kind of server donation in order to test *CUDA* code. (Please contact us).
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
Developing Kornia
|
| 43 |
+
=================
|
| 44 |
+
|
| 45 |
+
In order to start to develop, please follow the steps below:
|
| 46 |
+
|
| 47 |
+
1. Uninstall all existing installs:
|
| 48 |
+
|
| 49 |
+
.. code:: bash
|
| 50 |
+
|
| 51 |
+
pip uninstall kornia
|
| 52 |
+
pip uninstall kornia # run this command twice
|
| 53 |
+
|
| 54 |
+
2. Clone a copy of Kornia from source:
|
| 55 |
+
|
| 56 |
+
.. code:: bash
|
| 57 |
+
|
| 58 |
+
git clone https://github.com/kornia/kornia.git
|
| 59 |
+
cd kornia
|
| 60 |
+
|
| 61 |
+
3. Create a new branch with a meaningful name reflecting your contribution. See an example:
|
| 62 |
+
|
| 63 |
+
.. code:: bash
|
| 64 |
+
|
| 65 |
+
git checkout -b feat/foo_feature
|
| 66 |
+
# or
|
| 67 |
+
git checkout -b fix/bar_bug
|
| 68 |
+
|
| 69 |
+
4. Assuming that you are on ubuntu 16.04, with nvidia-drivers installed. In bash, source the ``path.bash.inc`` script. This will install a local conda environment under ``./.dev_env``, which includes pytorch and some dependencies (no root required).
|
| 70 |
+
|
| 71 |
+
.. code:: bash
|
| 72 |
+
|
| 73 |
+
source ./path.bash.inc
|
| 74 |
+
python setup.py develop
|
| 75 |
+
python -c "import kornia; print(kornia.__version__)"
|
| 76 |
+
|
| 77 |
+
To install, or update the conda environment run ``setup_dev_env.sh``
|
| 78 |
+
|
| 79 |
+
.. code:: bash
|
| 80 |
+
|
| 81 |
+
./setup_dev_env.sh
|
| 82 |
+
|
| 83 |
+
Coding Standards
|
| 84 |
+
================
|
| 85 |
+
|
| 86 |
+
This section provides general guidance for developing code for the project. The following rules will serve as guide in writing high-quality code that will allow us to scale the project and ensure that the code base remains readable and maintainable.
|
| 87 |
+
|
| 88 |
+
- Use meaningful names for variables, functions and classes.
|
| 89 |
+
|
| 90 |
+
- Write small incremental changes:
|
| 91 |
+
|
| 92 |
+
- In order to have a linear and clean commits history, we recommend to commit each small change that you do to the source code.
|
| 93 |
+
- Clear commit messages will help to understand the progress of your work.
|
| 94 |
+
- Please, avoid pushing large files.
|
| 95 |
+
|
| 96 |
+
- Add tests:
|
| 97 |
+
|
| 98 |
+
- Tests are crucial and we expect you to write unit test for each of the functionalities that you implement.
|
| 99 |
+
It is also a good idea to group the tests for functionalities
|
| 100 |
+
|
| 101 |
+
.. code:: python
|
| 102 |
+
|
| 103 |
+
class TestMyFunction:
|
| 104 |
+
def test_smoke(self):
|
| 105 |
+
# check defaults parameters, i/o shapes
|
| 106 |
+
pass
|
| 107 |
+
|
| 108 |
+
def test_feature_foo(self):
|
| 109 |
+
# test basic functionality
|
| 110 |
+
pass
|
| 111 |
+
|
| 112 |
+
def test_feature_bar(self):
|
| 113 |
+
# test another functionality
|
| 114 |
+
pass
|
| 115 |
+
|
| 116 |
+
def test_gradcheck(self):
|
| 117 |
+
# test the functionality gradients
|
| 118 |
+
pass
|
| 119 |
+
|
| 120 |
+
def test_jit(self):
|
| 121 |
+
# test the functionality using jit modules
|
| 122 |
+
pass
|
| 123 |
+
|
| 124 |
+
- Tests should cover different devices (CPU and CUDA) and different input batch size. See an example:
|
| 125 |
+
|
| 126 |
+
.. code:: python
|
| 127 |
+
|
| 128 |
+
@pytest.mark.parametrize("device_type", ("cpu", "cuda"))
|
| 129 |
+
@pytest.mark.parametrize("batch_size", [1, 2, 5])
|
| 130 |
+
def test_smoke(batch_size, device_type):
|
| 131 |
+
x = torch.rand(batch_size, 2, 3)
|
| 132 |
+
x = x.to(torch.device(device_type))
|
| 133 |
+
assert x.shape == (batch_size, 2, 3), x.shape
|
| 134 |
+
|
| 135 |
+
- We give support to static type checker for Python >= 3.6
|
| 136 |
+
|
| 137 |
+
- Please, read `MyPy cheatsheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#type-hints-cheat-sheet-python-3>`_ for Python 3.
|
| 138 |
+
- It is recommended to use typing inside the function, when it would increase readability.
|
| 139 |
+
- Always type function input and output, e.g.:
|
| 140 |
+
|
| 141 |
+
.. code:: python
|
| 142 |
+
|
| 143 |
+
def homography_warp(patch_src: torch.Tensor,
|
| 144 |
+
dst_homo_src: torch.Tensor,
|
| 145 |
+
dsize: Tuple[int, int],
|
| 146 |
+
mode: str = 'bilinear',
|
| 147 |
+
padding_mode: str = 'zeros') -> torch.Tensor:
|
| 148 |
+
|
| 149 |
+
- We suggest to use new Python 3's f-Strings improved string formatting syntax:
|
| 150 |
+
|
| 151 |
+
Guidelines: https://realpython.com/python-f-strings/
|
| 152 |
+
|
| 153 |
+
.. code:: python
|
| 154 |
+
|
| 155 |
+
python_version: int = 3
|
| 156 |
+
print(f"This is an example to use Python {python_version}'s f-Strings")
|
| 157 |
+
|
| 158 |
+
- Format your code:
|
| 159 |
+
|
| 160 |
+
- We follow `PEP8 style guide <https://www.python.org/dev/peps/pep-0008>`_.
|
| 161 |
+
- Use ``pre-commit`` to autoformat each commit before push: https://pre-commit.com/.
|
| 162 |
+
For doing so, just install it for this repository:
|
| 163 |
+
|
| 164 |
+
.. code:: bash
|
| 165 |
+
|
| 166 |
+
pre-commit install
|
| 167 |
+
|
| 168 |
+
- Changes to PEP8:
|
| 169 |
+
|
| 170 |
+
- Line length is 120 char.
|
| 171 |
+
- W504 (line break after binary operator) is sometimes acceptable. E.g.
|
| 172 |
+
|
| 173 |
+
.. code:: python
|
| 174 |
+
|
| 175 |
+
determinant = A[:, :, 0:1, 0:1] * A[:, :, 1:2, 1:2] -
|
| 176 |
+
A[:, :, 0:1, 1:2] * A[:, :, 1:2, 0:1])
|
| 177 |
+
|
| 178 |
+
- Using 3rd party libraries:
|
| 179 |
+
|
| 180 |
+
- Everything from standard library (https://docs.python.org/3/library/) and PyTorch (https://pytorch.org/) is OK.
|
| 181 |
+
It does`t mean, that one should import urllib just because, but doing it when needed is fine.
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
Pull Request
|
| 186 |
+
============
|
| 187 |
+
|
| 188 |
+
Once you finish implementing a feature or bug-fix, please send a Pull Request to
|
| 189 |
+
https://github.com/kornia/kornia through the website.
|
| 190 |
+
|
| 191 |
+
If you are not familiar with creating a Pull Request, here are some guides:
|
| 192 |
+
|
| 193 |
+
- http://stackoverflow.com/questions/14680711/how-to-do-a-github-pull-request
|
| 194 |
+
- https://help.github.com/articles/creating-a-pull-request
|
| 195 |
+
|
| 196 |
+
Once your pull request is created, our continuous build system will check your pull request. Continuous build will test that:
|
| 197 |
+
|
| 198 |
+
- `pytest <https://docs.pytest.org/en/latest>`_ all tests pass.
|
| 199 |
+
- `flake8 <https://pypi.org/project/flake8/>`_ accepts the code style (our guidelines are based on PEP8).
|
| 200 |
+
- `mypy <http://mypy-lang.org>`_ type checks the Python code.
|
| 201 |
+
- The docs can be generated successfully
|
| 202 |
+
- Test coverage remains high. Please add unit tests so we maintain our code coverage.
|
| 203 |
+
|
| 204 |
+
If your code fails one of these checks, you will be expected to fix your pull request before it is considered.
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
Unit testing
|
| 209 |
+
============
|
| 210 |
+
|
| 211 |
+
To run the test suite locally, make sure that you have activated the conda environment, then:
|
| 212 |
+
|
| 213 |
+
.. code:: bash
|
| 214 |
+
|
| 215 |
+
make test
|
| 216 |
+
|
| 217 |
+
Licence
|
| 218 |
+
=======
|
| 219 |
+
|
| 220 |
+
By contributing to the project, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.
|
COPYRIGHT
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (C) 2017-2019, Arraiy, Inc., all rights reserved.
|
| 2 |
+
Copyright (C) 2019- , Kornia authors, all rights reserved.
|
| 3 |
+
|
| 4 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
you may not use this file except in compliance with the License.
|
| 6 |
+
You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
See the License for the specific language governing permissions and
|
| 14 |
+
limitations under the License.
|
LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
Makefile
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.PHONY: test test-cpu test-cuda lint mypy build-docs install uninstall FORCE
|
| 2 |
+
|
| 3 |
+
test: mypy lint build-docs test-all
|
| 4 |
+
# TODO: Add cuda-float16 when #649 is solved
|
| 5 |
+
test-all: FORCE
|
| 6 |
+
pytest -v --device all --dtype float32,float64 --cov=kornia test/ --flake8 --mypy
|
| 7 |
+
|
| 8 |
+
test-cpu: FORCE
|
| 9 |
+
pytest -v --device cpu --dtype all --cov=kornia test/ --flake8 --mypy
|
| 10 |
+
|
| 11 |
+
test-cuda: FORCE
|
| 12 |
+
pytest -v --device cuda --dtype all --cov=kornia test/ --flake8 --mypy
|
| 13 |
+
|
| 14 |
+
test-module: FORCE
|
| 15 |
+
pytest -v --device all --dtype all test/$(module) --flake8 --mypy
|
| 16 |
+
|
| 17 |
+
test-jit: FORCE
|
| 18 |
+
pytest -v --device all --dtype all -m jit
|
| 19 |
+
|
| 20 |
+
test-gradcheck: FORCE
|
| 21 |
+
pytest -v --device all --dtype all -m grad
|
| 22 |
+
|
| 23 |
+
test-nn: FORCE
|
| 24 |
+
pytest -v --device all --dtype all -m nn
|
| 25 |
+
|
| 26 |
+
test-quick: FORCE
|
| 27 |
+
pytest -v --device all --dtype all -m "not (jit or grad or nn)"
|
| 28 |
+
|
| 29 |
+
test-slow: FORCE
|
| 30 |
+
pytest -v --device all --dtype all -m "(jit or grad or nn)"
|
| 31 |
+
|
| 32 |
+
lint: FORCE
|
| 33 |
+
pytest -v --cache-clear --flake8 kornia/ examples/ test/ -m flake8
|
| 34 |
+
|
| 35 |
+
mypy: FORCE
|
| 36 |
+
pytest -v --cache-clear --mypy kornia/ -m mypy
|
| 37 |
+
|
| 38 |
+
autopep8: FORCE
|
| 39 |
+
autopep8 --in-place --aggressive --recursive kornia/ test/ examples/
|
| 40 |
+
|
| 41 |
+
yapf: FORCE
|
| 42 |
+
yapf --in-place --parallel --recursive kornia/ test/ examples/
|
| 43 |
+
|
| 44 |
+
doctest:
|
| 45 |
+
pytest -v --doctest-modules kornia/
|
| 46 |
+
|
| 47 |
+
docstyle: FORCE
|
| 48 |
+
pydocstyle kornia/
|
| 49 |
+
|
| 50 |
+
build-docs: FORCE
|
| 51 |
+
cd docs; make clean html
|
| 52 |
+
|
| 53 |
+
install: FORCE
|
| 54 |
+
python setup.py install
|
| 55 |
+
|
| 56 |
+
install-dev: FORCE
|
| 57 |
+
python setup.py develop
|
| 58 |
+
|
| 59 |
+
benchmark: FORCE
|
| 60 |
+
for f in test/performance/*.py ; do python -utt $${f}; done
|
| 61 |
+
|
| 62 |
+
uninstall: FORCE
|
| 63 |
+
pip uninstall kornia
|
README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div align="center">
|
| 2 |
+
<p align="center">
|
| 3 |
+
<img width="75%" src="https://github.com/kornia/data/raw/main/kornia_banner_pixie.png" />
|
| 4 |
+
</p>
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
English | [简体中文](README_zh-CN.md)
|
| 9 |
+
|
| 10 |
+
<!-- prettier-ignore -->
|
| 11 |
+
<a href="https://kornia.org">Website</a> •
|
| 12 |
+
<a href="https://kornia.readthedocs.io">Docs</a> •
|
| 13 |
+
<a href="https://colab.research.google.com/github/kornia/tutorials/blob/master/source/hello_world_tutorial.ipynb">Try it Now</a> •
|
| 14 |
+
<a href="https://kornia-tutorials.readthedocs.io">Tutorials</a> •
|
| 15 |
+
<a href="https://github.com/kornia/kornia-examples">Examples</a> •
|
| 16 |
+
<a href="https://kornia.github.io//kornia-blog">Blog</a> •
|
| 17 |
+
<a href="https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ">Community</a>
|
| 18 |
+
|
| 19 |
+
[](https://pypi.org/project/kornia)
|
| 20 |
+
[](https://pypi.org/project/kornia)
|
| 21 |
+
[](https://pepy.tech/project/kornia)
|
| 22 |
+
[](LICENCE)
|
| 23 |
+
[](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ)
|
| 24 |
+
[](https://twitter.com/kornia_foss)
|
| 25 |
+
|
| 26 |
+
[](https://github.com/kornia/kornia/actions/workflows/tests_cpu.yml)
|
| 27 |
+
[](https://github.com/kornia/kornia/actions/workflows/tests_cuda.yml)
|
| 28 |
+
[](https://codecov.io/gh/kornia/kornia)
|
| 29 |
+
[](https://kornia.readthedocs.io/en/latest/?badge=latest)
|
| 30 |
+
[](https://results.pre-commit.ci/latest/github/kornia/kornia/master)
|
| 31 |
+
|
| 32 |
+
<a href="https://www.producthunt.com/posts/kornia?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-kornia" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=306439&theme=light" alt="Kornia - Computer vision library for deep learning | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
| 33 |
+
|
| 34 |
+
</p>
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
*Kornia* is a differentiable computer vision library for [PyTorch](https://pytorch.org).
|
| 38 |
+
|
| 39 |
+
It consists of a set of routines and differentiable modules to solve generic computer vision problems. At its core, the package uses *PyTorch* as its main backend both for efficiency and to take advantage of the reverse-mode auto-differentiation to define and compute the gradient of complex functions.
|
| 40 |
+
|
| 41 |
+
<div align="center">
|
| 42 |
+
<img src="https://github.com/kornia/kornia/raw/master/docs/source/_static/img/hakuna_matata.gif" width="75%" height="75%">
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<!--<div align="center">
|
| 46 |
+
<img src="http://drive.google.com/uc?export=view&id=1KNwaanUdY1MynF0EYfyXjDM3ti09tzaq">
|
| 47 |
+
</div>-->
|
| 48 |
+
|
| 49 |
+
## Overview
|
| 50 |
+
|
| 51 |
+
Inspired by existing packages, this library is composed by a subset of packages containing operators that can be inserted within neural networks to train models to perform image transformations, epipolar geometry, depth estimation, and low-level image processing such as filtering and edge detection that operate directly on tensors.
|
| 52 |
+
|
| 53 |
+
At a granular level, Kornia is a library that consists of the following components:
|
| 54 |
+
|
| 55 |
+
| **Component** | **Description** |
|
| 56 |
+
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
|
| 57 |
+
| [kornia](https://kornia.readthedocs.io/en/latest/index.html) | a Differentiable Computer Vision library, with strong GPU support |
|
| 58 |
+
| [kornia.augmentation](https://kornia.readthedocs.io/en/latest/augmentation.html) | a module to perform data augmentation in the GPU |
|
| 59 |
+
| [kornia.color](https://kornia.readthedocs.io/en/latest/color.html) | a set of routines to perform color space conversions |
|
| 60 |
+
| [kornia.contrib](https://kornia.readthedocs.io/en/latest/contrib.html) | a compilation of user contrib and experimental operators |
|
| 61 |
+
| [kornia.enhance](https://kornia.readthedocs.io/en/latest/enhance.html) | a module to perform normalization and intensity transformation |
|
| 62 |
+
| [kornia.feature](https://kornia.readthedocs.io/en/latest/feature.html) | a module to perform feature detection |
|
| 63 |
+
| [kornia.filters](https://kornia.readthedocs.io/en/latest/filters.html) | a module to perform image filtering and edge detection |
|
| 64 |
+
| [kornia.geometry](https://kornia.readthedocs.io/en/latest/geometry.html) | a geometric computer vision library to perform image transformations, 3D linear algebra and conversions using different camera models |
|
| 65 |
+
| [kornia.losses](https://kornia.readthedocs.io/en/latest/losses.html) | a stack of loss functions to solve different vision tasks |
|
| 66 |
+
| [kornia.morphology](https://kornia.readthedocs.io/en/latest/morphology.html) | a module to perform morphological operations |
|
| 67 |
+
| [kornia.utils](https://kornia.readthedocs.io/en/latest/utils.html) | image to tensor utilities and metrics for vision problems |
|
| 68 |
+
|
| 69 |
+
## Installation
|
| 70 |
+
|
| 71 |
+
### From pip:
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
pip install kornia
|
| 75 |
+
pip install kornia[x] # to get the training API !
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
<details>
|
| 79 |
+
<summary>Other installation options</summary>
|
| 80 |
+
|
| 81 |
+
#### From source:
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
python setup.py install
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
#### From source with symbolic links:
|
| 88 |
+
|
| 89 |
+
```bash
|
| 90 |
+
pip install -e .
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
#### From source using pip:
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
pip install git+https://github.com/kornia/kornia
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
</details>
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
## Examples
|
| 103 |
+
|
| 104 |
+
Run our Jupyter notebooks [tutorials](https://kornia-tutorials.readthedocs.io/en/latest/) to learn to use the library.
|
| 105 |
+
|
| 106 |
+
<div align="center">
|
| 107 |
+
<a href="https://colab.research.google.com/github/kornia/tutorials/blob/master/source/hello_world_tutorial.ipynb" target="_blank">
|
| 108 |
+
<img src="https://raw.githubusercontent.com/kornia/data/main/hello_world_arturito.png" width="75%" height="75%">
|
| 109 |
+
</a>
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
:triangular_flag_on_post: **Updates**
|
| 113 |
+
- :white_check_mark: Integrated to [Huggingface Spaces](https://huggingface.co/spaces) with [Gradio](https://github.com/gradio-app/gradio). See [Gradio Web Demo](https://huggingface.co/spaces/akhaliq/Kornia-LoFTR).
|
| 114 |
+
|
| 115 |
+
## Cite
|
| 116 |
+
|
| 117 |
+
If you are using kornia in your research-related documents, it is recommended that you cite the paper. See more in [CITATION](https://github.com/kornia/kornia/blob/master/CITATION.md).
|
| 118 |
+
|
| 119 |
+
```bash
|
| 120 |
+
@inproceedings{eriba2019kornia,
|
| 121 |
+
author = {E. Riba, D. Mishkin, D. Ponsa, E. Rublee and G. Bradski},
|
| 122 |
+
title = {Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},
|
| 123 |
+
booktitle = {Winter Conference on Applications of Computer Vision},
|
| 124 |
+
year = {2020},
|
| 125 |
+
url = {https://arxiv.org/pdf/1910.02190.pdf}
|
| 126 |
+
}
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
## Contributing
|
| 130 |
+
We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us. Please, consider reading the [CONTRIBUTING](https://github.com/kornia/kornia/blob/master/CONTRIBUTING.rst) notes. The participation in this open source project is subject to [Code of Conduct](https://github.com/kornia/kornia/blob/master/CODE_OF_CONDUCT.md).
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
## Community
|
| 134 |
+
- **Forums:** discuss implementations, research, etc. [GitHub Forums](https://github.com/kornia/kornia/discussions)
|
| 135 |
+
- **GitHub Issues:** bug reports, feature requests, install issues, RFCs, thoughts, etc. [OPEN](https://github.com/kornia/kornia/issues/new/choose)
|
| 136 |
+
- **Slack:** Join our workspace to keep in touch with our core contributors and be part of our community. [JOIN HERE](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ)
|
| 137 |
+
- For general information, please visit our website at www.kornia.org
|
README_zh-CN.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div align="center">
|
| 2 |
+
<p align="center">
|
| 3 |
+
<img width="50%" src="https://github.com/kornia/kornia/blob/master/docs/source/_static/img/kornia_logo.svg" />
|
| 4 |
+
</p>
|
| 5 |
+
|
| 6 |
+
**The open-source and Computer Vision 2.0 library**
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
[English](README.md) | 简体中文
|
| 11 |
+
|
| 12 |
+
<!-- prettier-ignore -->
|
| 13 |
+
<a href="https://kornia.org">网站</a> •
|
| 14 |
+
<a href="https://kornia.readthedocs.io">文档</a> •
|
| 15 |
+
<a href="https://colab.research.google.com/github/kornia/tutorials/blob/master/source/hello_world_tutorial.ipynb">快速尝试</a> •
|
| 16 |
+
<a href="https://kornia-tutorials.readthedocs.io">教程</a> •
|
| 17 |
+
<a href="https://github.com/kornia/kornia-examples">例子</a> •
|
| 18 |
+
<a href="https://kornia.github.io//kornia-blog">博客</a> •
|
| 19 |
+
<a href="https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ">Slack社区</a>
|
| 20 |
+
|
| 21 |
+
[](https://pypi.org/project/kornia)
|
| 22 |
+
[](https://pypi.org/project/kornia)
|
| 23 |
+
[](https://pepy.tech/project/kornia)
|
| 24 |
+
[](LICENCE)
|
| 25 |
+
[](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ)
|
| 26 |
+
[](https://twitter.com/kornia_foss)
|
| 27 |
+
|
| 28 |
+
[](https://github.com/kornia/kornia/actions/workflows/tests_cpu_versions.yml)
|
| 29 |
+
[](https://github.com/kornia/kornia/actions/workflows/tests_cuda.yml)
|
| 30 |
+
[](https://codecov.io/gh/kornia/kornia)
|
| 31 |
+
[](https://kornia.readthedocs.io/en/latest/?badge=latest)
|
| 32 |
+
[](https://results.pre-commit.ci/latest/github/kornia/kornia/master)
|
| 33 |
+
|
| 34 |
+
</p>
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
*Kornia* 是一款基于 [PyTorch](https://pytorch.org) 的可微分的计算机视觉库。
|
| 38 |
+
|
| 39 |
+
它由一组用于解决通用计算机视觉问题的操作模块和可微分模块组成。其核心使用 *PyTorch* 作为主要后端,以提高效率并利用反向模式自动微分来定义和计算复杂函数的梯度。
|
| 40 |
+
|
| 41 |
+
<div align="center">
|
| 42 |
+
<img src="https://github.com/kornia/kornia/raw/master/docs/source/_static/img/hakuna_matata.gif" width="75%" height="75%">
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<!--<div align="center">
|
| 46 |
+
<img src="http://drive.google.com/uc?export=view&id=1KNwaanUdY1MynF0EYfyXjDM3ti09tzaq">
|
| 47 |
+
</div>-->
|
| 48 |
+
|
| 49 |
+
## 概览
|
| 50 |
+
|
| 51 |
+
受现有开源库的启发,Kornia可以由包含各种可以嵌入神经网络的操作符组成,并可以训练模型来执行图像变换、对极几何、深度估计和低级图像处理,例如过滤和边缘检测。此外,整个库都可以直接对张量进行操作。
|
| 52 |
+
|
| 53 |
+
详细来说,Kornia 是一个包含以下组件的库:
|
| 54 |
+
|
| 55 |
+
| **Component** | **Description** |
|
| 56 |
+
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
|
| 57 |
+
| [kornia](https://kornia.readthedocs.io/en/latest/index.html) | 具有强大 GPU 支持的可微计算机视觉库 |
|
| 58 |
+
| [kornia.augmentation](https://kornia.readthedocs.io/en/latest/augmentation.html) | 在 GPU 中执行数据增强的模块 |
|
| 59 |
+
| [kornia.color](https://kornia.readthedocs.io/en/latest/color.html) | 执行色彩空间转换的模块 |
|
| 60 |
+
| [kornia.contrib](https://kornia.readthedocs.io/en/latest/contrib.html) | 未进入稳定版本的实验性模块 |
|
| 61 |
+
| [kornia.enhance](https://kornia.readthedocs.io/en/latest/enhance.html) | 执行归一化和像素强度变换的模块 |
|
| 62 |
+
| [kornia.feature](https://kornia.readthedocs.io/en/latest/feature.html) | 执行特征检测的模块 |
|
| 63 |
+
| [kornia.filters](https://kornia.readthedocs.io/en/latest/filters.html) | 执行图像滤波和边缘检测的模块 |
|
| 64 |
+
| [kornia.geometry](https://kornia.readthedocs.io/en/latest/geometry.html) | 执行几何计算的模块,用于使用不同的相机模型执行图像变换、3D线性代数和转换 |
|
| 65 |
+
| [kornia.losses](https://kornia.readthedocs.io/en/latest/losses.html) | 损失函数模块 |
|
| 66 |
+
| [kornia.morphology](https://kornia.readthedocs.io/en/latest/morphology.html) | 执行形态学操作的模块 |
|
| 67 |
+
| [kornia.utils](https://kornia.readthedocs.io/en/latest/utils.html) | 图像/张量常用工具以及metrics |
|
| 68 |
+
|
| 69 |
+
## 安装说明
|
| 70 |
+
|
| 71 |
+
### 通过 pip 安装:
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
pip install kornia
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
<details>
|
| 78 |
+
<summary>其他安装方法</summary>
|
| 79 |
+
|
| 80 |
+
#### 通过源码安装:
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
python setup.py install
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
#### 通过源码安装(软链接至当前路径):
|
| 87 |
+
|
| 88 |
+
```bash
|
| 89 |
+
pip install -e .
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
#### 通过源码安装(从GIT自动下载最新代码):
|
| 93 |
+
|
| 94 |
+
```bash
|
| 95 |
+
pip install git+https://github.com/kornia/kornia
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
</details>
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
## 例子
|
| 102 |
+
|
| 103 |
+
可以尝试通过这些 [教程](https://kornia-tutorials.readthedocs.io/en/latest/) 来学习和使用这个库。
|
| 104 |
+
|
| 105 |
+
<div align="center">
|
| 106 |
+
<a href="https://colab.research.google.com/github/kornia/tutorials/blob/master/source/hello_world_tutorial.ipynb" target="_blank">
|
| 107 |
+
<img src="https://raw.githubusercontent.com/kornia/data/main/hello_world_arturito.png" width="75%" height="75%">
|
| 108 |
+
</a>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
## 引用
|
| 112 |
+
|
| 113 |
+
如果您在与研究相关的文档中使用 Kornia,您可以引用我们的论文。更多信息可以在 [CITATION](https://github.com/kornia/kornia/blob/master/CITATION.md) 看到。
|
| 114 |
+
|
| 115 |
+
```bash
|
| 116 |
+
@inproceedings{eriba2019kornia,
|
| 117 |
+
author = {E. Riba, D. Mishkin, D. Ponsa, E. Rublee and G. Bradski},
|
| 118 |
+
title = {Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},
|
| 119 |
+
booktitle = {Winter Conference on Applications of Computer Vision},
|
| 120 |
+
year = {2020},
|
| 121 |
+
url = {https://arxiv.org/pdf/1910.02190.pdf}
|
| 122 |
+
}
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
## 贡献
|
| 126 |
+
我们感谢所有的贡献者为改进和提升 Kornia 所作出的努力。您可以直接修复一个已知的BUG而无需进一步讨论;如果您想要添加一个任何新的或者扩展功能,请务必先通过提交一个Issue来与我们讨论。详情请阅读 [贡献指南](https://github.com/kornia/kornia/blob/master/CONTRIBUTING.rst)。开源项目的参与者请务必了解如下 [规范](https://github.com/kornia/kornia/blob/master/CODE_OF_CONDUCT.md)。
|
| 127 |
+
|
| 128 |
+
## 社区
|
| 129 |
+
- **论坛:** 讨论代码实现,学术研究等。[GitHub Forums](https://github.com/kornia/kornia/discussions)
|
| 130 |
+
- **GitHub Issues:** bug reports, feature requests, install issues, RFCs, thoughts, etc. [OPEN](https://github.com/kornia/kornia/issues/new/choose)
|
| 131 |
+
- **Slack:** 加入我们的Slack社区,与我们的核心贡献者保持联系。 [JOIN HERE](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ)
|
| 132 |
+
- 常见信息请访问我们的网站 www.kornia.org
|
| 133 |
+
|
| 134 |
+
## 中文社区
|
| 135 |
+
扫描下方的二维码可关注 Kornia 的官方交流QQ群(679683070)。
|
| 136 |
+
|
| 137 |
+
<div align="center">
|
| 138 |
+
<img src="https://github.com/kornia/kornia/raw/master/docs/source/_static/img/cn_community_qq.jpg" width="75%" height="75%">
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
我们会在 Kornia 交流社区为大家
|
| 142 |
+
|
| 143 |
+
- 📢 更新 Kornia 的最新动态
|
| 144 |
+
- 📘 进行更高效的答疑解惑以及意见反馈
|
| 145 |
+
- 💻 提供与行业大牛的充分交流的平台
|
conftest.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from itertools import product
|
| 2 |
+
from typing import Dict
|
| 3 |
+
|
| 4 |
+
import numpy
|
| 5 |
+
import pytest
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
import kornia
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def get_test_devices() -> Dict[str, torch.device]:
|
| 12 |
+
"""Create a dictionary with the devices to test the source code. CUDA devices will be test only in case the
|
| 13 |
+
current hardware supports it.
|
| 14 |
+
|
| 15 |
+
Return:
|
| 16 |
+
dict(str, torch.device): list with devices names.
|
| 17 |
+
"""
|
| 18 |
+
devices: Dict[str, torch.device] = {}
|
| 19 |
+
devices["cpu"] = torch.device("cpu")
|
| 20 |
+
if torch.cuda.is_available():
|
| 21 |
+
devices["cuda"] = torch.device("cuda:0")
|
| 22 |
+
if kornia.xla_is_available():
|
| 23 |
+
import torch_xla.core.xla_model as xm
|
| 24 |
+
|
| 25 |
+
devices["tpu"] = xm.xla_device()
|
| 26 |
+
return devices
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def get_test_dtypes() -> Dict[str, torch.dtype]:
|
| 30 |
+
"""Create a dictionary with the dtypes the source code.
|
| 31 |
+
|
| 32 |
+
Return:
|
| 33 |
+
dict(str, torch.dtype): list with dtype names.
|
| 34 |
+
"""
|
| 35 |
+
dtypes: Dict[str, torch.dtype] = {}
|
| 36 |
+
dtypes["float16"] = torch.float16
|
| 37 |
+
dtypes["float32"] = torch.float32
|
| 38 |
+
dtypes["float64"] = torch.float64
|
| 39 |
+
return dtypes
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# setup the devices to test the source code
|
| 43 |
+
|
| 44 |
+
TEST_DEVICES: Dict[str, torch.device] = get_test_devices()
|
| 45 |
+
TEST_DTYPES: Dict[str, torch.dtype] = get_test_dtypes()
|
| 46 |
+
|
| 47 |
+
# Combinations of device and dtype to be excluded from testing.
|
| 48 |
+
DEVICE_DTYPE_BLACKLIST = {('cpu', 'float16')}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
@pytest.fixture()
|
| 52 |
+
def device(device_name) -> torch.device:
|
| 53 |
+
return TEST_DEVICES[device_name]
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
@pytest.fixture()
|
| 57 |
+
def dtype(dtype_name) -> torch.dtype:
|
| 58 |
+
return TEST_DTYPES[dtype_name]
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def pytest_generate_tests(metafunc):
|
| 62 |
+
device_names = None
|
| 63 |
+
dtype_names = None
|
| 64 |
+
if 'device_name' in metafunc.fixturenames:
|
| 65 |
+
raw_value = metafunc.config.getoption('--device')
|
| 66 |
+
if raw_value == 'all':
|
| 67 |
+
device_names = list(TEST_DEVICES.keys())
|
| 68 |
+
else:
|
| 69 |
+
device_names = raw_value.split(',')
|
| 70 |
+
if 'dtype_name' in metafunc.fixturenames:
|
| 71 |
+
raw_value = metafunc.config.getoption('--dtype')
|
| 72 |
+
if raw_value == 'all':
|
| 73 |
+
dtype_names = list(TEST_DTYPES.keys())
|
| 74 |
+
else:
|
| 75 |
+
dtype_names = raw_value.split(',')
|
| 76 |
+
if device_names is not None and dtype_names is not None:
|
| 77 |
+
# Exclude any blacklisted device/dtype combinations.
|
| 78 |
+
params = [combo for combo in product(device_names, dtype_names) if combo not in DEVICE_DTYPE_BLACKLIST]
|
| 79 |
+
metafunc.parametrize('device_name,dtype_name', params)
|
| 80 |
+
elif device_names is not None:
|
| 81 |
+
metafunc.parametrize('device_name', device_names)
|
| 82 |
+
elif dtype_names is not None:
|
| 83 |
+
metafunc.parametrize('dtype_name', dtype_names)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def pytest_addoption(parser):
|
| 87 |
+
parser.addoption('--device', action="store", default="cpu")
|
| 88 |
+
parser.addoption('--dtype', action="store", default="float32")
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@pytest.fixture(autouse=True)
|
| 92 |
+
def add_np(doctest_namespace):
|
| 93 |
+
doctest_namespace["np"] = numpy
|
| 94 |
+
doctest_namespace["torch"] = torch
|
| 95 |
+
doctest_namespace["kornia"] = kornia
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# the commit hash for the data version
|
| 99 |
+
sha: str = 'cb8f42bf28b9f347df6afba5558738f62a11f28a'
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
@pytest.fixture(scope='session')
|
| 103 |
+
def data(request):
|
| 104 |
+
url = {
|
| 105 |
+
'loftr_homo': f'https://github.com/kornia/data_test/blob/{sha}/loftr_outdoor_and_homography_data.pt?raw=true',
|
| 106 |
+
'loftr_fund': f'https://github.com/kornia/data_test/blob/{sha}/loftr_indoor_and_fundamental_data.pt?raw=true',
|
| 107 |
+
}
|
| 108 |
+
return torch.hub.load_state_dict_from_url(url[request.param])
|
docker/Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nvidia/cuda:9.1-cudnn7-devel-ubuntu16.04
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 4 |
+
curl \
|
| 5 |
+
vim \
|
| 6 |
+
ca-certificates &&\
|
| 7 |
+
rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
|
| 10 |
+
chmod +x ~/miniconda.sh && \
|
| 11 |
+
~/miniconda.sh -b -p /opt/conda && \
|
| 12 |
+
rm ~/miniconda.sh && \
|
| 13 |
+
/opt/conda/bin/conda install -y python=$PYTHON_VERSION numpy pyyaml scipy ipython mkl mkl-include cython typing && \
|
| 14 |
+
/opt/conda/bin/conda install -y -c pytorch magma-cuda90 && \
|
| 15 |
+
/opt/conda/bin/conda clean -ya
|
| 16 |
+
ENV PATH /opt/conda/bin:$PATH
|
| 17 |
+
|
| 18 |
+
RUN conda install pytorch torchvision cuda91 -c pytorch
|
docker/Dockerfile.travis
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ubuntu:16.04
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 4 |
+
curl \
|
| 5 |
+
bzip2 \
|
| 6 |
+
build-essential \
|
| 7 |
+
ca-certificates &&\
|
| 8 |
+
rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
COPY . /torchgeometry
|
| 11 |
+
WORKDIR /torchgeometry
|
| 12 |
+
|
| 13 |
+
RUN ./setup_travis_env.sh
|
docker/build.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -ex
|
| 2 |
+
# This script is useful to build the dev_env container.
|
| 3 |
+
script_link="$( readlink "$BASH_SOURCE" )" || script_link="$BASH_SOURCE"
|
| 4 |
+
apparent_sdk_dir="${script_link%/*}"
|
| 5 |
+
if [ "$apparent_sdk_dir" == "$script_link" ]; then
|
| 6 |
+
apparent_sdk_dir=.
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
sdk_dir="$( command cd -P "$apparent_sdk_dir/../" > /dev/null && pwd -P )"
|
| 10 |
+
|
| 11 |
+
# This builds the docker file, from the root of the workspace
|
| 12 |
+
# docker build -t arraiy/torchgeometry -f Dockerfile $sdk_dir
|
| 13 |
+
docker build -t arraiy/torchgeometry -f Dockerfile.travis $sdk_dir
|
docker/tpu-tests/Dockerfile
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM google/cloud-sdk:slim
|
| 2 |
+
|
| 3 |
+
# Build args.
|
| 4 |
+
ARG GITHUB_REF=refs/heads/master
|
| 5 |
+
|
| 6 |
+
# TODO: This Dockerfile installs pytorch/xla 3.6 wheels. There are also 3.7
|
| 7 |
+
# wheels available; see below.
|
| 8 |
+
ARG PYTHON_VERSION=3.6
|
| 9 |
+
|
| 10 |
+
ARG PYTORCH_VERSION=1.7
|
| 11 |
+
|
| 12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
+
build-essential \
|
| 14 |
+
cmake \
|
| 15 |
+
git \
|
| 16 |
+
curl \
|
| 17 |
+
ca-certificates
|
| 18 |
+
|
| 19 |
+
# Install conda and python.
|
| 20 |
+
# NOTE new Conda does not forward the exit status... https://github.com/conda/conda/issues/8385
|
| 21 |
+
RUN curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh && \
|
| 22 |
+
chmod +x ~/miniconda.sh && \
|
| 23 |
+
~/miniconda.sh -b && \
|
| 24 |
+
rm ~/miniconda.sh
|
| 25 |
+
|
| 26 |
+
ENV PATH=/root/miniconda3/bin:$PATH
|
| 27 |
+
|
| 28 |
+
RUN conda create -y --name container python=$PYTHON_VERSION
|
| 29 |
+
|
| 30 |
+
# Run the rest of commands within the new conda env.
|
| 31 |
+
# Use absolute path to appease Codefactor.
|
| 32 |
+
SHELL ["/root/miniconda3/bin/conda", "run", "-n", "container", "/bin/bash", "-c"]
|
| 33 |
+
RUN conda install -y python=$PYTHON_VERSION mkl
|
| 34 |
+
|
| 35 |
+
RUN pip uninstall -y torch && \
|
| 36 |
+
# Python 3.7 wheels are available. Replace cp36-cp36m with cp37-cp37m
|
| 37 |
+
gsutil cp 'gs://tpu-pytorch/wheels/torch-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' . && \
|
| 38 |
+
gsutil cp 'gs://tpu-pytorch/wheels/torch_xla-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' . && \
|
| 39 |
+
pip install 'torch-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
| 40 |
+
pip install 'torch_xla-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
| 41 |
+
rm 'torch-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
| 42 |
+
rm 'torch_xla-${PYTORCH_VERSION}-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
| 43 |
+
apt-get install -y libomp5
|
| 44 |
+
|
| 45 |
+
ENV LD_LIBRARY_PATH=root/miniconda3/envs/container/lib
|
| 46 |
+
|
| 47 |
+
# Install kornia/kornia at the current PR, plus dependencies.
|
| 48 |
+
RUN git clone https://github.com/kornia/kornia.git && \
|
| 49 |
+
cd kornia && \
|
| 50 |
+
git fetch origin $GITHUB_REF:CI && \
|
| 51 |
+
git checkout CI && \
|
| 52 |
+
python setup.py install && \
|
| 53 |
+
pip install pytest
|
| 54 |
+
|
| 55 |
+
RUN conda init bash
|
| 56 |
+
|
| 57 |
+
RUN python -c "import torch; print(torch.__version__)"
|
| 58 |
+
RUN python -c "import torch_xla; print(torch_xla.__version__)"
|
| 59 |
+
RUN python -c "import kornia as K; print(K.__version__)"
|
| 60 |
+
COPY docker-entrypoint.sh /usr/local/bin/
|
| 61 |
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
| 62 |
+
|
| 63 |
+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
| 64 |
+
CMD ["bash"]
|
docker/tpu-tests/docker-entrypoint.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
source ~/.bashrc
|
| 3 |
+
echo "running docker-entrypoint.sh"
|
| 4 |
+
conda activate container
|
| 5 |
+
echo $KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS
|
| 6 |
+
echo "printed TPU info"
|
| 7 |
+
export XRT_TPU_CONFIG="tpu_worker;0;${KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS:7}"
|
| 8 |
+
exec "$@"#!/bin/bash
|
docker/tpu-tests/tpu_test_cases.jsonnet
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
local base = import 'templates/base.libsonnet';
|
| 2 |
+
local tpus = import 'templates/tpus.libsonnet';
|
| 3 |
+
local utils = import "templates/utils.libsonnet";
|
| 4 |
+
|
| 5 |
+
local tputests = base.BaseTest {
|
| 6 |
+
frameworkPrefix: 'kornia',
|
| 7 |
+
modelName: 'tpu-tests',
|
| 8 |
+
mode: 'postsubmit',
|
| 9 |
+
configMaps: [],
|
| 10 |
+
|
| 11 |
+
timeout: 900, # 15 minutes, in seconds.
|
| 12 |
+
|
| 13 |
+
image: std.extVar('image'),
|
| 14 |
+
imageTag: std.extVar('image-tag'),
|
| 15 |
+
|
| 16 |
+
tpuSettings+: {
|
| 17 |
+
softwareVersion: 'pytorch-VERSION',
|
| 18 |
+
},
|
| 19 |
+
accelerator: tpus.v3_8,
|
| 20 |
+
|
| 21 |
+
command: utils.scriptCommand(
|
| 22 |
+
|||
|
| 23 |
+
python -c "import torch; print(torch.__version__)"
|
| 24 |
+
python -c "import torch_xla; print(torch_xla.__version__)"
|
| 25 |
+
python -c "import kornia; print(kornia.__version__)"
|
| 26 |
+
pytest -v kornia/test/color kornia/test/enhance kornia/test/filters kornia/test/test_losses.py --device tpu --dtype float32 -k "not grad"
|
| 27 |
+
test_exit_code=$?
|
| 28 |
+
echo "\nFinished running commands.\n"
|
| 29 |
+
test $test_exit_code -eq 0
|
| 30 |
+
|||
|
| 31 |
+
),
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
tputests.oneshotJob
|
docs/.gitignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
build/doctest
|
| 2 |
+
build/html/.buildinfo
|
| 3 |
+
build/html/objects.inv
|
| 4 |
+
source/tutorials/*
|
| 5 |
+
source/_static/img/*.png
|
docs/Makefile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Minimal makefile for Sphinx documentation
|
| 2 |
+
#
|
| 3 |
+
|
| 4 |
+
# You can set these variables from the command line.
|
| 5 |
+
SPHINXOPTS =
|
| 6 |
+
SPHINXBUILD = sphinx-build
|
| 7 |
+
SPHINXPROJ = kornia
|
| 8 |
+
SOURCEDIR = source
|
| 9 |
+
BUILDDIR = build
|
| 10 |
+
|
| 11 |
+
# Put it first so that "make" without argument is like "make help".
|
| 12 |
+
help:
|
| 13 |
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
| 14 |
+
|
| 15 |
+
.PHONY: help Makefile
|
| 16 |
+
|
| 17 |
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
| 18 |
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
| 19 |
+
%: Makefile
|
| 20 |
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
| 21 |
+
|
| 22 |
+
clean:
|
| 23 |
+
@echo "Removing everything under 'build'.."
|
| 24 |
+
@rm -rf $(BUILDDIR)/html/ $(BUILDDIR)/doctrees
|
| 25 |
+
|
| 26 |
+
images:
|
| 27 |
+
python3 generate_example_images.py
|
docs/generate_example_images.py
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import importlib
|
| 2 |
+
import math
|
| 3 |
+
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from typing import Optional, Tuple
|
| 6 |
+
|
| 7 |
+
import cv2
|
| 8 |
+
import numpy as np
|
| 9 |
+
import requests
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
import kornia as K
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def read_img_from_url(url: str, resize_to: Optional[Tuple[int, int]] = None) -> torch.Tensor:
|
| 16 |
+
# perform request
|
| 17 |
+
response = requests.get(url).content
|
| 18 |
+
# convert to array of ints
|
| 19 |
+
nparr = np.frombuffer(response, np.uint8)
|
| 20 |
+
# convert to image array and resize
|
| 21 |
+
img: np.ndarray = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)[..., :3]
|
| 22 |
+
# convert the image to a tensor
|
| 23 |
+
img_t: torch.Tensor = K.utils.image_to_tensor(img, keepdim=False) # 1xCxHXW
|
| 24 |
+
img_t = img_t.float() / 255.0
|
| 25 |
+
if resize_to is None:
|
| 26 |
+
img_t = K.geometry.resize(img_t, 184)
|
| 27 |
+
else:
|
| 28 |
+
img_t = K.geometry.resize(img_t, resize_to)
|
| 29 |
+
return img_t
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def main():
|
| 33 |
+
# load the images
|
| 34 |
+
BASE_IMAGE_URL1: str = "https://raw.githubusercontent.com/kornia/data/main/panda.jpg" # augmentation
|
| 35 |
+
BASE_IMAGE_URL2: str = "https://raw.githubusercontent.com/kornia/data/main/simba.png" # color
|
| 36 |
+
BASE_IMAGE_URL3: str = "https://raw.githubusercontent.com/kornia/data/main/girona.png" # enhance
|
| 37 |
+
BASE_IMAGE_URL4: str = "https://raw.githubusercontent.com/kornia/data/main/baby_giraffe.png" # morphology
|
| 38 |
+
BASE_IMAGE_URL5: str = "https://raw.githubusercontent.com/kornia/data/main/persistencia_memoria.jpg" # filters
|
| 39 |
+
BASE_IMAGE_URL6: str = "https://raw.githubusercontent.com/kornia/data/main/delorean.png" # geometry
|
| 40 |
+
OUTPUT_PATH = Path(__file__).absolute().parent / "source/_static/img"
|
| 41 |
+
|
| 42 |
+
os.makedirs(OUTPUT_PATH, exist_ok=True)
|
| 43 |
+
print(f"Pointing images to path {OUTPUT_PATH}.")
|
| 44 |
+
img1 = read_img_from_url(BASE_IMAGE_URL1)
|
| 45 |
+
img2 = read_img_from_url(BASE_IMAGE_URL2, img1.shape[-2:])
|
| 46 |
+
img3 = read_img_from_url(BASE_IMAGE_URL3, img1.shape[-2:])
|
| 47 |
+
img4 = read_img_from_url(BASE_IMAGE_URL4)
|
| 48 |
+
img5 = read_img_from_url(BASE_IMAGE_URL5, (234, 320))
|
| 49 |
+
img6 = read_img_from_url(BASE_IMAGE_URL6)
|
| 50 |
+
|
| 51 |
+
# TODO: make this more generic for modules out of kornia.augmentation
|
| 52 |
+
# Dictionary containing the transforms to generate the sample images:
|
| 53 |
+
# Key: Name of the transform class.
|
| 54 |
+
# Value: (parameters, num_samples, seed)
|
| 55 |
+
mod = importlib.import_module("kornia.augmentation")
|
| 56 |
+
augmentations_list: dict = {
|
| 57 |
+
"CenterCrop": ((184, 184), 1, 2018),
|
| 58 |
+
"ColorJitter": ((0.3, 0.3, 0.3, 0.3), 2, 2018),
|
| 59 |
+
"RandomAffine": (((-15.0, 20.0), (0.1, 0.1), (0.7, 1.3), 20), 2, 2019),
|
| 60 |
+
"RandomBoxBlur": (((7, 7),), 1, 2020),
|
| 61 |
+
"RandomCrop": ((img1.shape[-2:], (50, 50)), 2, 2020),
|
| 62 |
+
"RandomChannelShuffle": ((), 1, 2020),
|
| 63 |
+
"RandomElasticTransform": (((63, 63), (32, 32), (2.0, 2.0)), 2, 2018),
|
| 64 |
+
"RandomEqualize": ((), 1, 2020),
|
| 65 |
+
"RandomErasing": (((0.2, 0.4), (0.3, 1 / 0.3)), 2, 2017),
|
| 66 |
+
"RandomFisheye": ((torch.tensor([-0.3, 0.3]), torch.tensor([-0.3, 0.3]), torch.tensor([0.9, 1.0])), 2, 2020),
|
| 67 |
+
"RandomGaussianBlur": (((3, 3), (0.1, 2.0)), 1, 2020),
|
| 68 |
+
"RandomGaussianNoise": ((0.0, 0.05), 1, 2020),
|
| 69 |
+
"RandomGrayscale": ((), 1, 2020),
|
| 70 |
+
"RandomHorizontalFlip": ((), 1, 2020),
|
| 71 |
+
"RandomInvert": ((), 1, 2020),
|
| 72 |
+
"RandomMotionBlur": ((7, 35.0, 0.5), 2, 2020),
|
| 73 |
+
"RandomPerspective": ((0.2,), 2, 2020),
|
| 74 |
+
"RandomPosterize": (((1, 4),), 2, 2016),
|
| 75 |
+
"RandomResizedCrop": ((img1.shape[-2:], (1.0, 2.0), (1.0, 2.0)), 2, 2020),
|
| 76 |
+
"RandomRotation": ((45.0,), 2, 2019),
|
| 77 |
+
"RandomSharpness": ((16.0,), 1, 2019),
|
| 78 |
+
"RandomSolarize": ((0.2, 0.2), 2, 2019),
|
| 79 |
+
"RandomVerticalFlip": ((), 1, 2020),
|
| 80 |
+
"RandomThinPlateSpline": ((), 1, 2020),
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
# ITERATE OVER THE TRANSFORMS
|
| 84 |
+
for aug_name, (args, num_samples, seed) in augmentations_list.items():
|
| 85 |
+
img_in = img1.repeat(num_samples, 1, 1, 1)
|
| 86 |
+
# dynamically create the class instance
|
| 87 |
+
cls = getattr(mod, aug_name)
|
| 88 |
+
aug = cls(*args, p=1.0)
|
| 89 |
+
# set seed
|
| 90 |
+
torch.manual_seed(seed)
|
| 91 |
+
# apply the augmentaiton to the image and concat
|
| 92 |
+
out = aug(img_in)
|
| 93 |
+
|
| 94 |
+
if aug_name == "CenterCrop":
|
| 95 |
+
h, w = img1.shape[-2:]
|
| 96 |
+
h_new, w_new = out.shape[-2:]
|
| 97 |
+
h_dif, w_dif = int(h - h_new), int(w - w_new)
|
| 98 |
+
out = torch.nn.functional.pad(out, (w_dif // 2, w_dif // 2, 0, h_dif))
|
| 99 |
+
|
| 100 |
+
out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 101 |
+
# save the output image
|
| 102 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 103 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{aug_name}.png"), out_np)
|
| 104 |
+
sig = f"{aug_name}({', '.join([str(a) for a in args])}, p=1.0)"
|
| 105 |
+
print(f"Generated image example for {aug_name}. {sig}")
|
| 106 |
+
|
| 107 |
+
mod = importlib.import_module("kornia.augmentation")
|
| 108 |
+
mix_augmentations_list: dict = {
|
| 109 |
+
"RandomMixUp": (((0.3, 0.4),), 2, 20),
|
| 110 |
+
"RandomCutMix": ((img1.shape[-2], img1.shape[-1]), 2, 2019),
|
| 111 |
+
}
|
| 112 |
+
# ITERATE OVER THE TRANSFORMS
|
| 113 |
+
for aug_name, (args, num_samples, seed) in mix_augmentations_list.items():
|
| 114 |
+
img_in = torch.cat([img1, img2])
|
| 115 |
+
# dynamically create the class instance
|
| 116 |
+
cls = getattr(mod, aug_name)
|
| 117 |
+
aug = cls(*args, p=1.0)
|
| 118 |
+
# set seed
|
| 119 |
+
torch.manual_seed(seed)
|
| 120 |
+
# apply the augmentaiton to the image and concat
|
| 121 |
+
out, _ = aug(img_in, torch.tensor([0, 1]))
|
| 122 |
+
out = torch.cat([img_in[0], img_in[1], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 123 |
+
# save the output image
|
| 124 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 125 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{aug_name}.png"), out_np)
|
| 126 |
+
sig = f"{aug_name}({', '.join([str(a) for a in args])}, p=1.0)"
|
| 127 |
+
print(f"Generated image example for {aug_name}. {sig}")
|
| 128 |
+
|
| 129 |
+
mod = importlib.import_module("kornia.color")
|
| 130 |
+
color_transforms_list: dict = {
|
| 131 |
+
"grayscale_to_rgb": ((), 3),
|
| 132 |
+
"rgb_to_bgr": ((), 1),
|
| 133 |
+
"rgb_to_grayscale": ((), 1),
|
| 134 |
+
"rgb_to_hsv": ((), 1),
|
| 135 |
+
"rgb_to_hls": ((), 1),
|
| 136 |
+
"rgb_to_luv": ((), 1),
|
| 137 |
+
"rgb_to_lab": ((), 1),
|
| 138 |
+
# "rgb_to_rgba": ((1.,), 1),
|
| 139 |
+
"rgb_to_xyz": ((), 1),
|
| 140 |
+
"rgb_to_ycbcr": ((), 1),
|
| 141 |
+
"rgb_to_yuv": ((), 1),
|
| 142 |
+
"rgb_to_linear_rgb": ((), 1),
|
| 143 |
+
}
|
| 144 |
+
# ITERATE OVER THE TRANSFORMS
|
| 145 |
+
for fn_name, (args, num_samples) in color_transforms_list.items():
|
| 146 |
+
# import function and apply
|
| 147 |
+
fn = getattr(mod, fn_name)
|
| 148 |
+
if fn_name == "grayscale_to_rgb":
|
| 149 |
+
out = fn(K.color.rgb_to_grayscale(img2), *args)
|
| 150 |
+
else:
|
| 151 |
+
out = fn(img2, *args)
|
| 152 |
+
# perform normalization to visualize
|
| 153 |
+
if fn_name == "rgb_to_lab":
|
| 154 |
+
out = out[:, :1] / 100.0
|
| 155 |
+
elif fn_name == "rgb_to_hsv":
|
| 156 |
+
out[:, :1] = out[:, :1] / 2 * math.pi
|
| 157 |
+
elif fn_name == "rgb_to_luv":
|
| 158 |
+
out = out[:, :1] / 116.0
|
| 159 |
+
# repeat channels for grayscale
|
| 160 |
+
if out.shape[1] != 3:
|
| 161 |
+
out = out.repeat(1, 3, 1, 1)
|
| 162 |
+
# save the output image
|
| 163 |
+
if fn_name == "grayscale_to_rgb":
|
| 164 |
+
out = torch.cat(
|
| 165 |
+
[K.color.rgb_to_grayscale(img2[0]).repeat(3, 1, 1), *(out[i] for i in range(out.size(0)))], dim=-1
|
| 166 |
+
)
|
| 167 |
+
else:
|
| 168 |
+
out = torch.cat([img2[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 169 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 170 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)
|
| 171 |
+
sig = f"{fn_name}({', '.join([str(a) for a in args])})"
|
| 172 |
+
print(f"Generated image example for {fn_name}. {sig}")
|
| 173 |
+
|
| 174 |
+
# korna.enhance module
|
| 175 |
+
mod = importlib.import_module("kornia.enhance")
|
| 176 |
+
transforms: dict = {
|
| 177 |
+
"adjust_brightness": ((torch.tensor([0.25, 0.5]),), 2),
|
| 178 |
+
"adjust_contrast": ((torch.tensor([0.65, 0.5]),), 2),
|
| 179 |
+
"adjust_gamma": ((torch.tensor([0.85, 0.75]), 2.0), 2),
|
| 180 |
+
"adjust_hue": ((torch.tensor([-math.pi / 4, math.pi / 4]),), 2),
|
| 181 |
+
"adjust_saturation": ((torch.tensor([1.0, 2.0]),), 2),
|
| 182 |
+
"solarize": ((torch.tensor([0.8, 0.5]), torch.tensor([-0.25, 0.25])), 2),
|
| 183 |
+
"posterize": ((torch.tensor([4, 2]),), 2),
|
| 184 |
+
"sharpness": ((torch.tensor([1.0, 2.5]),), 2),
|
| 185 |
+
"equalize": ((), 1),
|
| 186 |
+
"invert": ((), 1),
|
| 187 |
+
"equalize_clahe": ((), 1),
|
| 188 |
+
"add_weighted": ((0.75, 0.25, 2.0), 1),
|
| 189 |
+
}
|
| 190 |
+
# ITERATE OVER THE TRANSFORMS
|
| 191 |
+
for fn_name, (args, num_samples) in transforms.items():
|
| 192 |
+
img_in = img3.repeat(num_samples, 1, 1, 1)
|
| 193 |
+
if fn_name == "add_weighted":
|
| 194 |
+
args_in = (img_in, args[0], img2, args[1], args[2])
|
| 195 |
+
else:
|
| 196 |
+
args_in = (img_in, *args)
|
| 197 |
+
# import function and apply
|
| 198 |
+
fn = getattr(mod, fn_name)
|
| 199 |
+
out = fn(*args_in)
|
| 200 |
+
# save the output image
|
| 201 |
+
out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 202 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 203 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)
|
| 204 |
+
sig = f"{fn_name}({', '.join([str(a) for a in args])})"
|
| 205 |
+
print(f"Generated image example for {fn_name}. {sig}")
|
| 206 |
+
|
| 207 |
+
# korna.morphology module
|
| 208 |
+
mod = importlib.import_module("kornia.morphology")
|
| 209 |
+
kernel = torch.tensor([[0, 1, 0], [1, 1, 1], [0, 1, 0]])
|
| 210 |
+
transforms: dict = {
|
| 211 |
+
"dilation": ((kernel,), 1),
|
| 212 |
+
"erosion": ((kernel,), 1),
|
| 213 |
+
"opening": ((kernel,), 1),
|
| 214 |
+
"closing": ((kernel,), 1),
|
| 215 |
+
"gradient": ((kernel,), 1),
|
| 216 |
+
"top_hat": ((kernel,), 1),
|
| 217 |
+
"bottom_hat": ((kernel,), 1),
|
| 218 |
+
}
|
| 219 |
+
# ITERATE OVER THE TRANSFORMS
|
| 220 |
+
for fn_name, (args, num_samples) in transforms.items():
|
| 221 |
+
img_in = img4.repeat(num_samples, 1, 1, 1)
|
| 222 |
+
args_in = (img_in, *args)
|
| 223 |
+
# import function and apply
|
| 224 |
+
# import pdb;pdb.set_trace()
|
| 225 |
+
fn = getattr(mod, fn_name)
|
| 226 |
+
out = fn(*args_in)
|
| 227 |
+
# save the output image
|
| 228 |
+
out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 229 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 230 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)
|
| 231 |
+
sig = f"{fn_name}({', '.join([str(a) for a in args])})"
|
| 232 |
+
print(f"Generated image example for {fn_name}. {sig}")
|
| 233 |
+
|
| 234 |
+
# korna.filters module
|
| 235 |
+
mod = importlib.import_module("kornia.filters")
|
| 236 |
+
kernel = torch.tensor([[0, 1, 0], [1, 1, 1], [0, 1, 0]])
|
| 237 |
+
transforms: dict = {
|
| 238 |
+
"box_blur": (((5, 5),), 1),
|
| 239 |
+
"median_blur": (((5, 5),), 1),
|
| 240 |
+
"gaussian_blur2d": (((5, 5), (1.5, 1.5)), 1),
|
| 241 |
+
"motion_blur": ((5, 90.0, 1.0), 1),
|
| 242 |
+
"max_blur_pool2d": ((5,), 1),
|
| 243 |
+
"blur_pool2d": ((5,), 1),
|
| 244 |
+
"unsharp_mask": (((5, 5), (1.5, 1.5)), 1),
|
| 245 |
+
"laplacian": ((5,), 1),
|
| 246 |
+
"sobel": ((), 1),
|
| 247 |
+
"spatial_gradient": ((), 1),
|
| 248 |
+
"canny": ((), 1),
|
| 249 |
+
}
|
| 250 |
+
# ITERATE OVER THE TRANSFORMS
|
| 251 |
+
for fn_name, (args, num_samples) in transforms.items():
|
| 252 |
+
img_in = img5.repeat(num_samples, 1, 1, 1)
|
| 253 |
+
args_in = (img_in, *args)
|
| 254 |
+
# import function and apply
|
| 255 |
+
fn = getattr(mod, fn_name)
|
| 256 |
+
out = fn(*args_in)
|
| 257 |
+
if fn_name in ("max_blur_pool2d", "blur_pool2d"):
|
| 258 |
+
out = K.geometry.resize(out, img_in.shape[-2:])
|
| 259 |
+
if fn_name == "canny":
|
| 260 |
+
out = out[1].repeat(1, 3, 1, 1)
|
| 261 |
+
if isinstance(out, torch.Tensor):
|
| 262 |
+
out = out.clamp(min=0.0, max=1.0)
|
| 263 |
+
if fn_name in ("laplacian", "sobel", "spatial_gradient", "canny"):
|
| 264 |
+
out = K.enhance.normalize_min_max(out)
|
| 265 |
+
if fn_name == "spatial_gradient":
|
| 266 |
+
out = out.permute(2, 1, 0, 3, 4).squeeze()
|
| 267 |
+
# save the output image
|
| 268 |
+
out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 269 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 270 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)
|
| 271 |
+
sig = f"{fn_name}({', '.join([str(a) for a in args])})"
|
| 272 |
+
print(f"Generated image example for {fn_name}. {sig}")
|
| 273 |
+
|
| 274 |
+
# korna.geometry.transform module
|
| 275 |
+
mod = importlib.import_module("kornia.geometry.transform")
|
| 276 |
+
h, w = img6.shape[-2:]
|
| 277 |
+
|
| 278 |
+
def _get_tps_args():
|
| 279 |
+
src = torch.tensor([[[-1.0, -1.0], [-1.0, 1.0], [1.0, -1.0], [1.0, -1.0], [0.0, 0.0]]]).repeat(2, 1, 1) # Bx5x2
|
| 280 |
+
dst = src + torch.distributions.Uniform(-0.2, 0.2).rsample((2, 5, 2))
|
| 281 |
+
kernel, affine = K.geometry.transform.get_tps_transform(dst, src)
|
| 282 |
+
return src, kernel, affine
|
| 283 |
+
|
| 284 |
+
transforms: dict = {
|
| 285 |
+
"warp_affine": (
|
| 286 |
+
(
|
| 287 |
+
K.geometry.transform.get_affine_matrix2d(
|
| 288 |
+
translations=torch.zeros(2, 2),
|
| 289 |
+
center=(torch.tensor([w, h]) / 2).repeat(2, 1),
|
| 290 |
+
scale=torch.distributions.Uniform(0.5, 1.5).rsample((2, 2)),
|
| 291 |
+
angle=torch.tensor([-25.0, 25.0]),
|
| 292 |
+
)[:, :2, :3],
|
| 293 |
+
(h, w),
|
| 294 |
+
),
|
| 295 |
+
2,
|
| 296 |
+
),
|
| 297 |
+
"remap": (
|
| 298 |
+
(
|
| 299 |
+
*(K.utils.create_meshgrid(h, w, normalized_coordinates=True) - 0.25).unbind(-1),
|
| 300 |
+
'bilinear',
|
| 301 |
+
'zeros',
|
| 302 |
+
True,
|
| 303 |
+
True,
|
| 304 |
+
),
|
| 305 |
+
1,
|
| 306 |
+
),
|
| 307 |
+
"warp_image_tps": ((_get_tps_args()), 2),
|
| 308 |
+
"rotate": ((torch.tensor([-15.0, 25.0]),), 2),
|
| 309 |
+
"translate": ((torch.tensor([[10.0, -15], [50.0, -25.0]]),), 2),
|
| 310 |
+
"scale": ((torch.tensor([[0.5, 1.25], [1.0, 1.5]]),), 2),
|
| 311 |
+
"shear": ((torch.tensor([[0.1, -0.2], [-0.2, 0.1]]),), 2),
|
| 312 |
+
"rot180": ((), 1),
|
| 313 |
+
"hflip": ((), 1),
|
| 314 |
+
"vflip": ((), 1),
|
| 315 |
+
"resize": (((120, 220),), 1),
|
| 316 |
+
"rescale": ((0.5,), 1),
|
| 317 |
+
"elastic_transform2d": ((torch.rand(1, 2, h, w) * 2 - 1, (63, 63), (32, 32), (4.0, 4.0)), 1),
|
| 318 |
+
"pyrdown": ((), 1),
|
| 319 |
+
"pyrup": ((), 1),
|
| 320 |
+
"build_pyramid": ((3,), 1),
|
| 321 |
+
}
|
| 322 |
+
# ITERATE OVER THE TRANSFORMS
|
| 323 |
+
for fn_name, (args, num_samples) in transforms.items():
|
| 324 |
+
img_in = img6.repeat(num_samples, 1, 1, 1)
|
| 325 |
+
args_in = (img_in, *args)
|
| 326 |
+
# import function and apply
|
| 327 |
+
fn = getattr(mod, fn_name)
|
| 328 |
+
out = fn(*args_in)
|
| 329 |
+
if fn_name in ("resize", "rescale", "pyrdown", "pyrup"):
|
| 330 |
+
h_new, w_new = out.shape[-2:]
|
| 331 |
+
out = torch.nn.functional.pad(out, (0, (w - w_new), 0, (h - h_new)))
|
| 332 |
+
if fn_name == "build_pyramid":
|
| 333 |
+
_out = []
|
| 334 |
+
for pyr in out[1:]:
|
| 335 |
+
h_new, w_new = pyr.shape[-2:]
|
| 336 |
+
out_tmp = torch.nn.functional.pad(pyr, (0, (w - w_new), 0, (h - h_new)))
|
| 337 |
+
_out.append(out_tmp)
|
| 338 |
+
out = torch.cat(_out)
|
| 339 |
+
# save the output image
|
| 340 |
+
out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)
|
| 341 |
+
out_np = K.utils.tensor_to_image((out * 255.0).byte())
|
| 342 |
+
cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)
|
| 343 |
+
sig = f"{fn_name}({', '.join([str(a) for a in args])})"
|
| 344 |
+
print(f"Generated image example for {fn_name}. {sig}")
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
if __name__ == "__main__":
|
| 348 |
+
main()
|
docs/requirements.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs requirements
|
| 2 |
+
torch
|
| 3 |
+
torchvision
|
| 4 |
+
opencv-python
|
| 5 |
+
matplotlib
|
| 6 |
+
# sphinx
|
| 7 |
+
sphinx>=4.0
|
| 8 |
+
sphinx_rtd_theme>0.5
|
| 9 |
+
sphinxcontrib-bibtex
|
| 10 |
+
sphinxcontrib-youtube
|
| 11 |
+
sphinx-autodoc-typehints>=1.0
|
| 12 |
+
sphinx-copybutton>=0.3
|
| 13 |
+
sphinx-autodoc-defaultargs
|
| 14 |
+
PyYAML>=5.1,<6.1.0
|
| 15 |
+
furo
|
| 16 |
+
sphinx-design
|
docs/source/_extra/googlef1b16a85a18694bd.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
google-site-verification: googlef1b16a85a18694bd.html
|