diff --git a/README.md b/README.md index 4be5c69..6191061 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,40 @@ The above will save each image class in a separate subdirectory under the base directory, with images in a subdirectory named "images" and the PASCAL VOC format annotations in a subdirectory named "pascal". +## Resize images +In order to resize images and update the associated annotations use the script +`cvdata/resize.py`. This script currently supports annotations in KITTI (*.txt) +and PASCAL VOC (*.xml) formats. For example to resize images to 1024x768 and +update the associated annotations in KITTI format: +```bash +$ python resize.py --input_images /ssd_training/kitti/image_2 \ + --input_annotations /ssd_training/kitti/label_2 \ + --output_images /ssd_training/kitti/image_2 \ + --output_annotations /ssd_training/kitti/label_2 \ + --width 1024 --height 768 --format kitti +``` + +## Convert annotation formats +In order to convert from one annotation format to another use the script +`cvdata/convert.py`. This script currently supports converting annotations from +PASCAL to KITTI formats. For example: +```bash +$ python convert.py --in_format pascal --out_format kitti \ + --annotations_dir /data/handgun/pascal \ + --images_dir /data/handgun/images \ + --out_dir /data/handgun/kitti \ + --kitti_ids_file handgun.txt +``` + ## Rename annotation labels In order to rename the image class labels of annotations use the script -`cvdata/visualize.py`. This script currently supports annotations in KITTI (*.txt) +`cvdata/rename.py`. This script currently supports annotations in KITTI (*.txt) and PASCAL VOC (*.xml) formats. It is used to replace the label name for all annotation files of the specified format in the specified directory. For example: ```bash $ python rename.py --labels_dir /data/cvdata/pascal --old handgun --new firearm --format pascal ``` + ## Visualize annotations In order to visualize images and corresponding annotations use the script `cvdata/visualize.py`. This script currently supports annotations in COCO (*.json), diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..43bbf47 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,30 @@ +boto3==1.10.28 +botocore==1.13.28 +certifi==2019.9.11 +chardet==3.0.4 +docutils==0.15.2 +filelock==3.0.10 +idna==2.8 +importlib-metadata==0.23 +jmespath==0.9.4 +lxml==4.4.2 +more-itertools==7.2.0 +numpy==1.17.4 +opencv-python==4.1.2.30 +packaging==19.2 +pandas==0.25.3 +Pillow==6.2.1 +pluggy==0.12.0 +py==1.8.0 +pyparsing==2.4.5 +python-dateutil==2.8.0 +pytz==2019.3 +requests==2.22.0 +s3transfer==0.2.1 +six==1.13.0 +toml==0.10.0 +tox==3.14.1 +tqdm==4.39.0 +urllib3==1.25.7 +virtualenv==16.7.5 +zipp==0.6.0 diff --git a/setup.py b/setup.py index 14c6d36..ce77f86 100644 --- a/setup.py +++ b/setup.py @@ -8,14 +8,14 @@ setuptools.setup( name="cvdata", - version="0.0.1", + version="0.0.2", author="James Adams", author_email="monocongo@gmail.com", description="Tools for creating and manipulating computer vision datasets", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/monocongo/cvdata", - python_requires=">=3.0, <3.8", + python_requires=">=3.0", packages=[ "cvdata", ], @@ -30,15 +30,11 @@ "boto3", "lxml", "numpy", - "opencv-contrib-python-nonfree", + "opencv-python", + # "opencv-contrib-python-nonfree", "pandas", "pillow", "requests", "tqdm", ], - tests_require=[ - "opencv", - "pytest", - "scikit-image", - ] ) diff --git a/tests/assert_utils.py b/tests/assert_utils.py index 81cd951..0a2c2e3 100644 --- a/tests/assert_utils.py +++ b/tests/assert_utils.py @@ -1,10 +1,8 @@ -import cv2 -# scikit-image version <0.16 -from skimage.measure import compare_mse as mean_squared_error -# scikit-image version >=0.16 -# from skimage.metrics import mean_squared_error from xml.etree import ElementTree +import cv2 +from skimage.metrics import mean_squared_error + # ------------------------------------------------------------------------------ def elements_equal(e1, e2) -> bool: diff --git a/tests/test_clean.py b/tests/test_clean.py index f4e1486..4f24da7 100644 --- a/tests/test_clean.py +++ b/tests/test_clean.py @@ -1,15 +1,10 @@ import logging import os -import cv2 import pytest -# scikit-image version <0.16 -from skimage.measure import compare_mse as mean_squared_error -# scikit-image version >=0.16 -# from skimage.metrics import mean_squared_error from cvdata import clean -from tests.assert_utils import images_equal, xml_equal +from assert_utils import images_equal, xml_equal # ------------------------------------------------------------------------------ # disable logging messages diff --git a/tests/test_convert.py b/tests/test_convert.py index 4409c33..51350b0 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -9,7 +9,7 @@ # from skimage.metrics import mean_squared_error from cvdata import convert -from tests.assert_utils import images_equal +from assert_utils import images_equal # ------------------------------------------------------------------------------ diff --git a/tests/test_relabel.py b/tests/test_relabel.py index b76a7bb..6366b83 100644 --- a/tests/test_relabel.py +++ b/tests/test_relabel.py @@ -4,7 +4,7 @@ import pytest from cvdata import relabel -from tests.assert_utils import elements_equal, text_files_equal +from assert_utils import elements_equal, text_files_equal # ------------------------------------------------------------------------------ # disable logging messages diff --git a/tests/test_resize.py b/tests/test_resize.py index c02a947..2d15a50 100644 --- a/tests/test_resize.py +++ b/tests/test_resize.py @@ -6,7 +6,7 @@ import pytest from cvdata import resize -from tests.assert_utils import text_files_equal, xml_equal +from assert_utils import text_files_equal, xml_equal # ------------------------------------------------------------------------------ # disable logging messages diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b9a7b4c --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py3 + +[testenv] +deps = opencv-python + pytest + scikit-image +commands = pytest