Skip to content
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

ValueError: too many values to unpack (expected 3) #2

Open
ontheway-arch opened this issue Nov 14, 2023 · 0 comments
Open

ValueError: too many values to unpack (expected 3) #2

ontheway-arch opened this issue Nov 14, 2023 · 0 comments

Comments

@ontheway-arch
Copy link

File "/data2/xingyc/LG-VQA/train.py", line 305, in
train_loss, train_acc, train_preds = train_or_eval_model(model, train_loader, optimizer, "Train")
File "/data2/xingyc/LG-VQA/train.py", line 199, in train_or_eval_model
loss, pred, label, qid = model(batch)
File "/data2/xingyc/anaconda3/envs/lgvqa/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/data2/xingyc/anaconda3/envs/lgvqa/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/data2/xingyc/LG-VQA/models.py", line 178, in forward
similarity_logits = self.score_input(images, texts, knowledge, qid)
File "/data2/xingyc/LG-VQA/models.py", line 152, in score_input
logits, features, image_embeds = self.model(batch, match_head="itm")
ValueError: too many values to unpack (expected 3)

I build LAVIS from source.
I find in the class Blip2ITM, it only return one value, so what the other two params (features, image_embeds)means?

if match_head == "itm":
        query_tokens = self.query_tokens.expand(image_embeds.shape[0], -1, -1)
        query_atts = torch.ones(query_tokens.size()[:-1], dtype=torch.long).to(
            image.device
        )
        attention_mask = torch.cat([query_atts, text.attention_mask], dim=1)
        output_itm = self.Qformer.bert(
            text.input_ids,
            query_embeds=query_tokens,
            attention_mask=attention_mask,
            encoder_hidden_states=image_embeds,
            encoder_attention_mask=image_atts,
            return_dict=True,
        )
        itm_embeddings = output_itm.last_hidden_state[:, : query_tokens.size(1), :]
        itm_logit = self.itm_head(itm_embeddings)
        itm_logit = itm_logit.mean(dim=1)

        return itm_logit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant