MikhailMashukov / particles_nsu

Public repository with core code for counting particles by means of neural networks
4 stars 1 forks source link

Errors from nano_predict.py implementation #3

Closed FiyinfobaO closed 1 year ago

FiyinfobaO commented 1 year ago

I am trying to reproduce the code on your data provided and my custom data by running the nano_predict.py file but I am getting different errors.

The first (shown below) was a type error which I resolved using a new config according to this solution

Screen Shot 2023-01-04 at 4 06 50 PM

After resolving it, I then got an Index Error from line 70 of nano_predict.py (as seen in the screenshot below) that I am yet to rectify and would need help with as I still get the same error even when I use my own data.

Screen Shot 2023-01-04 at 4 10 36 PM

It seems the error is coming from the the content of segms[inst_cls][i] which was passed inside maskUtils.decode(). When I print out the segms[inst_cls][i], it shows the screenshot below.

Screen Shot 2023-01-04 at 4 14 55 PM

I would appreciate any help in rectifying this error. Thanks.

MikhailMashukov commented 1 year ago

We used quite old mmdetection version and then it changed, so config and weights became incompatible. Sorry, we didn't specify it.

We used mmdetection commit d0c0418763 that is in between 1.0rc0 and 1.0rc1 and mmcv 0.2.14.

You can try to remove .decode call since you get non-compressed masks (decode uncompresses RLE-coded masks), but maybe simpler to use that version of mmdetection.

FiyinfobaO commented 1 year ago

Thanks for the response. I will try the mmcv and mmdetection version you specified

FiyinfobaO commented 1 year ago

@MikhailMashukov pls how do i specify the exact commit to install the mmdetection?

I tried using the command: pip install git+https://github.com/open-mmlab/mmdetection.git@d0c0418763 but I keep getting the error shown below, which makes it seem like the installation won't work if I'm not using Linux as I'm currently using mac

Screen Shot 2023-01-07 at 8 48 38 AM

Kindly note that before running the earlier command, I already installed mmcv using the command: pip install mmcv==0.2.14

MikhailMashukov commented 1 year ago

Oh, to install it can be a big problem... It looks like the problem is not in pip command, but in CUDA Toolkit setup. Maybe you don't have it at all? And maybe it is worth trying to add -e to pip.

Here are some commands I used when installed mmdetection. Better not to try to run them as is (maybe you don't need all these modules in .yml and so on), but to look for ideas instead.

conda env create -f ~/CondaEnvs/gs_open-mm.environment.yml -n open-mmlab7 conda activate open-mmlab7 conda install -c anaconda pandas cd /mnt/tenTB/mashukov_mu/mmcv/ python setup.py develop cd .. git clone https://github.com/open-mmlab/mmdetection.git mmdetection7 git checkout d0c0418763 cd mmdetection7 python setup.py develop

Here is renamed gs_open-mm.environment.yml: gs_open-mm.environment.txt

FiyinfobaO commented 1 year ago

sorry but can you send the .yml environment file rather than .txt since the i can easily create the environment with that

Then where do i find this mnt folder in this path you provided: /mnt/tenTB/mashukov_mu/mmcv/

MikhailMashukov commented 1 year ago

I attached .yml for you above, but since github doesn't allow yml extension, I renamed it. /mnt/tenTB/mashukov_mu is initially empty folder in which I setted up mmcv and mmdetection. Use any other on your drive. I don't remember exactly, but maybe I also checked out latest mmcv version from its GIT, into this .../mmcv subfolder. Then python setup.py develop

FiyinfobaO commented 1 year ago

Okay, thanks. Quick one: is it the mmcv-full or mmcv that you guys used?

Then I noticed that the above method we're using to install the mmcv is from source, and when I tried it, it was the 1.7.1 version that installed and not 0.2.14. Is there a way to specify the 0.2.14 version?

Lastly, after cloning mmdetection and checking out the commit you specified, I got this message (not sure if its showing what is meant to show or not)

Screen Shot 2023-01-10 at 2 40 46 PM

So, I continued and ran the python setup.py develop command but it throws the same CUDA HOME error I mentioned in my earlier comment

Screen Shot 2023-01-10 at 2 42 44 PM

Please what exactly am I doing wrong?

MikhailMashukov commented 1 year ago

I don't remember, rather mmcv, I don't remember "-full".

mmcv is from source, and when I tried it, it was the 1.7.1 version

I suppose you didn't checked out older commit, by default GIT checks out latest master.

What it says about switch is logical, you haven't create branch and this is strange for GIT. Read documentation if you want to understand deeper.

As I wrote, missing CUDA_HOME maybe means you haven't installed require CUDA Toolkit.

FiyinfobaO commented 1 year ago

I honestly don't understand what you are saying. For mmcv, you didn't give any commit for me to checkout. All you said was "..latest mmcv version" which is why I'm wondering how you were able to use the 0.2.14 version. However, I've been able to sort that one out. I found the 0.2.14 version commit, checked out the commit and ran the setup.py which worked.

For mmdetection, where I am getting the cuda_home error, I mentioned that I'm using a MacBook and macs can't have cuda toolkit installed. Which is why I was asking if this project can really work on a mac or whether its specific to linux?

MikhailMashukov commented 1 year ago

Fiyinfoba, I don't work on Mac, so you should know your computer better than me. 1-minute googling showed that CUDA can be installed on Macs. This should be your work to google for details, whether this is possible for you MacBook and OS. Our project doesn't prevent from running it on Macs, but we didn't try. What we know is that it needs CUDA Toolkit or something like this (CuDNN runtime libraries for example).

I sent you our mmcv version which is 0.2.14. So you could find a corresponding commit in GIT history if you want to install it from sources.

FiyinfobaO commented 1 year ago

Can you share the link where you saw that CUDA can be installed on macs, cause I didn't see any. Thanks.

MikhailMashukov commented 1 year ago

https://developer.download.nvidia.com/compute/cuda/10.1/Prod/docs/sidebar/CUDA_Installation_Guide_Mac.pdf https://gist.github.com/Mistobaan/dd32287eeb6859c6668d https://www.google.com/search?q=install+cuda+on+mac&newwindow=1

FiyinfobaO commented 1 year ago

Thanks for sharing.

@MikhailMashukov I've been going through the code but I can't seem to find the training script that was used to create the epoch_500_3x.pth file. Can you kindly point me to it?

Thanks.

MikhailMashukov commented 1 year ago

Training of the network is another and complicated question, so we didn't share it. Were you able to run inference?

FiyinfobaO commented 1 year ago

Yes, I did, but the results (shown below) weren't looking good on the data, which wasn't really surprising since the model wasn't trained on my data. Result1_Img_masks_predicted Result2_Img_masks_predicted

As you can see, the results are not good. This is why I need the training script so I can build a custom model

MikhailMashukov commented 1 year ago

Ah, well. Yes, of course this is too far from particles we had. You for sure need our service https://t.me/nanoparticles_nsk instead where you can train on your data. It has to have instruction in English too in pinned message

FiyinfobaO commented 1 year ago

thanks, but it seems like the telegram link doesn't work.

MikhailMashukov commented 1 year ago

The main thing you need to do is to take this part "nanoparticles_nsk", add @ before it and search in Telegram: @nanoparticles_nsk

FiyinfobaO commented 1 year ago

so the telegram gc helps to train the model for custom datasets which is good, but what of cases where the person wants to manually train the model by themselves, shouldn't that option be possible?

MikhailMashukov commented 1 year ago

Yes, of course. Google for any model you want and go forward