Open PodoprikhinMaxim opened 1 year ago
Hello! didn't find how to run your models using GPU, can you explain please how i can do it?
I also want to know
Me too
The models (https://github.com/eugenesiow/super-image/tree/main/src/super_image/models) are all classes that inherit from pytorch nn.Module
s, via the intermediary base class PretrainedModel
(https://github.com/eugenesiow/super-image/blob/main/src/super_image/modeling_utils.py#L160), so you can simply push the model to your GPU like this:
from super_image import EdsrModel, ImageLoader
from PIL import Image
import requests
import torch
device = torch.device("cuda")
url = 'https://paperswithcode.com/media/datasets/Set5-0000002728-07a9793f_zA3bDjj.jpg'
image = Image.open(requests.get(url, stream=True).raw)
model = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=2).to(device)
inputs = ImageLoader.load_image(torch.from_numpy(image).to(device))
preds = model(inputs).detach().cpu().numpy()
ImageLoader.save_image(preds, './scaled_2x.png')
ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')
@jordanjuras Traceback (most recent call last):
File "C:\upscalegpu.py", line 12, in
from PIL import Image
import requests
import torch
device = torch.device("cuda")
print(torch.cuda.is_available()) # make sure this is TRUE !
url = './4-o.jpg'
image = Image.open(url)
model = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=2)
model = model.to(device)
inputs = ImageLoader.load_image(image)
preds = model(inputs.to(device))
ImageLoader.save_image(preds, './scaled_2x.png')
ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')
I am using the following code to upscale a local image on GPU which seems to work fine
Hello! didn't find how to run your models using GPU, can you explain please how i can do it?