{"record":{"id":"594f793e5e92100f","repo":"lllyasviel/Fooocus","slug":"you-have-to-specify-either-input-ids-or-inputs-emb","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/med.py","lineNumber":732,"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":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/extras/BLIP/models/med.py#L714-L750","documentation":"The MED BertModel forward requires at least one input source — input_ids, inputs_embeds, or encoder_embeds — to determine batch_size/seq_length/device. If all three are None it cannot infer the input shape and raises this ValueError before doing any compute.","triggerScenarios":"model() or model(attention_mask=mask, ...) with none of input_ids/inputs_embeds/encoder_embeds set; commonly when a caller intended to pass encoder_embeds (BLIP's image branch) but named it inputs_embeds in an outdated signature, or when a required tensor is accidentally None from an upstream bug.","commonSituations":"Version drift where the argument expected by caller code was renamed/added; generation wrappers that pass only past_key_values; None returned by a dataloader or preprocessing step silently propagated.","solutions":["Pass one of input_ids, inputs_embeds, or encoder_embeds explicitly","If calling the BLIP image-grounded path, pass the projected image features as encoder_embeds","Add an assert before forward: assert input_ids is not None or inputs_embeds is not None or encoder_embeds is not None to catch upstream None early"],"exampleFix":"// before\nout = text_encoder(attention_mask=mask)  # inputs all None\n\n// after\nout = text_encoder(input_ids=ids, attention_mask=mask)\n# BLIP image branch:\n# out = text_encoder(encoder_embeds=image_embeds, attention_mask=mask)","handlingStrategy":"validation","validationCode":"assert any(x is not None for x in (input_ids, inputs_embeds, encoder_embeds)), \\\n    'must pass input_ids, inputs_embeds, or encoder_embeds'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert at least one input source before every forward call","Guard dataloader outputs against None batches","Remember BLIP image conditioning uses encoder_embeds"],"tags":["blip","bert","input-validation","kwargs"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}