Skip to content

Commit

Permalink
Auto sort imports (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe authored Oct 11, 2023
1 parent 754726e commit 7426bc7
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 63 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E203
exclude = .git,__pycache__,build,.venv/
22 changes: 8 additions & 14 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@ on:
pull_request:
types: [ assigned, opened, synchronize, reopened ]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
jupyter: true
linting-check:
name: Linting Check
check:
name: Format and Lint Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: '3.10'
cache: 'pip'
- run: python -m pip install --upgrade pip
- run: python -m pip install .
- run: python -m pip install --upgrade flake8
- run: python -m flake8 . --exclude build/
- run: python -m pip install .[dev]
- run: python -m flake8 .
- run: python -m isort . --check-only --diff
- run: python -m black . --check --diff
167 changes: 161 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,166 @@
/build/
*.egg-info
*.pyc
/.idea/
/data/
/outputs/
__pycache__
/lightglue/weights/
lightglue/_flash/
*-checkpoint.ipynb
*.pth

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
9 changes: 5 additions & 4 deletions benchmark.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Benchmark script for LightGlue on real images
from pathlib import Path
import argparse
import matplotlib.pyplot as plt
from collections import defaultdict
import time
from collections import defaultdict
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import torch
import torch._dynamo

from lightglue import LightGlue, SuperPoint
from lightglue.utils import load_image
import torch._dynamo

torch.set_grad_enabled(False)

Expand Down
2 changes: 1 addition & 1 deletion lightglue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .disk import DISK # noqa
from .lightglue import LightGlue # noqa
from .superpoint import SuperPoint # noqa
from .disk import DISK # noqa
from .utils import match_pair # noqa
6 changes: 4 additions & 2 deletions lightglue/disk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from types import SimpleNamespace

import kornia
import torch
import torch.nn as nn
import kornia
from types import SimpleNamespace

from .utils import ImagePreprocessor


Expand Down
7 changes: 4 additions & 3 deletions lightglue/lightglue.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import warnings
from pathlib import Path
from types import SimpleNamespace
import warnings
from typing import Callable, List, Optional, Tuple

import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from typing import Optional, List, Callable, Tuple
from torch import nn

try:
from flash_attn.modules.mha import FlashCrossAttention
Expand Down
1 change: 1 addition & 0 deletions lightglue/superpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import torch
from torch import nn

from .utils import ImagePreprocessor


Expand Down
11 changes: 6 additions & 5 deletions lightglue/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import collections.abc as collections
from pathlib import Path
import torch
import kornia
from types import SimpleNamespace
from typing import Callable, List, Optional, Tuple, Union

import cv2
import kornia
import numpy as np
from typing import Union, List, Optional, Callable, Tuple
import collections.abc as collections
from types import SimpleNamespace
import torch


class ImagePreprocessor:
Expand Down
2 changes: 1 addition & 1 deletion lightglue/viz2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"""

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
import matplotlib.pyplot as plt
import numpy as np
import torch

Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[project]
name = "lightglue"
description = "LightGlue: Local Feature Matching at Light Speed"
version = "0.0"
authors = [
{name = "Philipp Lindenberger"},
{name = "Paul-Edouard Sarlin"},
]
readme = "README.md"
requires-python = ">=3.6"
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
urls = {Repository = "https://github.com/cvg/LightGlue/"}
dynamic = ["dependencies"]

[project.optional-dependencies]
dev = ["black", "flake8", "isort"]

[tool.setuptools]
packages = ["lightglue"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.isort]
profile = "black"
27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

0 comments on commit 7426bc7

Please sign in to comment.