deepglint / unicom

[ICLR 2023] Unicom: Universal and Compact Representation Learning for Image Retrieval

Home Page:https://arxiv.org/pdf/2304.05884.pdf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

x= x.cpu() in retrival.py (around line 636)get error with nontype

Chaoran-F opened this issue · comments

I printed x after the for image, label in dataloader: line and the for loop line were completed, and I got the result of None, and I found that for image, label in dataloader: did not start the loop, so what is the reason, I Try to check the dataloader, there is an output, but the for loop is not started.

error:
x = x.cpu()
AttributeError: 'NoneType' object has no attribute 'cpu'

code:
print('dataset_this_rank',dataset_this_rank)
dataloader = DataLoader(dataset_this_rank, **kwargs)
x = None
y_np = []
idx = 0
print('dataloader',dataloader)
print('before: ', x)

for image, label in dataloader:
    print('entry!')
    image = image.cuda()
    embedding = model(image)
    embedding_size: int = embedding.size(1)
    if x is None:
        print(x)
        size = [len(dataset_this_rank), embedding_size]
        x = torch.zeros(*size, device=image.device)
    print('!',x)
    x[idx:idx + embedding.size(0)] = embedding
    y_np.append(np.array(label))
    idx += embedding.size(0)
print('after: ', x)
x = x.cpu()

dataset: own food dataset, use sop loading style
envs: torch:1.12.1,cuda:11.4