{"record":{"id":"80f2505fa96b7207","repo":"lllyasviel/Fooocus","slug":"you-have-to-specify-either-input-ids-or-inputs-emb-80f250","errorCode":null,"errorMessage":"You have to specify either input_ids or inputs_embeds or encoder_embeds","messagePattern":"You have to specify either input_ids or inputs_embeds or encoder_embeds","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"extras/BLIP/models/nlvr_encoder.py","lineNumber":767,"sourceCode":"        else:\n            use_cache = False\n\n        if input_ids is not None and inputs_embeds is not None:\n            raise ValueError(\"You cannot specify both input_ids and inputs_embeds at the same time\")\n        elif input_ids is not None:\n            input_shape = input_ids.size()\n            batch_size, seq_length = input_shape\n            device = input_ids.device\n        elif inputs_embeds is not None:\n            input_shape = inputs_embeds.size()[:-1]\n            batch_size, seq_length = input_shape\n            device = inputs_embeds.device\n        elif encoder_embeds is not None:    \n            input_shape = encoder_embeds.size()[:-1]\n            batch_size, seq_length = input_shape \n            device = encoder_embeds.device\n        else:\n            raise ValueError(\"You have to specify either input_ids or inputs_embeds or encoder_embeds\")\n\n        # past_key_values_length\n        past_key_values_length = past_key_values[0][0].shape[2] if past_key_values is not None else 0\n\n        if attention_mask is None:\n            attention_mask = torch.ones(((batch_size, seq_length + past_key_values_length)), device=device)\n            \n        # We can provide a self-attention mask of dimensions [batch_size, from_seq_length, to_seq_length]\n        # ourselves in which case we just need to make it broadcastable to all heads.\n        extended_attention_mask: torch.Tensor = self.get_extended_attention_mask(attention_mask, input_shape, \n                                                                                 device, is_decoder)\n\n        # If a 2D or 3D attention mask is provided for the cross-attention\n        # we need to make broadcastable to [batch_size, num_heads, seq_length, seq_length]\n        if encoder_hidden_states is not None:\n            if type(encoder_hidden_states) == list:\n                encoder_batch_size, encoder_sequence_length, _ = encoder_hidden_states[0].size()\n            else:","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/extras/BLIP/models/nlvr_encoder.py#L749-L785","documentation":"NLVR encoder's forward requires one of input_ids, inputs_embeds, or encoder_embeds to infer input shape, batch size, and device; if all are None it raises this ValueError before any computation.","triggerScenarios":"Calling the encoder with only auxiliary args (attention_mask, past_key_values, labels), or with an input tensor that a preprocessing step set to None.","commonSituations":"None tensors from a failing dataloader or tokenizer; refactors where encoder_embeds was renamed; wrapper code that conditionally builds inputs but all branches were skipped.","solutions":["Pass input_ids (or inputs_embeds / encoder_embeds) explicitly","Assert the input tensor is not None right before the forward call","Log which input source your pipeline chose in debug builds to catch silent None"],"exampleFix":"// before\noutputs = encoder(attention_mask=mask)\n\n// after\nassert ids is not None, 'input_ids missing from batch'\noutputs = encoder(input_ids=ids, attention_mask=mask)","handlingStrategy":"validation","validationCode":"assert input_ids is not None or inputs_embeds is not None or encoder_embeds is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check batch tensors for None before forward","Keep one clear input-selection code path","Name the chosen input source in debug logs"],"tags":["blip","nlvr","input-validation"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}