piyushghai commented on a change in pull request #14503: API to create RecordIO
files
URL: https://github.com/apache/incubator-mxnet/pull/14503#discussion_r273237078
##########
File path: tests/python/unittest/test_io.py
##########
@@ -556,6 +556,70 @@ def assert_dataiter_items_not_equals(dataiter1,
dataiter2):
assert_dataiter_items_equals(dataiter1, dataiter2)
+def test_im2rec():
+ if not os.path.isdir("data/test_im2rec/"):
+ os.makedirs('data/test_im2rec/')
+ tar_filename = download('http://data.mxnet.io/data/test_images.tar.gz',
+ dirname='data/test_im2rec/')
+ with tarfile.open(tar_filename, "r:gz") as gf:
+ gf.extractall("data/test_im2rec/")
+ filenames = next(os.walk("data/test_im2rec/test_images"))[2]
+ filenames =
[os.path.abspath(os.path.join("data/test_im2rec/test_images",i))
+ for i in filenames]
+ # creating list file from test image data
+ lst_filename = os.path.abspath("data/test_im2rec/img.lst")
+ output_path = os.path.abspath("data/test_im2rec/")
+ with open(lst_filename, 'w') as img_lst:
+ for i,fpath in enumerate(filenames):
+ img_lst.write(str(i) + "\t" + str(i) + "\t" + fpath + "\n")
+
+ def test_validate_params():
+ try:
+ mx.io.im2rec._validate_params("notafile", output_path)
+ assert False, "Invalid list file"
+ except ValueError:
+ assert True
+ try:
+ mx.io.im2rec._validate_params(lst_filename, "notafolder")
+ assert False, "Invalid output folder"
+ except ValueError:
+ assert True
+ try:
+ mx.io.im2rec._validate_params(lst_filename, output_path, color=3)
+ assert False, "Invalid color value"
+ except ValueError:
+ assert True
+ try:
+ mx.io.im2rec._validate_params(lst_filename, output_path,
encoding='abc')
+ assert False, "Invalid encoding"
+ except ValueError:
+ assert True
+ try:
+ mx.io.im2rec._validate_params(lst_filename, output_path,
quality='abc')
+ assert False, "Quality should be an int value"
+ except ValueError:
+ assert True
+
+ def test_read_worker():
+ try:
+ try:
+ import Queue as queue
+ except ImportError:
+ import queue as queue
+ q_out = queue.PriorityQueue(5)
+ img_path =
"/home/ubuntu/im2rec/unit_test/data/test_im2rec/test_images/ILSVRC2012_val_00000007.JPEG"
Review comment:
Can you use os.path.abspath here rather than hardcoding the ```img_path```
here ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services