aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.34k stars 2.43k forks source link

AttributeError: module 'imgaug' has no attribute 'SegmentationMapOnImage' #208

Open azmathmoosa opened 5 years ago

azmathmoosa commented 5 years ago

I tried to run this code given in the documentation,

import imgaug as ia
from imgaug import augmenters as iaa
import imageio
import numpy as np

ia.seed(1)

# Load an example image (uint8, 128x128x3).
image = ia.quokka(size=(128, 128), extract="square")

# Create an example segmentation map (int32, 128x128).
# Here, we just randomly place some squares on the image.
# Class 0 is the background class.
segmap = np.zeros((128, 128), dtype=np.int32)
segmap[28:71, 35:85] = 1
segmap[10:25, 30:45] = 2
segmap[10:25, 70:85] = 3
segmap[10:110, 5:10] = 4
segmap[118:123, 10:110] = 5
segmap = ia.SegmentationMapOnImage(segmap, shape=image.shape, nb_classes=1+5)

It fails at the last line with

>>> segmap = ia.SegmentationMapOnImage(segmap, shape=image.shape, nb_classes=1+5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'imgaug' has no attribute 'SegmentationMapOnImage'
>>> exit()

I tried installing using pip and pip+git but both versions are 0.2.6 and have this issue.

Any suggestions?

i7p9h9 commented 5 years ago

Have the same problem

aleju commented 5 years ago

Try pip uninstall imgaug && pip install git+https://github.com/aleju/imgaug.git and make sure that there are no errors. Then run

import numpy as np
import imgaug as ia
segmap = ia.SegmentationMapOnImage(np.zeros((3, 3, 1), dtype=np.int32), shape=(3, 3, 3), nb_classes=1+5)

That code should then run -- at least it just worked for me with the latest version from github.

i7p9h9 commented 5 years ago

Try pip uninstall imgaug && pip install git+https://github.com/aleju/imgaug.git and make sure that there are no errors. Then run

import numpy as np
import imgaug as ia
segmap = ia.SegmentationMapOnImage(np.zeros((3, 3, 1), dtype=np.int32), shape=(3, 3, 3), nb_classes=1+5)

That code should then run -- at least it just worked for me with the latest version from github.

All work correctly, if i install from source, but when i install by pip - z i get this error.

aleju commented 5 years ago

The version on pypi is a bit outdated and doesn't contain segmentation maps yet.

orsveri commented 5 years ago

I had this issue too, but simple reinstalling with pip helped. Looks like the version on pypi isn't outdated anymore.

YeahYo17 commented 4 years ago

This problem I think is because of change of imgaug 'segmap.py' code. The SegmentationMapOnImage changes to SegmentationMapsOnImage. Only adds the 's' letter to 'Map'.

https://github.com/aleju/imgaug/blob/c268d368f9caeb46d8df4fe73f8f7c988c97dcba/imgaug/augmentables/segmaps.py#L24

SegmentationMapOnImage class without 's' don't exists.