How to use pillow_heif in Dataloader (Pytorch) #70
Answered
by
bigcat88
qilong-zhang
asked this question in
Q&A
-
Hi @bigcat88 , I want to load ".heic" images in Dataloader. So my code is Class Dataset(torch.utils.data.Dataset):
def __init__(self, path=None, mode='train'):
pass
def __len__(self):
pass
def __getitem__(self, index):
register_heif_opener()
pass But this code seems to cause a memory leak. Is there any other better solution? |
Beta Was this translation helpful? Give feedback.
Answered by
bigcat88
Jan 28, 2023
Replies: 2 comments 12 replies
-
Can you provide fuller example?
|
Beta Was this translation helpful? Give feedback.
1 reply
-
You can call it before the definition of from multiprocessing import shared_memory
import glob
from pillow_heif import register_heif_opener
import torch
register_heif_opener()
class Dataset_Test(torch.utils.data.Dataset): if it works, you can simplify it even more with one import line and without calling from multiprocessing import shared_memory
import glob
import pillow_heif.HeifImagePlugin # noqa
import torch |
Beta Was this translation helpful? Give feedback.
11 replies
Answer selected by
qilong-zhang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can call it before the definition of
Dataset_Test
class for example.if it works, you can simplify it even more with one import line and without calling
register_heif_opener
: