dvlab-research / LLaMA-VID

Official Implementation for LLaMA-VID: An Image is Worth 2 Tokens in Large Language Models
Apache License 2.0
623 stars 40 forks source link

stage 2: freezing the visual encoder? #44

Closed dragen1860 closed 5 months ago

dragen1860 commented 6 months ago

Dear all: The paper say it will freeze the visual encoder only when training on stage2. However, from the training script here:

deepspeed  --include localhost:4,5 llamavid/train/train_mem.py \
    --deepspeed ./scripts/zero2_offload.json \
    --version imgsp_v1 \
    --data_path ./data/LLaMA-VID-Finetune/llava_v1_5_mix665k_with_video_chatgpt.json \
    --output_dir ./work_dirs/llama-vid-7b-full-224-video-fps-1  \
    --image_folder ./data/LLaMA-VID-Finetune \
    --video_folder ./data/LLaMA-VID-Finetune \
    --vision_tower ./model_zoo/LAVIS/eva_vit_g.pth \
    --image_processor ./llamavid/processor/clip-patch14-224 \
    --model_name_or_path /media/sdb/long/lmm/CogVLM/vicuna-7b-v1.5/ \
    --pretrain_mm_mlp_adapter ./pretrained/llama-vid-7b-pretrain-224-video-fps-1/mm_projector.bin \
    --mm_projector_type mlp2x_gelu \
    --mm_vision_select_layer -2 \
    --mm_use_im_start_end False \
    --mm_use_im_patch_token False \
    --image_aspect_ratio pad \
    --group_by_modality_length True \
    --video_fps 1 \
    --bert_type "qformer_pretrain" \
    --num_query 32 \
    --compress_type "mean" \
    --bf16 True \
    --num_train_epochs 1 \
    --per_device_train_batch_size 4 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 4 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 1000 \
    --save_total_limit 1 \
    --learning_rate 2e-5 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --tf32 True \
    --model_max_length 2048 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True
#    --report_to wandb

I can not see any setup related to freeze the EVA backbone. And also i check the code in details, but still can not find any code related to freeze the visual encoder. Anyone help me, thank you.

by the way, i found the freeze_backbone parameters. However, it will freeze both the EVA and LLM as model.model.requires_grad_(False).

yanwei-li commented 5 months ago

Hi, visual encoder is frozen across all stages, as declared in Implementation Details of Section 4.1 of the paper.