semiautomaticgit / SemiAutomaticClassificationPlugin

https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html
Other
137 stars 50 forks source link

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #24

Closed naoliv closed 6 years ago

naoliv commented 6 years ago

I am unsure what exactly is the problem here. QGIS is 2.14.19, gdal is 2.2.1 and python-numpy is 1.13.1:

2017-09-23T16:33:06 1   Traceback (most recent call last):
              File "/home/naoliv/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/classificationdock/classificationdock.py", line 520, in runClassificationAction
                self.runClassification()
              File "/home/naoliv/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/classificationdock/classificationdock.py", line 599, in runClassification
                ok, opOut, mOut = self.runAlgorithm(cfg.algName, img, sL, cfg.clssPth, cfg.macroclassCheck, None, None, None, compress)
              File "/home/naoliv/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/classificationdock/classificationdock.py", line 450, in runAlgorithm
                o = cfg.utls.processRaster(rD, bL, signatureList, None, cfg.utls.classification, algorithmName, oRL, oMR[0], oCR[0], previewSize, previewPoint, cfg.NoDataVal, macroclassCheck, cfg.multiAddFactorsVar, cfg.bndSetMultAddFactorsList)
              File "/home/naoliv/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/core/utils.py", line 3791, in processRaster
                o = functionRaster(gdalBandList, signatureList, algorithmName, c, bSX, bSY, x, y, outputRasterList, outputAlgorithmRaster, outputClassificationRaster, nodataValue, macroclassCheck, previewSize, pX[lX.index(x)], pY[lY.index(y)], progressStart, progresStep, remainingBlocks, progressMessage)
              File "/home/naoliv/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/core/utils.py", line 1150, in classification
                if classArray == None:
            ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I can do tests and try to give you more info if needed.

semiautomaticgit commented 6 years ago

Thank you for reporting this. Please follow these steps and copy the SCP Log file http://semiautomaticclassificationmanual-v5.readthedocs.io/en/latest/faq.html#how-can-i-report-an-error

naoliv commented 6 years ago

scp-log.txt Tell me if you need more information or tests, please. Thank you!

semiautomaticgit commented 6 years ago

Thank you. I don't see any particular error. Possibly the issue is related to the image or to the operating system. Please try using this image https://docs.google.com/uc?id=0BysUrKXWIDwBNEtudThrcWlERDg

naoliv commented 6 years ago

Hi! Unfortunatelly I see the same problem with the sample image. I loaded it in QGIS, created a new training input (in the SCP input part) Then in ROI creation (at Classification dock) I traced 3 test polygons. While trying to see the preview or trying to run the classification I see the error from the first message.

Will it help if I record a video of what exactly I am doing? Thank you!

semiautomaticgit commented 6 years ago

I think the issue is related to the operating system. You can try to uninstall QGIS and install it again following this http://semiautomaticclassificationmanual-v5.readthedocs.io/en/latest/installation_ubuntu.html

naoliv commented 6 years ago

I can't run it on two different Debian machines. But using a live Ubuntu image it works.

One difference that I saw is that Debian has python-numpy 1.13.1, while Ubuntu has it at version 1.12 I will see if I can compile a local version of python-numpy 1.13.3 (the latest version) and see if this error persists.

naoliv commented 6 years ago

With python-numpy 1.13.3 the same error happens. I need to see if I can spot anything else different.

semiautomaticgit commented 6 years ago

Thank you for your feedback. Considering that it is a dependency issue I'm going to close this. Of course feel free to reopen it if you have news

naoliv commented 6 years ago

Sure. I will let you know about any news about this. Thank you very much for your attention!

Mapjotr commented 6 years ago

Hi Naoliv, have you been able to solve this issue? I ran into exactly the same one and can not get it to work. I tried the stuff suggested above... without success. I use QGIS 2.18.14 and numpy 1.13.3 on Ubuntu 16.04.3. Thank you!

Mapjotr commented 6 years ago

I used the sample image from https://docs.google.com/uc?id=0BysUrKXWIDwBNEtudThrcWlERDg Here are my log and error files: error_messsage.txt log_file.txt

naoliv commented 6 years ago

Unfortunately I wasn't able to solve it :-/ I guess that it can be related with python-numpy 1.13 (since an Ubuntu with python-numpy 1.12 seems to work without any problems)

Mapjotr commented 6 years ago

Thanks for your quick reply! Indeed, it seems an issue related to Numpy 1.13. I installed python-numpy 1.12 and it all worked fine!

naoliv commented 6 years ago

@semiautomaticgit I was reading https://github.com/SheffieldML/GPyOpt/issues/96#issuecomment-308329094 and it seems that constructions like this

if X != None: (or if X == None:)

should be updated to something like this for the new numpy:

if X is not None: (or if X is None:)

semiautomaticgit commented 6 years ago

Thank you for your feedback. I'll look into it

sh-slg commented 6 years ago

It really helped me... (if X is None) instead of (X == None). It is working now. Thank you