ricardoborsoi / Unmixing_with_Deep_Generative_Models

Spectral unmixing using deep generative models
27 stars 6 forks source link

suggestion solution on an issue #3

Closed khalidcoding closed 1 year ago

khalidcoding commented 1 year ago
Screenshot 2023-03-22 at 18 38 39

Good evening, I got this issue related to arrays have imcompatible sizes, please I tried fixing it but every time I get more errors, I know it's a simple error but I'm just new in learning matlab and coding, so if you could help me it will be much appreciate it.

Screenshot 2023-03-22 at 18 41 26

thank you.

ricardoborsoi commented 1 year ago

Hi @khalidcoding, have you checked the sizes of the variables Mvs and M_DeepGen to see if they are the same? You can do this by running the commands size(Mvs) and size(M_DeepGen) on the Matlab prompt right after you get the error and see what is the result.

Also, was the image r_cube cropped or modified before being passed to the DeepGUn function? Thanks

khalidcoding commented 1 year ago

Hi @ricardoborsoi, yes I already checked the sizes of Mvs and M_DeepGen, Mvs has (224×3×4900) and M_DeepGen has (345×3×4900), Also the image r_cube hasn't been cropped or modified, "r_cube has (70×70×345) data size".

ricardoborsoi commented 1 year ago

Hi @khalidcoding, there is some problem with the dimension of r_cube, it should be 70x70x224 (it is the hyperspectral image, with dimension height by width by bands). This variable (which is the hyperspectral image) is loaded directly from the file data_ex1.mat, provided in the repository:

>> load('data/data_ex1.mat')
>> size(r_cube)
ans =
    70    70   224 

Please try to compare your version of the code to the latest version of example1.m in the repository to see if there were any changes to this variable, or to the contents of the file data_ex1.mat.

khalidcoding commented 1 year ago

Hello @ricardoborsoi, yes I noticed that I'm using another hyperspectral image data but the thing is when i use this particular r_cube I get a whole bunch of other errors as the picture below

Screenshot 2023-03-28 at 18 49 53

thank you for your help, I will try harder with it and let you know the result. sorry for the late reply.

ricardoborsoi commented 1 year ago

Hi @khalidcoding , if you are using a different hyperspectral image, there are a few things to consider:

  1. the variable Mvs contains the ground truths for the endmembers, if this is not available for the image you are considering you might have to ignore the lines where it is used to evaluate the endmembers RMSE.
  2. You need to extract the reference endmembers (which are stored in M0 of size bands number of materials) for your new image, using the command M0 = vca(r,'Endmembers',P);, where r is the new hyperspectral image ordered as (bands pixels) and P is the number of materials in the scene.
khalidcoding commented 1 year ago

Hi @ricardoborsoi , hope you're doing well. I couldn't fix this issue I have so I changed my data to the original one (the one you used ) and now this new error pops up and it's about using hdf5info and that 'vae_EM_idx1.h5' could not be open as shown bellow

Screenshot 2023-04-13 at 12 11 58

knowing that the file is saved in the same folder, please if you could give some guidance to fix it I would appreciat it.

ricardoborsoi commented 1 year ago

Hello @khalidcoding, this error is most likely caused by the inability to run the python terminal command from Matlab, see the line system('python python/vae_keras_ems_train.py') in the function DeepGUn/train_DeepGen_EM_model.m. This is shown through the command not found: python message.

Fixing it might depend on your operating system, but if you have Anaconda already installed and are still getting a "python not found" error, you basically have to "tell" Matlab where your python installation is in your system:

  1. First you need the path to python (e.g., Anaconda) in your system, in unix environments you can open a terminal and type "which python", this will show the path to python on your system, for example, /Users/myusername/opt/anaconda3/bin/python.
  2. The you add this path to your Matlab path, using setenv('PATH', [getenv('PATH') ':/Users/myusername/opt/anaconda3/bin']) (substituting myusername by the username/path in your case).
  3. You can use system('echo $PATH') in Matlab to check if python is now present in the path, if so you should be able to run python scripts using system("python ...") in Matlab.
khalidcoding commented 1 year ago

Hello @ricardoborsoi , I don't actually have anaconda in mac mac book, I will try this guidance now and let you know the result, thank you. at first it was working well without anaconda I had only an error in matrix dimensions, now when I downloaded your code and data version, this error pops up, I don't know why. In 2. do I need to add this path to the matlab code path or matlab path in general ?