-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CUDA of memory during testing #74
Comments
Hi, thanks! |
Thanks a lot! |
Yes! So you need to carefully tune the scale factor such that the performance won't be affected too much :) |
Maybe you could use the tile test. if not opt["tile"]:
noisy_state = sde.noise_state(LQ)
model.feed_data(noisy_state, LQ, GT, text_context=degra_context, image_context=image_context)
tic = time.time()
model.test(sde, mode=sampling_mode, save_states=False)
toc = time.time()
test_times.append(toc - tic)
visuals = model.get_current_visuals()
SR_img = visuals["Output"]
else:
# Tile test
b, c, h, w = LQ.size()
tile = 512
tile_overlap = 32
stride = tile - tile_overlap
h_idx_list = list(range(0, h - tile, stride)) + [h - tile]
w_idx_list = list(range(0, w - tile, stride)) + [w - tile]
E = torch.zeros(b, c, h, w).type_as(LQ)
W = torch.zeros_like(E)
tic = time.time()
for h_idx in h_idx_list:
for w_idx in w_idx_list:
in_patch = LQ[..., h_idx : h_idx + tile, w_idx : w_idx + tile]
gt_patch = GT[..., h_idx : h_idx + tile, w_idx : w_idx + tile]
noisy_state = sde.noise_state(in_patch)
model.feed_data(noisy_state, in_patch, gt_patch, text_context=degra_context, image_context=image_context)
model.test(sde, mode=sampling_mode, save_states=False)
out_patch = model.get_current_visuals()["Output"].type_as(LQ)
out_patch_mask = torch.ones_like(out_patch)
x0 = h_idx
y0 = w_idx
x1 = (h_idx + tile)
y1 = (w_idx + tile)
E[..., x0:x1, y0:y1].add_(out_patch)
W[..., x0:x1, y0:y1].add_(out_patch_mask)
SR_img = E.div_(W)
toc = time.time()
test_times.append(toc - tic)
output = util.tensor2img(SR_img.squeeze()) # uint8 |
Does stitching patches of image after they have been generated result in an image with distinct grid boundaries? @jkhu29 |
In my test, such artifacts are rare. Imagine we are cropping a 1024-resolution image to many 512-resolution images with a stride of 480, there will be many 32x32 overlapping areas. They belong to four cropped images and will be calculated four times during testing. Their results are cached ( |
thank you so much for your reply and good method! |
It’s an awesome work, and thank you for sharing.😄
When I apply DA-CLIP to train on my own dataset for a dehazing task, I encounter an error during testing: "CUDA out of memory." It seems like the issue is due to the large size of my test images (1024x1024).
Could you please provide some suggestions to fix this? Thank you very much!
The text was updated successfully, but these errors were encountered: