logo
Browse Source

update unittest

main
Kaiyuan Hu 3 years ago
parent
commit
86bbcf2bb3
  1. 209
      .gitignore
  2. 5
      image_embedding_resnet50.yaml
  3. 12
      test_image_embedding_resnet50.py

209
.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

5
image_embedding_resnet50.yaml

@ -16,7 +16,7 @@ operators:
type: map type: map
- -
name: 'preprocessing' 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 tag: 'main' # optional
init_args: init_args:
size: 256 size: 256
@ -48,8 +48,7 @@ operators:
type: map type: map
- -
name: '_end_op' name: '_end_op'
function:
name: '_end_op'
function: '_end_op'
init_args: init_args:
inputs: inputs:
- -

12
test_image_embedding_resnet50.py

@ -1,17 +1,17 @@
import os
import unittest import unittest
from towhee import pipeline from towhee import pipeline
from PIL import Image from PIL import Image
class TestImageEmbeddingResnet50(unittest.TestCase): class TestImageEmbeddingResnet50(unittest.TestCase):
test_img = './test_data/test.jpg'
test_img = Image.open(test_img)
def test_image_embedding_resnet50(self): 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_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__': if __name__ == '__main__':

Loading…
Cancel
Save