InstColorization icon indicating copy to clipboard operation
InstColorization copied to clipboard

Is there any way to make the result image size consistent with the input image size?

Open quuhua911 opened this issue 4 years ago • 6 comments

It's a great job. Thank you ! Here ,I have two questions to ask your advice: (1)My input image size is different such as 419* 320 , 520* 400.... ,but I found the size of result image all are 512*512,Is there any way to make the result image size consistent with the input image size? (2) I have changed the Parameter:fineSize=512
for examle: python test_fusion.py --name test_fusion --sample_p 1.0 --model fusion --fineSize 512 --test_img_dir example --results_img_dir results ,but Program error display: "RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 10.91 GiB total capacity; 9.73 GiB already allocated; 56.38 MiB free; 9.83 GiB reserved in total by PyTorch)" My GPU is 1080Ti.

The current output image size seems to be too small,How do I fix this problem?

quuhua911 avatar May 28 '20 09:05 quuhua911

I got the same problem when I run python test_fusion.py --name test_fusion --sample_p 1.0 --model fusion --fineSize 512 --test_img_dir example --results_img_dir results at colab. I can only use the fineSize 256 to test the effect, the colorization is so great but the image was compressed and cropped.

wangerzi avatar Jun 01 '20 04:06 wangerzi

Our model colorizes every instance in the image, so it would take large amount of vram, so colorizing small image and attach color channel onto original gray image (see the least block of colab notebook) would be one acceptable method to colorize high resolution image.

ericsujw avatar Jun 02 '20 13:06 ericsujw

Hi, Please forgive me re-asking the same questions, I'm not clear about the answer yet.

Your Git page and read-me have been easy to follow and I can get small square cropped color results from my PC, that look great, (thank you!)

I am aiming to get color pictures the same size (and ratio) as the original gray ones from my home PC. I think you are saying I would need a lot of memory on my GPU to do this and my 6GB GPU is not enough.

But I think you are saying there is away around this problem..... "so colorizing small image and attach color channel onto original gray image would be one acceptable method to colorize high resolution image."

Are there any steps you could share with me that I can use on my home PC to do this? Ive looked at the last block of code on the colab but have not been able to use this in my conda environment. Thanks.

polojohn avatar Jun 04 '20 14:06 polojohn

If you know a way to make the resulting image the same size as the input image, please let me know. Thank you very much for your letter

------------------ 原始邮件 ------------------ 发件人: "polojohn"<[email protected]>; 发送时间: 2020年6月4日(星期四) 晚上10:14 收件人: "ericsujw/InstColorization"<[email protected]>; 抄送: "Subscribed"<[email protected]>; 主题: Re: [ericsujw/InstColorization] Is there any way to make the result image size consistent with the input image size? (#4)

Hi, Please forgive me re-asking the same questions, I'm not clear about the answer yet.

Your Git page and read-me have been easy to follow and I can get small square cropped color results from my PC, that look great, (thank you!)

I am aiming to get color pictures the same size (and ratio) as the original gray ones from my home PC. I think you are saying I would need a lot of memory on my GPU to do this and my 6GB GPU is not enough.

But I think you are saying there is away around this problem..... "so colorizing small image and attach color channel onto original gray image would be one acceptable method to colorize high resolution image."

Are there any steps you could share with me that I can use on my home PC to do this? Ive looked at the last block of code on the colab but have not been able to use this in my conda environment. Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Python1203 avatar Jun 04 '20 14:06 Python1203

you can use the code from InstColorization/InstColorization.ipynb

from google.colab.patches import cv2_imshow
img_name_list = ['000000022969', '000000023781', '000000046872', '000000050145']
show_index = 1

img = cv2.imread('example/'+img_name_list[show_index]+'.jpg')
lab_image = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
l_channel, _, _ = cv2.split(lab_image)

img = cv2.imread('results/'+img_name_list[show_index]+'.png')
lab_image = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
_, a_pred, b_pred = cv2.split(lab_image)
a_pred = cv2.resize(a_pred, (l_channel.shape[1], l_channel.shape[0]))
b_pred = cv2.resize(b_pred, (l_channel.shape[1], l_channel.shape[0]))
gray_color = np.ones_like(a_pred) * 128

gray_image = cv2.cvtColor(np.stack([l_channel, gray_color, gray_color], 2), cv2.COLOR_LAB2BGR)
color_image = cv2.cvtColor(np.stack([l_channel, a_pred, b_pred], 2), cv2.COLOR_LAB2BGR)

cv2_imshow(np.concatenate([gray_image, color_image], 1))

onefish51 avatar Jun 17 '20 07:06 onefish51

I think it will be great if somehow the code suggested by @onefish51 be merged into the https://github.com/ericsujw/InstColorization/blob/master/test_fusion.py

jerrymatjila avatar Aug 31 '20 13:08 jerrymatjila