semiautomaticgit/SemiAutomaticClassificationPlugin

SCP: error in supervised classification

JoseRascon opened this issue · 9 comments

Hello, I get the following error when running a supervised classification (I'm trying to make a model and I can't)
Traceback (most recent call last):
File "C:\Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\interface\classification_tab.py", line 148, in save_classifier_action
output = run_classifier(save_classifier=True)
File "C:\Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\interface\classification_tab.py", line 487, in run_classifier
if output is None:
UnboundLocalError: local variable 'output' referenced before assignment

Just in case I also put the error that I get from the application in report error
INFO|2024-03-04T14:47:24.010|system_tools|get_system_info|38|system: Windows; 64bit: True; n_processes: 2; ram: 10; temp.dir: C:\Users\jrassan\AppData\Local\Temp\remotior_sensus_0304trf64cdn
INFO|2024-03-04T14:48:26.408|bandset_catalog|create|744|start
ERROR|2024-03-04T14:48:26.415|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-04T14:48:26.419|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-04T14:48:26.423|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-04T14:48:26.430|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
INFO|2024-03-04T14:48:26.430|bandset_catalog|create|927|end; file list: ['D:/AlgoritmoClasificado/Mayo2020.tif']
INFO|2024-03-04T14:48:38.596|scp_dock|open_signature_catalog_file|2465|open_signature_catalog_file: D:/AlgoritmoClasificado/Training.scpx
INFO|2024-03-04T14:49:03.413|classification_tab|run_classifier|193|run_classifier: D:/AlgoritmoClasificado/Modelo.rsmo.tif
INFO|2024-03-04T14:49:03.440|band_classification|band_classification|1235|start
ERROR|2024-03-04T14:49:16.633|classification_tab|run_classifier|485|boolean index did not match indexed array along dimension 0; dimension is 21261 but corresponding boolean dimension is 15
INFO|2024-03-04T14:50:25.505|session|set|405|n_processes: 2; ram: 10; temp.dir: C:\Users\jrassan\AppData\Local\Temp\remotior_sensus_0304trf64cdn

Hello @JoseRascon ,
it seems an issue related to input data.
You may try to split bands using this tool https://semiautomaticclassificationmanual.readthedocs.io/en/latest/split_bands_tab.html and then create a new band set.

Thanks for the help, I have tried separating the bands and joining them again as you told me and the same error continues to appear

I attach what I get when trying with another raster
Ha ocurrido un error mientras se ejecutaba el código de Python:

UnboundLocalError: local variable 'output' referenced before assignment
Traceback (most recent call last):
File "C:\Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\interface\classification_tab.py", line 148, in save_classifier_action
output = run_classifier(save_classifier=True)
File "C:\Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\interface\classification_tab.py", line 487, in run_classifier
if output is None:
UnboundLocalError: local variable 'output' referenced before assignment

Versión de Python: 3.9.18 (heads/master:c290dc6, Jan 14 2024, 01:36:02) [MSC v.1929 64 bit (AMD64)]
Versión de QGIS: 3.34.3-Prizren Prizren, 47373234ac

Ruta de Python:
C:\Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools
C:/PROGRA1/QGIS331.3/apps/qgis/./python
C:/Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA1/QGIS331.3/apps/qgis/./python/plugins
C:\PROGRA1\QGIS331.3\apps\grass\grass83\etc\python
C:\Users\jrassan\Documents
C:\Program Files\QGIS 3.34.3\bin\python39.zip
C:\PROGRA1\QGIS331.3\apps\Python39\DLLs
C:\PROGRA1\QGIS331.3\apps\Python39\lib
C:\Program Files\QGIS 3.34.3\bin
C:\Users\jrassan\AppData\Roaming\Python\Python39\site-packages
C:\PROGRA1\QGIS331.3\apps\Python39
C:\PROGRA1\QGIS331.3\apps\Python39\lib\site-packages
C:\PROGRA1\QGIS331.3\apps\Python39\lib\site-packages\win32
C:\PROGRA1\QGIS331.3\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA1\QGIS331.3\apps\Python39\lib\site-packages\Pythonwin
C:/Users/jrassan/AppData/Roaming/QGIS/QGIS3\profiles\default/python

Hello, what images are you using?

Also, please copy the log file as described here (from the creation of the band set)
https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#how-can-i-report-an-error

Hello, I am using Sentinel-2 images corrected without clouds processed in Google Engine (I have tried with normal Sentinel 2 images in case that was the error and nothing)
I copy the entire error as you have indicated.

INFO|2024-03-11T12:34:06.419|system_tools|get_system_info|38|system: Windows; 64bit: True; n_processes: 2; ram: 10; temp.dir: C:\Users\jrassan\AppData\Local\Temp\remotior_sensus_0311bm7vybo2
INFO|2024-03-11T12:35:25.510|bandset_catalog|create|744|start
ERROR|2024-03-11T12:35:25.563|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:35:25.579|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:35:25.595|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:35:25.595|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
INFO|2024-03-11T12:35:25.595|bandset_catalog|create|927|end; file list: ['D:/AlgoritmoClasificado/Mayo2020.tif']
INFO|2024-03-11T12:36:30.922|split_bands_tab|split_raster_to_bands|52|split_raster_to_bands: D:/AlgoritmoClasificado
INFO|2024-03-11T12:36:30.954|raster_split|raster_split|70|start
INFO|2024-03-11T12:46:55.470|raster_split|raster_split|116|end; raster split: ['D:/AlgoritmoClasificado/split1.tif', 'D:/AlgoritmoClasificado/split2.tif', 'D:/AlgoritmoClasificado/split3.tif', 'D:/AlgoritmoClasificado/split4.tif']
INFO|2024-03-11T12:47:27.662|bandset_catalog|create|744|start
ERROR|2024-03-11T12:47:27.691|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:47:27.695|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:47:27.699|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:47:27.704|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
INFO|2024-03-11T12:47:27.704|bandset_catalog|create|927|end; file list: ['D:/AlgoritmoClasificado/split1.tif', 'D:/AlgoritmoClasificado/split2.tif', 'D:/AlgoritmoClasificado/split3.tif', 'D:/AlgoritmoClasificado/split4.tif']
INFO|2024-03-11T12:47:37.018|bandset_tab|bandset_tools|785|bandset_tools: D:/AlgoritmoClasificado
INFO|2024-03-11T12:52:16.781|bandset_catalog|create|744|start
ERROR|2024-03-11T12:52:16.781|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:52:16.797|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:52:16.797|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
ERROR|2024-03-11T12:52:16.797|table_manager|create_band_table|1186|Python int too large to convert to C long; nodata: -9.223372036854776e+18
INFO|2024-03-11T12:52:16.797|bandset_catalog|create|927|end; file list: ['D:/AlgoritmoClasificado/spli_stack_raster.tif']
INFO|2024-03-11T12:52:56.393|scp_dock|open_signature_catalog_file|2465|open_signature_catalog_file: D:/AlgoritmoClasificado/Training.scpx
INFO|2024-03-11T12:53:45.141|classification_tab|run_classifier|193|run_classifier: D:/AlgoritmoClasificado/SCPModel.rsmo.tif
INFO|2024-03-11T12:53:45.172|band_classification|band_classification|1235|start
ERROR|2024-03-11T12:53:59.379|classification_tab|run_classifier|485|boolean index did not match indexed array along dimension 0; dimension is 21261 but corresponding boolean dimension is 15
INFO|2024-03-11T12:54:31.659|session|set|405|n_processes: 2; ram: 10; temp.dir: C:\Users\jrassan\AppData\Local\Temp\remotior_sensus_0311bm7vybo2

Hello @JoseRascon , it seems that the issue is related to input images and the nodata value -9.223372036854776e+18.
You could try to use QGIS raster tools to change the datatype and nodata values of the image.

Hello @JoseRascon , I have a similar problem. I think that It could be useful to compare our data to understand what the common issue is.

Hello, I was testing with other plugins (like Dzetsaka) and the error I was getting was mainly that there were NaN values, once this error was solved it came out perfect. I couldn't verify it with SCP but it could be that this was the problem

Hello, I'm closing this because I checked now that it is a duplicate of #330.
Of course, please continue the reporting here #330.