From 86bbcf2bb34c7e515628dfc62bfeb2e62879dd05 Mon Sep 17 00:00:00 2001 From: Kaiyuan Hu Date: Wed, 8 Dec 2021 15:27:28 +0800 Subject: [PATCH] update unittest --- .gitignore | 209 +++++++++++++++++++++++++++++++ image_embedding_resnet50.yaml | 5 +- test_image_embedding_resnet50.py | 12 +- 3 files changed, 217 insertions(+), 9 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..32030ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,209 @@ +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# 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 + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__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/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk \ No newline at end of file diff --git a/image_embedding_resnet50.yaml b/image_embedding_resnet50.yaml index 18474e2..3ed4a1f 100644 --- a/image_embedding_resnet50.yaml +++ b/image_embedding_resnet50.yaml @@ -16,7 +16,7 @@ operators: type: map - name: 'preprocessing' - function: 'towhee/transform-image' # same as 'transform-image', default author is towhee + function: 'towhee/transform-image' # default author is towhee tag: 'main' # optional init_args: size: 256 @@ -48,8 +48,7 @@ operators: type: map - name: '_end_op' - function: - name: '_end_op' + function: '_end_op' init_args: inputs: - diff --git a/test_image_embedding_resnet50.py b/test_image_embedding_resnet50.py index cb90524..8ffe627 100644 --- a/test_image_embedding_resnet50.py +++ b/test_image_embedding_resnet50.py @@ -1,17 +1,17 @@ +import os import unittest from towhee import pipeline from PIL import Image class TestImageEmbeddingResnet50(unittest.TestCase): - test_img = './test_data/test.jpg' - test_img = Image.open(test_img) - def test_image_embedding_resnet50(self): - self.dimension = 1000 + img_src = './test_data/test.jpg' + test_img = Image.open(img_src) + dimension = 1000 embedding_pipeline = pipeline('towhee/image-embedding-resnet50') - embedding = embedding_pipeline(self.test_img) - assert (1, self.dimension) == op(img_tensor)[0].shape + embedding = embedding_pipeline(test_img) + self.assertEqual((1, dimension), embedding[0][0].shape) if __name__ == '__main__':