DaChro / ogh_summer_school_2020

Material for the session "Introduction to Deep Learning in R for the analysis of UAV-based remote sensing data"
20 stars 18 forks source link

Error in py_call_impl(callable, dots$args, dots$keywords) #3

Open safalabolo opened 2 years ago

safalabolo commented 2 years ago

Hi Christian, thank you for sharing this important material!

After performing all the steps related to installing the libraries, etc.

install.packages(c("keras","tfdatasets","mapview","stars","rsample","gdalUtils","purrr", "magick", "jpeg"))

reticulate::install_miniconda() keras::install_keras()

reticulate::py_config() tensorflow::tf_config() keras::is_keras_available()

After downloading and unzipping the tutorial data, when I start the block including the Line 235 of the Tutorial_DL_UAV.Rmd file

I have the following error:

pretrained_unet <- load_model_hdf5("./pretrained_unet.h5") Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: Expected trainable argument to be a boolean, but got: None

Detailed traceback: File "C:\Users\Utente\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\Utente\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\keras\engine\base_layer.py", line 349, in init raise TypeError(

Unfortunately I was unable to understand why. Thanks in advance for the support.

DaChro commented 2 years ago

Hi safalabolo, my first guess would be that this has something to do with a conflict between the tensorflow/keras versions used in the tutorial (and for creating this model you want to load) and your installed version. I was able to reproduce the error with tf 2.8 and could solve it by installing tf 2.2, which was also used in the tutorial. You can install a specific version by using tensorflow::install_tensorflow(version = "2.2.0") . However, it is probably a good idea to test that in a separate conda environment that you create beforehand (using conda_create() and naming it, e.g., "mytestenv"), then do tensorflow::install_tensorflow(envname = "mytestenv",version = "2.2.0") Best, Christian

rion-saeon commented 2 months ago

Hello @DaChro. I tried the workaround of this seemingly lovely R tutorial but to no avail.

See attached log. issue_log_conda_tensorflow.txt

If you could please keep this workflow current it will be good as there are not many other such tutorials out there explaining such object detection/classification.