juhongm999 / hsnet

Official PyTorch Implementation of Hypercorrelation Squeeze for Few-Shot Segmentation, ICCV 2021
231 stars 43 forks source link

unsufficient GPU storage? #13

Closed JoniGlueck closed 2 years ago

JoniGlueck commented 2 years ago

Hello, I'm currently testing your code on a new class I inserted to FSS-1000 (weldings on big machine parts). When trying to change several values, such as the image size in line 88 in test.py or the batch size, i constantly run into this error:

RuntimeError: CUDA out of memory. Tried to allocate 1.40 GiB (GPU 0; 7.79 GiB total capacity; 4.36 GiB already allocated; 448.50 MiB free; 5.44 GiB reserved in total by PyTorch)

I'm working on a nvidia RTX 3070ti with 8 Gigs of VRAM. I suppose this is because Pytorch manually manages storage allocation and there is not enough VRAM for processing larger images. However this is what i want to do, because I suppose larger images lead to better results in Few Shot Segmentation. So my question is, is there any way to increase FB-IoU and mIou on my own set of images or do I have to implement a completely new dataset on my own and do I have to train a new model to use it on this own set of images?

Thank you in advance and for your impressive work.

juhongm999 commented 2 years ago

Note that the training of our model with batch size of 20 & image size of 400x400 requires about 20G memory. What exactly were the batch and image sizes in your experiments? Also, if the domain of your dataset is quite different from the provided FSS datasets (PASCAL, COCO, FSS-1000), results of the provided pretrained HSNet might be bad on your dataset.

JoniGlueck commented 2 years ago

Thank you for your quick reply. I've experimented with several batch sizes from 1-5, image size is aimed at 1960x1960px . I trained your network again with my set of images as results where about 45-50 FBIoU with the pretrained model on Vgg16. Now I'm sitting at around 60-70 FBIoU with my new model (trained with 100 iterations). Another question I've come across is: does your hsnet work when no exact batch (containing sample images, masks, query image, query mask etc.) is provided? As our own query images are not supposed to have a mask with them.

juhongm999 commented 2 years ago

You must have query masks to train the network with cross-entropy loss but you are not required to have query masks during testing. However, it's encouraged if you want to evaluate the model using mIoU metric.

JoniGlueck commented 2 years ago

Thank you very much, that helps me out!