-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 155989e
Showing
32 changed files
with
17,658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__pycache__ | ||
build | ||
lanms_nova.egg-info | ||
.idea | ||
venv | ||
dist |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Include the license file | ||
include LICENSE | ||
|
||
# Include cpp source files and Makefile | ||
include src/lanmslib.cpp | ||
include src/lanmslib.h | ||
include src/Makefile | ||
|
||
|
||
include src/include/clipper/clipper.h | ||
include src/include/clipper/clipper.cpp | ||
include src/include/pybind11/stl_bind.h | ||
include src/include/pybind11/embed.h | ||
include src/include/pybind11/attr.h | ||
include src/include/pybind11/class_support.h | ||
include src/include/pybind11/pytypes.h | ||
include src/include/pybind11/complex.h | ||
include src/include/pybind11/operators.h | ||
include src/include/pybind11/eval.h | ||
include src/include/pybind11/pybind11.h | ||
include src/include/pybind11/descr.h | ||
include src/include/pybind11/eigen.h | ||
include src/include/pybind11/buffer_info.h | ||
include src/include/pybind11/chrono.h | ||
include src/include/pybind11/options.h | ||
include src/include/pybind11/common.h | ||
include src/include/pybind11/cast.h | ||
include src/include/pybind11/numpy.h | ||
include src/include/pybind11/typeid.h | ||
include src/include/pybind11/functional.h | ||
include src/include/pybind11/stl.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Locality-Aware Non-Maximum Suppression (LANMS) | ||
|
||
This is a python binding for LANMS as described by Zhout et al. | ||
in their paper "EAST: An Efficient and Accurate Scene Text Detector", CVPR 2017. The C++ code is taken from the | ||
implementation available on: https://github.com/argman/EAST | ||
|
||
### Installation | ||
|
||
`pip install lanms-nova` | ||
|
||
### Usage example | ||
```python | ||
import numpy as np | ||
import lanms | ||
|
||
boxes = np.array([ | ||
[137.0, 113.6, 162.3, 113.3, 162.4, 122.2, 137.2, 122.6, 0.75], | ||
[137.2, 113.8, 163.2, 114.6, 163.0, 122.6, 137.0, 121.9, 0.97], | ||
[136.8, 113.4, 163.2, 114.5, 162.9, 122.7, 136.5, 121.6, 0.15], | ||
[136.6, 112.9, 163.3, 114.5, 162.8, 122.9, 136.1, 121.3, 0.95], | ||
[136.4, 112.6, 163.4, 114.5, 162.8, 123.0, 135.8, 121.2, 0.96], | ||
[131.4, 89.2, 137.8, 89.0, 138.2, 98.5, 131.8, 98.7, 0.98], | ||
[131.6, 89.2, 137.8, 89.1, 138.1, 98.6, 131.8, 98.8, 0.32], | ||
[131.5, 89.2, 137.9, 89.1, 138.0, 98.6, 131.6, 98.7, 0.99], | ||
[131.5, 89.2, 138.0, 89.1, 138.1, 98.5, 131.6, 98.5, 0.87], | ||
[131.5, 89.3, 137.8, 89.0, 138.2, 98.4, 132.0, 98.7, 0.97] | ||
], dtype=np.float32) | ||
|
||
boxes = lanms.merge_quadrangle_n9(boxes, nms_thresh=0.5) | ||
print(boxes) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import numpy as np | ||
|
||
from .lanmslib import merge_quadrangle_n9 as nms_impl | ||
|
||
|
||
def merge_quadrangle_n9(polys: np.ndarray, nms_thresh: float = 0.3, precision: int = 10000) -> np.ndarray: | ||
if len(polys) == 0: | ||
return np.array([], dtype='float32') | ||
|
||
p = polys.copy() | ||
p[:, :8] *= precision | ||
ret = np.array(nms_impl(p, nms_thresh), dtype='float32') | ||
ret[:, :8] /= precision | ||
|
||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file=README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
from setuptools import setup, Extension | ||
|
||
|
||
setup( | ||
name="lanms-nova", | ||
version="1.0.1", | ||
author="Andranik Sargsyan", | ||
author_email="[email protected]", | ||
description="lanms-nova is a python binding for LANMS - Locality-Aware Non-Max Suppression", | ||
install_requires=["numpy"], | ||
long_description_content_type="text/markdown", | ||
long_description=open("README.md").read(), | ||
packages=["lanms"], | ||
include_package_data=True, | ||
ext_modules=[ | ||
Extension( | ||
name="lanms.lanmslib", | ||
sources=[ | ||
os.path.join("src", "lanmslib.cpp"), | ||
os.path.join("src", "include", "clipper", "clipper.cpp") | ||
], | ||
include_dirs=[os.path.join("src", "include")], | ||
language="c++", | ||
undef_macros=["NDEBUG"], | ||
), | ||
], | ||
zip_safe=False, | ||
license="GPL", | ||
keywords=["NMS", "LANMS"], | ||
url="https://github.com/AndranikSargsyan/lanms-nova", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CXXFLAGS = -I include -std=c++11 -O3 $(shell python3.8-config --cflags) | ||
LDFLAGS = $(shell python3.8-config --ldflags) | ||
|
||
DEPS = lanmslib.h $(shell find include -xtype f) | ||
CXX_SOURCES = lanmslib.cpp include/clipper/clipper.cpp | ||
|
||
LIB_SO = build/lanmslib.so | ||
|
||
$(LIB_SO): $(CXX_SOURCES) $(DEPS) | ||
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC | ||
|
||
clean: | ||
rm -rf $(LIB_SO) |
Oops, something went wrong.