Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for testing with tox #40

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
30 changes: 30 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
12 changes: 4 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand All @@ -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",
]
)
8 changes: 3 additions & 5 deletions tests/assert_utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 1 addition & 6 deletions tests/test_clean.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/test_relabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tox]
envlist = py3

[testenv]
deps = opencv-python
pytest
scikit-image
commands = pytest