diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..27d07d7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.py text=auto eol=lf +*.bat eol=crlf diff --git a/DECIMER/__init__.py b/DECIMER/__init__.py index fc0f4e8..b480a37 100644 --- a/DECIMER/__init__.py +++ b/DECIMER/__init__.py @@ -1,29 +1,29 @@ -# -*- coding: utf-8 -*- -"""DECIMER V2.6.0 Python Package. ============================ - -This repository contains DECIMER-V2,Deep lEarning for Chemical ImagE Recognition) project -was launched to address the OCSR problem with the latest computational intelligence methods -to provide an automated open-source software solution. - - -Typical usage example: - -from decimer import predict_SMILES - -# Chemical depiction to SMILES translation -image_path = "path/to/imagefile" -SMILES = predict_SMILES(image_path) -print(SMILES) - -For comments, bug reports or feature ideas, -please raise a issue on the Github repository. -""" - -__version__ = "2.6.0" - -__all__ = [ - "DECIMER", -] - - -from .decimer import predict_SMILES +# -*- coding: utf-8 -*- +"""DECIMER V2.6.0 Python Package. ============================ + +This repository contains DECIMER-V2,Deep lEarning for Chemical ImagE Recognition) project +was launched to address the OCSR problem with the latest computational intelligence methods +to provide an automated open-source software solution. + + +Typical usage example: + +from decimer import predict_SMILES + +# Chemical depiction to SMILES translation +image_path = "path/to/imagefile" +SMILES = predict_SMILES(image_path) +print(SMILES) + +For comments, bug reports or feature ideas, +please raise a issue on the Github repository. +""" + +__version__ = "2.6.0" + +__all__ = [ + "DECIMER", +] + + +from .decimer import predict_SMILES diff --git a/DECIMER/decimer.py b/DECIMER/decimer.py index 482ef5e..e81cf95 100644 --- a/DECIMER/decimer.py +++ b/DECIMER/decimer.py @@ -117,7 +117,7 @@ def detokenize_output_add_confidence( decoded_prediction_with_confidence = list( [(utils.decoder(tok), conf) for tok, conf in prediction_with_confidence_] ) - decoded_prediction_with_confidence.append(prediction_with_confidence_[-1]) + return decoded_prediction_with_confidence diff --git a/DECIMER/utils.py b/DECIMER/utils.py index f5a07e1..003eb4b 100644 --- a/DECIMER/utils.py +++ b/DECIMER/utils.py @@ -83,11 +83,10 @@ def ensure_models(default_path: str, model_urls: dict) -> dict: } for model_name, model_url in model_urls.items(): model_path = os.path.join(default_path, f"{model_name}_model") - if ( - os.path.exists(model_path) - and os.stat(os.path.join(model_path, "saved_model.pb")).st_size != model_sizes.get(model_name) - ): - print(f'Working with model {model_name}') + if os.path.exists(model_path) and os.stat( + os.path.join(model_path, "saved_model.pb") + ).st_size != model_sizes.get(model_name): + print(f"Working with model {model_name}") shutil.rmtree(model_path) config.download_trained_weights(model_url, default_path) elif not os.path.exists(model_path): diff --git a/docs/make.bat b/docs/make.bat index 32bb245..954237b 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,35 +1,35 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/setup.py b/setup.py index b5d30cb..ec77ff8 100644 --- a/setup.py +++ b/setup.py @@ -1,55 +1,55 @@ -#!/usr/bin/env python -import platform - -import setuptools - -if ( - platform.processor() == "arm" or platform.processor() == "i386" -) and platform.system() == "Darwin": - tensorflow_os = "tensorflow-macos>=2.10.0,<=2.15.0" -else: - tensorflow_os = "tensorflow>=2.12.0,<=2.15.0" - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="decimer", - version="2.6.0", - author="Kohulan Rajan", - author_email="kohulan.rajan@uni-jena.de", - maintainer="Kohulan Rajan, Otto Brinkhaus ", - maintainer_email="kohulan.rajan@uni-jena.de, otto.brinkhaus@uni-jena.de", - description="DECIMER 2.6.0: Deep Learning for Chemical Image Recognition using Efficient-Net V2 + Transformer", - long_description=long_description, - long_description_content_type="text/markdown", - entry_points={ - "console_scripts": ["decimer = DECIMER.decimer:main"], - }, - url="https://github.com/Kohulan/DECIMER-Image_Transformer", - packages=setuptools.find_packages(), - license="MIT", - install_requires=[ - tensorflow_os, - "opencv-python", - "pystow", - "pillow-heif", - "efficientnet", - "selfies", - "pyyaml", - ], - package_data={"DECIMER": ["repack/*.*", "efficientnetv2/*.*", "Utils/*.*"]}, - classifiers=[ - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3 :: Only", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires=">=3.5", -) +#!/usr/bin/env python +import platform + +import setuptools + +if ( + platform.processor() == "arm" or platform.processor() == "i386" +) and platform.system() == "Darwin": + tensorflow_os = "tensorflow-macos>=2.10.0,<=2.15.0" +else: + tensorflow_os = "tensorflow>=2.12.0,<=2.15.0" + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="decimer", + version="2.6.0", + author="Kohulan Rajan", + author_email="kohulan.rajan@uni-jena.de", + maintainer="Kohulan Rajan, Otto Brinkhaus ", + maintainer_email="kohulan.rajan@uni-jena.de, otto.brinkhaus@uni-jena.de", + description="DECIMER 2.6.0: Deep Learning for Chemical Image Recognition using Efficient-Net V2 + Transformer", + long_description=long_description, + long_description_content_type="text/markdown", + entry_points={ + "console_scripts": ["decimer = DECIMER.decimer:main"], + }, + url="https://github.com/Kohulan/DECIMER-Image_Transformer", + packages=setuptools.find_packages(), + license="MIT", + install_requires=[ + tensorflow_os, + "opencv-python", + "pystow", + "pillow-heif", + "efficientnet", + "selfies", + "pyyaml", + ], + package_data={"DECIMER": ["repack/*.*", "efficientnetv2/*.*", "Utils/*.*"]}, + classifiers=[ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires=">=3.5", +)