-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
AssertionError install tests for 0.2.9 build on NixOS #414
Comments
|
The first and second test are now a little bit looser in master and should run through. The |
Thanks. I will align my code to these changes and test. |
Hi @aleju , pytest: error: unrecognized arguments: --xdoctest
|
What command are you executing? I assume it contains |
Hi @aleju , initially i was just using pytest command. now I have modified the ### But now it is stuck after 79% `running install tests test/test_dtypes.py .................................................... [ 1%] ` Please suggest. Thanks. |
I usually use the command I can't tell exactly where it hangs as there is no corresponding output. Even if there was, it would probably be hard to debug it from the distance. |
Hi @aleju , Please find last output of imgaug unit test.
Please note that we donot have support for xdoctest on NixOS at present so I am removing Thanks. |
Hm, I thought that command showed the name of test currently being executed, but apparently it does so only after the test has fully run through. It also doesn't follow the order in which the tests were defined in the file. That makes things a bit harder. At least I can see that it fails at I would try now for aug in augs:
nb_changed = 0 to for aug in augs:
print(aug.name)
nb_changed = 0 and then run the above Step 1: iaa.Lambda(
func_images=lambda images, random_state, parents, hooks: images,
func_keypoints=lambda keypoints_on_images, random_state,
parents, hooks: keypoints_on_images,
name="Lambda-nochange"
),
iaa.AssertLambda(
func_images=lambda images, random_state, parents, hooks: True,
func_keypoints=lambda keypoints_on_images, random_state,
parents, hooks: True,
name="AssertLambda-nochange"
), from the test. Lambda functions can sometimes cause problems in connections with multiprocessing. Try the Step 2: Step 3: Btw, how long do you wait for the test to finish? It does take a few seconds on my machine. |
Hi @aleju , I have taken latest 0.3.0 changes. As per my observation the execution order is alphabetic here. Yes, it is I mean if try to run
I had waited for more than 1 hour and test is still stuck. Please suggest. Thanks. |
Hi @aleju , Another input in case it helps: I had tried to run all files under augmenters in two orders: Original Order : Hang on test_augment_batches_with_many_different_augmenters
test_meta.py moved to front: PASS
Result with test_meta.py moved to front: Thanks. |
Yes, that is way beyond the expected timeframe. On my machine it takes a few seconds. On a slow laptop maybe 30s. The observed hanging is very weird. Among all test files, I think only Some things I would do here to pinpoint the problem:
|
I have now seen similar behaviour. In my case it was caused by an exception in a subprocess that for some reason was not raised into the main process, even though Can you copy-paste the following code block into a file, run it and post the output. If it hangs again, import six.moves as sm
import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
for background in [False, True]:
image = np.array([[0, 0, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 1, 1, 1, 1]], dtype=np.uint8)
keypoint = ia.Keypoint(x=2, y=1)
keypoints = [ia.KeypointsOnImage([keypoint], shape=image.shape + (1,))]
def _lambda_func_images(images, random_state, parents, hooks):
return images
def _lambda_func_keypoints(keypoints_on_images, random_state,
parents, hooks):
return keypoints_on_images
def _assertlambda_func_images(images, random_state, parents, hooks):
return True
def _assertlambda_func_keypoints(keypoints_on_images, random_state, parents, hooks):
return True
augs = [
iaa.Sequential([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.SomeOf(1, [iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.OneOf([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.Sometimes(1.0, iaa.Fliplr(1)),
iaa.WithColorspace("HSV", children=iaa.Add((-50, 50))),
iaa.WithChannels([0], iaa.Add((-50, 50))),
iaa.Noop(name="Noop-nochange"),
iaa.Lambda(
func_images=_lambda_func_images,
func_keypoints=_lambda_func_keypoints,
name="Lambda-nochange"
),
iaa.AssertLambda(
func_images=_assertlambda_func_images,
func_keypoints=_assertlambda_func_keypoints,
name="AssertLambda-nochange"
),
iaa.AssertShape(
(None, 64, 64, 3),
check_keypoints=False,
name="AssertShape-nochange"
),
iaa.Resize((0.5, 0.9)),
iaa.CropAndPad(px=(-50, 50)),
iaa.Pad(px=(1, 50)),
iaa.Crop(px=(1, 50)),
iaa.Fliplr(1.0),
iaa.Flipud(1.0),
iaa.Superpixels(p_replace=(0.25, 1.0), n_segments=(16, 128)),
iaa.ChangeColorspace(to_colorspace="GRAY"),
iaa.Grayscale(alpha=(0.1, 1.0)),
iaa.GaussianBlur(1.0),
iaa.AverageBlur(5),
iaa.MedianBlur(5),
iaa.Convolve(np.array([[0, 1, 0],
[1, -4, 1],
[0, 1, 0]])),
iaa.Sharpen(alpha=(0.1, 1.0), lightness=(0.8, 1.2)),
iaa.Emboss(alpha=(0.1, 1.0), strength=(0.8, 1.2)),
iaa.EdgeDetect(alpha=(0.1, 1.0)),
iaa.DirectedEdgeDetect(alpha=(0.1, 1.0), direction=(0.0, 1.0)),
iaa.Add((-50, 50)),
iaa.AddElementwise((-50, 50)),
iaa.AdditiveGaussianNoise(scale=(0.1, 1.0)),
iaa.Multiply((0.6, 1.4)),
iaa.MultiplyElementwise((0.6, 1.4)),
iaa.Dropout((0.3, 0.5)),
iaa.CoarseDropout((0.3, 0.5), size_percent=(0.05, 0.2)),
iaa.Invert(0.5),
iaa.Affine(
scale=(0.7, 1.3),
translate_percent=(-0.1, 0.1),
rotate=(-20, 20),
shear=(-20, 20),
order=ia.ALL,
mode=ia.ALL,
cval=(0, 255)),
iaa.PiecewiseAffine(scale=(0.1, 0.3)),
iaa.ElasticTransformation(alpha=0.5)
]
nb_iterations = 100
image = ia.quokka(size=(64, 64))
batches = [ia.Batch(images=[np.copy(image)],
keypoints=[keypoints[0].deepcopy()])
for _ in sm.xrange(nb_iterations)]
for aug in augs:
print("[bg=%s] Running %s..." % (background, aug.name))
nb_changed = 0
batches_aug = list(aug.augment_batches(batches, background=background))
for batch_aug in batches_aug:
image_aug = batch_aug.images_aug[0]
if (image.shape != image_aug.shape
or not np.array_equal(image, image_aug)):
nb_changed += 1
if nb_changed > 10:
break
if "-nochange" not in aug.name:
assert nb_changed > 0
else:
assert nb_changed == 0 |
Hi @aleju , For me it is stuck at : Thanks. |
@aleju Any news on this? |
Sorry, didn't have much time the last couple of days, so this issue was delayed a bit. I have seen something like that before and it was fixed using With import six.moves as sm
import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
import os
import platform
import cv2
cv2.setNumThreads(0)
print(os.name)
print(platform.system())
print(platform.release())
for iteration, background in enumerate([False, False, False,
True, True, True]):
image = np.array([[0, 0, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 1, 1, 1, 1]], dtype=np.uint8)
keypoint = ia.Keypoint(x=2, y=1)
keypoints = [ia.KeypointsOnImage([keypoint], shape=image.shape + (1,))]
def _lambda_func_images(images, random_state, parents, hooks):
return images
def _lambda_func_keypoints(keypoints_on_images, random_state,
parents, hooks):
return keypoints_on_images
def _assertlambda_func_images(images, random_state, parents, hooks):
return True
def _assertlambda_func_keypoints(keypoints_on_images, random_state, parents, hooks):
return True
augs = [
iaa.Sequential([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.SomeOf(1, [iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.OneOf([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.Sometimes(1.0, iaa.Fliplr(1)),
iaa.WithColorspace("HSV", children=iaa.Add((-50, 50))),
iaa.WithChannels([0], iaa.Add((-50, 50))),
iaa.Noop(name="Noop-nochange"),
iaa.Lambda(
func_images=_lambda_func_images,
func_keypoints=_lambda_func_keypoints,
name="Lambda-nochange"
),
iaa.AssertLambda(
func_images=_assertlambda_func_images,
func_keypoints=_assertlambda_func_keypoints,
name="AssertLambda-nochange"
),
iaa.AssertShape(
(None, 64, 64, 3),
check_keypoints=False,
name="AssertShape-nochange"
),
iaa.Resize((0.5, 0.9)),
iaa.CropAndPad(px=(-50, 50)),
iaa.Pad(px=(1, 50)),
iaa.Crop(px=(1, 50)),
iaa.Fliplr(1.0),
iaa.Flipud(1.0),
iaa.Superpixels(p_replace=(0.25, 1.0), n_segments=(16, 128)),
iaa.ChangeColorspace(to_colorspace="GRAY"),
iaa.Grayscale(alpha=(0.1, 1.0)),
iaa.GaussianBlur(1.0),
iaa.AverageBlur(5),
iaa.MedianBlur(5),
iaa.Convolve(np.array([[0, 1, 0],
[1, -4, 1],
[0, 1, 0]])),
iaa.Sharpen(alpha=(0.1, 1.0), lightness=(0.8, 1.2)),
iaa.Emboss(alpha=(0.1, 1.0), strength=(0.8, 1.2)),
iaa.EdgeDetect(alpha=(0.1, 1.0)),
iaa.DirectedEdgeDetect(alpha=(0.1, 1.0), direction=(0.0, 1.0)),
iaa.Add((-50, 50)),
iaa.AddElementwise((-50, 50)),
iaa.AdditiveGaussianNoise(scale=(0.1, 1.0)),
iaa.Multiply((0.6, 1.4)),
iaa.MultiplyElementwise((0.6, 1.4)),
iaa.Dropout((0.3, 0.5)),
iaa.CoarseDropout((0.3, 0.5), size_percent=(0.05, 0.2)),
iaa.Invert(0.5),
iaa.Affine(
scale=(0.7, 1.3),
translate_percent=(-0.1, 0.1),
rotate=(-20, 20),
shear=(-20, 20),
order=ia.ALL,
mode=ia.ALL,
cval=(0, 255)),
iaa.PiecewiseAffine(scale=(0.1, 0.3)),
iaa.ElasticTransformation(alpha=0.5)
]
nb_iterations = 100
image = ia.quokka(size=(64, 64))
batches = [ia.Batch(images=[np.copy(image)],
keypoints=[keypoints[0].deepcopy()])
for _ in sm.xrange(nb_iterations)]
for aug in augs:
print("[#%d bg=%s] Running %s..." % (iteration, background, aug.name))
nb_changed = 0
batches_aug = list(aug.augment_batches(batches, background=background))
for batch_aug in batches_aug:
image_aug = batch_aug.images_aug[0]
if (image.shape != image_aug.shape
or not np.array_equal(image, image_aug)):
nb_changed += 1
if nb_changed > 10:
break
if "-nochange" not in aug.name:
assert nb_changed > 0
else:
assert nb_changed == 0 With import six.moves as sm
import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
import os
import platform
import multiprocessing
def main():
print(os.name)
print(platform.system())
print(platform.release())
multiprocessing.set_start_method("spawn")
for iteration, background in enumerate([False, False, False,
True, True, True]):
image = np.array([[0, 0, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 1, 1, 1, 1]], dtype=np.uint8)
keypoint = ia.Keypoint(x=2, y=1)
keypoints = [ia.KeypointsOnImage([keypoint], shape=image.shape + (1,))]
augs = [
iaa.Sequential([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.SomeOf(1, [iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.OneOf([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.Sometimes(1.0, iaa.Fliplr(1)),
iaa.WithColorspace("HSV", children=iaa.Add((-50, 50))),
iaa.WithChannels([0], iaa.Add((-50, 50))),
iaa.Noop(name="Noop-nochange"),
iaa.Lambda(
func_images=_lambda_func_images,
func_keypoints=_lambda_func_keypoints,
name="Lambda-nochange"
),
#iaa.AssertLambda(
# func_images=_assertlambda_func_images,
# func_keypoints=_assertlambda_func_keypoints,
# name="AssertLambda-nochange"
#),
#iaa.AssertShape(
# (None, 64, 64, 3),
# check_keypoints=False,
# name="AssertShape-nochange"
#),
iaa.Resize((0.5, 0.9)),
iaa.CropAndPad(px=(-50, 50)),
iaa.Pad(px=(1, 50)),
iaa.Crop(px=(1, 50)),
iaa.Fliplr(1.0),
iaa.Flipud(1.0),
iaa.Superpixels(p_replace=(0.25, 1.0), n_segments=(16, 128)),
iaa.ChangeColorspace(to_colorspace="GRAY"),
iaa.Grayscale(alpha=(0.1, 1.0)),
iaa.GaussianBlur(1.0),
iaa.AverageBlur(5),
iaa.MedianBlur(5),
iaa.Convolve(np.array([[0, 1, 0],
[1, -4, 1],
[0, 1, 0]])),
iaa.Sharpen(alpha=(0.1, 1.0), lightness=(0.8, 1.2)),
iaa.Emboss(alpha=(0.1, 1.0), strength=(0.8, 1.2)),
iaa.EdgeDetect(alpha=(0.1, 1.0)),
iaa.DirectedEdgeDetect(alpha=(0.1, 1.0), direction=(0.0, 1.0)),
iaa.Add((-50, 50)),
iaa.AddElementwise((-50, 50)),
iaa.AdditiveGaussianNoise(scale=(0.1, 1.0)),
iaa.Multiply((0.6, 1.4)),
iaa.MultiplyElementwise((0.6, 1.4)),
iaa.Dropout((0.3, 0.5)),
iaa.CoarseDropout((0.3, 0.5), size_percent=(0.05, 0.2)),
iaa.Invert(0.5),
iaa.Affine(
scale=(0.7, 1.3),
translate_percent=(-0.1, 0.1),
rotate=(-20, 20),
shear=(-20, 20),
order=ia.ALL,
mode=ia.ALL,
cval=(0, 255)),
iaa.PiecewiseAffine(scale=(0.1, 0.3)),
iaa.ElasticTransformation(alpha=0.5)
]
nb_iterations = 100
image = ia.quokka(size=(64, 64))
batches = [ia.Batch(images=[np.copy(image)],
keypoints=[keypoints[0].deepcopy()])
for _ in sm.xrange(nb_iterations)]
for aug in augs:
print("[#%d bg=%s] Running %s..." % (iteration, background, aug.name))
nb_changed = 0
batches_aug = list(aug.augment_batches(batches, background=background))
for batch_aug in batches_aug:
image_aug = batch_aug.images_aug[0]
if (image.shape != image_aug.shape
or not np.array_equal(image, image_aug)):
nb_changed += 1
if nb_changed > 10:
break
if "-nochange" not in aug.name:
assert nb_changed > 0
else:
assert nb_changed == 0
def _lambda_func_images(images, random_state, parents, hooks):
return images
def _lambda_func_keypoints(keypoints_on_images, random_state,
parents, hooks):
return keypoints_on_images
def _assertlambda_func_images(images, random_state, parents, hooks):
return True
def _assertlambda_func_keypoints(keypoints_on_images, random_state, parents, hooks):
return True
if __name__ == "__main__":
main() |
Thanks @aleju , I will update you after trying the above mentioned changes. |
Hi @aleju , Please find attached the output of above two executions (Block1 and Block2). Block1 was stuck, but Block2 ran without any issues. block1_debug_output.txt Also i did not get anything after pressing ctrl+c in my environment. Thanks, |
Hi @aleju , Did you a get a chance to look into this? Thanks. |
Yes... but as far as I can see, while the second set of tests ran through, it doesn't seem like the library can identify that it is running in NixOS and then conditionally use The first set of tests further hang at a different augmenter this time than previously and that augmenter does not use OpenCV but instead scikit-image. It might be that scikit-image uses OpenCV in the background, but I didn't see it when looking through the code. That makes it fairly unlikely that it is an OpenCV issue and more likely that it is a problem or slight behaviour change in the Basically I will have to install the OS on an old laptop and see if I can find the issue and fix it in a way that other systems are not affected. That's fairly time intensive and has a high risk of no succeeding, which is why I postponed that so far. |
Hi @aleju , Thanks. |
FYI, we are successfully using imgaug on NixOS environments with no problems. It's just the tests here failing. |
Only the tests involving
Do you mean patching NixOS or a fork of imgaug? I had hoped that |
@aleju thanks for all the help to the NixOS community! Really appreciate your efforts. Just chiming in that
|
Ah, didn't know about This adjusted test might work then and shouldn't break anything for other OS: import six.moves as sm
import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
import os
import platform
import multiprocessing
def main():
print(os.name)
print(platform.system())
print(platform.release())
print(platform.version())
if "NixOS" in platform.version():
multiprocessing.set_start_method("spawn")
for iteration, background in enumerate([False, False, False,
True, True, True]):
image = np.array([[0, 0, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 1, 1, 1, 1]], dtype=np.uint8)
keypoint = ia.Keypoint(x=2, y=1)
keypoints = [ia.KeypointsOnImage([keypoint], shape=image.shape + (1,))]
augs = [
iaa.Sequential([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.SomeOf(1, [iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.OneOf([iaa.Fliplr(1.0), iaa.Flipud(1.0)]),
iaa.Sometimes(1.0, iaa.Fliplr(1)),
iaa.WithColorspace("HSV", children=iaa.Add((-50, 50))),
iaa.WithChannels([0], iaa.Add((-50, 50))),
iaa.Noop(name="Noop-nochange"),
iaa.Lambda(
func_images=_lambda_func_images,
func_keypoints=_lambda_func_keypoints,
name="Lambda-nochange"
),
#iaa.AssertLambda(
# func_images=_assertlambda_func_images,
# func_keypoints=_assertlambda_func_keypoints,
# name="AssertLambda-nochange"
#),
#iaa.AssertShape(
# (None, 64, 64, 3),
# check_keypoints=False,
# name="AssertShape-nochange"
#),
iaa.Resize((0.5, 0.9)),
iaa.CropAndPad(px=(-50, 50)),
iaa.Pad(px=(1, 50)),
iaa.Crop(px=(1, 50)),
iaa.Fliplr(1.0),
iaa.Flipud(1.0),
iaa.Superpixels(p_replace=(0.25, 1.0), n_segments=(16, 128)),
iaa.ChangeColorspace(to_colorspace="GRAY"),
iaa.Grayscale(alpha=(0.1, 1.0)),
iaa.GaussianBlur(1.0),
iaa.AverageBlur(5),
iaa.MedianBlur(5),
iaa.Convolve(np.array([[0, 1, 0],
[1, -4, 1],
[0, 1, 0]])),
iaa.Sharpen(alpha=(0.1, 1.0), lightness=(0.8, 1.2)),
iaa.Emboss(alpha=(0.1, 1.0), strength=(0.8, 1.2)),
iaa.EdgeDetect(alpha=(0.1, 1.0)),
iaa.DirectedEdgeDetect(alpha=(0.1, 1.0), direction=(0.0, 1.0)),
iaa.Add((-50, 50)),
iaa.AddElementwise((-50, 50)),
iaa.AdditiveGaussianNoise(scale=(0.1, 1.0)),
iaa.Multiply((0.6, 1.4)),
iaa.MultiplyElementwise((0.6, 1.4)),
iaa.Dropout((0.3, 0.5)),
iaa.CoarseDropout((0.3, 0.5), size_percent=(0.05, 0.2)),
iaa.Invert(0.5),
iaa.Affine(
scale=(0.7, 1.3),
translate_percent=(-0.1, 0.1),
rotate=(-20, 20),
shear=(-20, 20),
order=ia.ALL,
mode=ia.ALL,
cval=(0, 255)),
iaa.PiecewiseAffine(scale=(0.1, 0.3)),
iaa.ElasticTransformation(alpha=0.5)
]
nb_iterations = 100
image = ia.quokka(size=(64, 64))
batches = [ia.Batch(images=[np.copy(image)],
keypoints=[keypoints[0].deepcopy()])
for _ in sm.xrange(nb_iterations)]
for aug in augs:
print("[#%d bg=%s] Running %s..." % (iteration, background, aug.name))
nb_changed = 0
batches_aug = list(aug.augment_batches(batches, background=background))
for batch_aug in batches_aug:
image_aug = batch_aug.images_aug[0]
if (image.shape != image_aug.shape
or not np.array_equal(image, image_aug)):
nb_changed += 1
if nb_changed > 10:
break
if "-nochange" not in aug.name:
assert nb_changed > 0
else:
assert nb_changed == 0
def _lambda_func_images(images, random_state, parents, hooks):
return images
def _lambda_func_keypoints(keypoints_on_images, random_state,
parents, hooks):
return keypoints_on_images
def _assertlambda_func_images(images, random_state, parents, hooks):
return True
def _assertlambda_func_keypoints(keypoints_on_images, random_state, parents, hooks):
return True
if __name__ == "__main__":
main() |
I have tried the code snippet shared above. This works fine without any issues on my system.
|
I just merged a patch into master that hopefully fixes the issue. Can you check if the tests run successfully with that version? |
Thanks. @aleju . I will check and update the outcome. |
Thanks @aleju . Tests are executed without any issues on this version. |
Hi @aleju , sorry for inconvenience. But last time when i reported there was some problem on my branch that caused weird behaviour. The current state is from master: When the tests started we get this error:
I locally patched this with following two changes:
After this change hang issue has disappeared for augmenter tests. I have attached the detailed error as attachment img_aug_erros.txt.
|
Seems like #526 should help this along? Shall we retest? |
Hi @CMCDragonkai, @aleju , Tested the changes on my system with 5c2fa03 on #526 ,
Local patches not needed anymore for:
Thanks. |
Thanks @aleju , finally with this fix imgaug is building on NixOS with all the test case passing.
|
That's good to hear. I merged the patch to master. |
Nixos fix is now merged to upstream. Closing this issue. Thanks again @aleju |
Hi Team,
I was trying to enable the test cases for pythonPackages.imgaug NixOS/nixpkgs#67494
During this process i am able to execute the test cases but facing AssertionError and this is causing 5 failures.
Summary of test run:
============ **5 failed, 383 passed, 3 warnings in 199.71s (0:03:19)** =============
detailed log :
imgaug_test_failures.txt
Please suggest. Thanks.
The text was updated successfully, but these errors were encountered: