-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Issue with Trainer Training - AttributeError: 'NoneType' object has no attribute 'shape' #36054
Comments
@Md-Nasif03 hey! I believe you are using an old version of transformers. The method you mentioned for merging has been deprecated for ~5 releases and is alreadt removed in v4.48. Can you please try to update transformers with |
@zucchini-nlp Thank you, ma'am. |
Can you share your model files on the hub? I believe something is wrong in the config, probably you need to add |
Good morning @zucchini-nlp ma'am, I have just uploaded my model at the hugging face hub.
You can check here and please check what is going wrong Also, I have given you the details of how I saved the model on Gdrive after fine-tuning and the list of model files saved in the hub. Saving the fine tune model to Google Drive
List files in the model directory
Output:
Copy the necessary file to our finetune model
Check if "pytorch_model.bin" exists in the main directory
List files in the model directory
output
Fine tuned model
Load the LlavaProcessor with the correct image processor
Manually update missing attributes
Save the updated processor back to the model directory
Reload the processor
output:
Prompt
resize the image
output: Process Inputs
Generate Response from the Model
![]() |
Your |
@zucchini-nlp thank you, ma'am. It's work |
Description:
I am working on fine-tuning an image-text model using the Hugging Face AutoModelForImageTextToText and LlavaProcessor. While attempting to train the model using the SFTTrainer, I encountered an error related to a NoneType object during the training loop. The error occurs specifically in the _merge_input_ids_with_image_features method in the modeling_llava.py file.
Note:
I have load the data(json) from my GDrive
Error Details:
AttributeError: 'NoneType' object has no attribute 'shape'
Error Occurrence:
The error occurs after calling trainer.train(), and it seems that during the training, the image_features passed into the _merge_input_ids_with_image_features function is None, causing the AttributeError when the code tries to access its shape.
Code Snippet Leading to the Error:
Relevant Model Function:
The error occurs within the following function in modeling_llava.py:
Potential Causes:
Request:
Code:
Load the base model
Load LLaMA tokenizer
Prompt Template
Reload the Dataset from Google Drive
Converting to Hugging Face Dataset
Merge the dataset
Split the Dataset into Train, Validation, and Test
Convert back to Hugging Face Dataset
Create DatasetDict
Preprocessing Function
Data preprocessing
#output: ['image', 'question', 'answer', 'index_level_0']
Apply preprocessing function
#output: ['input_ids', 'attention_mask', 'pixel_values', 'labels']
Prepare for finetuning
The text was updated successfully, but these errors were encountered: