BjornNyberg / Geometric-Attributes-Toolbox

The Geometric Attributes toolbox is a set of QGIS tools designed for the geometric attribute and shape characterization of modern depositional elements
GNU General Public License v3.0
67 stars 8 forks source link

TypeError during configuration of SegmentAnything Tool #18

Closed cmosig closed 11 months ago

cmosig commented 12 months ago

When using the button "Configure Segment Anything Model (SAM)", the program hangs for a while (expected), but then I get the following error:

An error has occurred while executing Python code: 

TypeError: setValue(self, value: int): argument 1 has unexpected type 'float' 
TypeError: setValue(self, value: int): argument 1 has unexpected type 'float'

Python version: 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] 
QGIS version: 3.28.3-Firenze Firenze, exported 

Python Path:
/home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python/plugins/geometric_attributes
/usr/share/qgis/python
/home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python
/home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python310.zip
/usr/lib/python3.10
/usr/lib/python3.10/lib-dynload
/usr/local/lib/python3.10/dist-packages
/usr/lib/python3/dist-packages
/home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python
/home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python/plugins/kmltools/libs

Let me know which other information is needed.

BjornNyberg commented 12 months ago

Hi @cmosig

Im not familar with this error and its hard to tell from that traceback the location of the error. It appears to be an error with the pyqgis interface but im not sure. Do any of the other tools within the plugin work? (for example the sinuosity tool...). Having said that, it is recommended to install segment-geospatial manually on OSX or linux. The reason is that QGIS does not distribute a seperate python version for those OS systems and the configure tool may not properly handle the installation.

cmosig commented 12 months ago

Thanks for the quick answer! I have not installed segment-geospatial manually on my (Ubuntu 22) system. When using this configuration button again I get the same result.

I believe the other tools in the plugin work.

Can I run anything with more debug output?

BjornNyberg commented 12 months ago

Hi again,

Sorry I dont think there is an option to display more. Have you tried installing segment-geospatial=0.5.0 manually on your system? What error do you receive then? You could also try directly in your QGIS python console to type

import subprocess subprocess.check_call(['python3', 'm','pip','install','segment-geospatial=0.5.0'])

cmosig commented 12 months ago

It's weird, the install works fine. segment-geospatial==0.5.0 is installed on my system. The install also works fine from the python console.

Is there anything else in the configuration script before or after the install that can cause this error/crash?

BjornNyberg commented 12 months ago

If segment-geosptial was sucessfully installed then all you need to do is download the training datasets from META available here

https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth

Each file should be placed within your geometric attributes toolbox located in your case at /home/cmosig/.local/share/QGIS/QGIS3/profiles/default/python/plugins/geometric_attributes

Once that is done, the tool should work.

cmosig commented 11 months ago

Alright, then I am going to close this issue. Thank you