martibosch / detectree

Tree detection from aerial imagery in Python
https://doi.org/10.21105/joss.02172
GNU General Public License v3.0
233 stars 31 forks source link

Bug in train_test_split.py #7

Closed pedromarcolin closed 3 years ago

pedromarcolin commented 4 years ago

Hello !

I'm trying to reproduce the detectree code in my computer, but I'm receiving an error when I execute this line of the background code:

split_df, evr = ts.train_test_split(method='cluster-II', num_components=12, return_evr=True)

This line is giving the error showed below:

AttributeError: 'TrainingSelector' object has no attribute '_descr_feature_matrix'

What am I doing wrong?

martibosch commented 4 years ago

Hello @pedromarcolin,

thank you for using detectree and for submitting this issue. This behavior is strange, since the train_test_split method calls the property descr_feature_matrix, which should catch such an AttributeError.

Could you please provide me (so that I can try to debug this):

Thank you. Best, Martí

pedromarcolin commented 4 years ago

Hello @martibosch

The full traceback of the error is following below:

image

I'm using Jupyter Notebook, opening in the Anaconda CMD

My verson of detectree is 0.3.1

The output of running conda env export is:

name: geo_py37 channels:

Thank you my friend !

Pedro Marcolin

martibosch commented 4 years ago

Hello Pedro,

thank you for sharing the traceback and environment. Nonetheless, from the traceback it seems that this is not an issue with detectree itself but rather an issue of your input data, i.e., the TrainingSelector does not have a non-empty list of images (its img_filepaths attribute) for which the image descriptors are to be computed.

How have you instantiated TrainingSelector? If you have followed the example notebooks, I assumed that you have done so as in ts = dtr.TrainingSelector(img_dir='data/interim/tiles'). In such case, are the images well located in the data/interim/tiles directory?

On the other hand, I see that you are using Windows, which might be the root of this issue. Before instantiating the TrainingSelector, you should run the !make tiles cell, nonetheless I believe that Make does not work out-of-the-box with windows. Were you able to run such a cell without getting any errors? If not, you might try installing Make with conda as in: conda install -c conda-forge make and re-running the notebook. Please let me know if that works.

Best, Martí

pedromarcolin commented 4 years ago

Hello Martí !

I executed this line: conda install -c conda-forge make, that's ok.

I'm having some troubles executing this lines of the codes:

image

image

In both cases appears this website to download the item ortho_sommer14.prj, but when I click on this, appears this website:

image

and I couldn't download the file.

martibosch commented 4 years ago

Hello Pedro,

I wonder whether these file not found errors are because of the different path syntax in UNIX and Windows (i.e., the use of the / and \ directory separators respectively). I believe that you can get more compatibility with UNIX commands in Windows by using Cygwin. Maybe such commands will work if you try running the Jupyter notebooks like this: https://www.scivision.dev/install-ipython-jupyter-in-cygwin/

On the other hand, the ortho_sommer14.prj is a basically text-like file with the contents that you see displayed in the browser - therefore, if you encounter problems downloading the file, you can instead copy such text into the notepad or any text editor and save it as ortho_sommer14.prj in the right path.

Best, Martí

martibosch commented 3 years ago

Hello Pedro,

have there been any news regarding this issue? Otherwise, may I close it?

Best, Martí

pedromarcolin commented 3 years ago

Hello Marti !

Sorry about the late, there's no issues anymore, you can close it.

Best regards,

Pedro Marcolin