-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b90927
commit 4d4fad2
Showing
48 changed files
with
6,492 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
subsampling: {} | ||
|
||
reading: | ||
yt_args: | ||
download_size: 360 | ||
download_audio_rate: 44100 | ||
yt_metadata_args: null | ||
timeout: 60 | ||
sampler: null | ||
|
||
storage: | ||
number_sample_per_shard: 1000 | ||
oom_shard_count: 5 | ||
captions_are_subtitles: False | ||
|
||
distribution: | ||
processes_count: 16 | ||
thread_count: 16 | ||
subjob_size: 1000 | ||
distributor: "multiprocessing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# wget -nc http://www.robots.ox.ac.uk/~maxbain/webvid/results_10M_train.csv | ||
|
||
video2dataset --url_list="results_2M_train.csv" \ | ||
--input_format="csv" \ | ||
--output-format="webdataset" \ | ||
--output_folder="dataset" \ | ||
--url_col="contentUrl" \ | ||
--caption_col="name" \ | ||
--save_additional_columns='[videoid,page_idx,page_dir,duration]' \ | ||
--enable_wandb=True \ | ||
--config="path/to/config.yaml" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## Preparation | ||
|
||
WebVid is a large-scale text-video dataset, containing 10 million video-text pairs scraped from the stock footage sites. | ||
To download the dataset, run the following command: | ||
|
||
```angular2html | ||
wget -nc http://www.robots.ox.ac.uk/~maxbain/webvid/results_2M_train.csv | ||
video2dataset --url_list="results_10M_train.csv" \ | ||
--input_format="csv" \ | ||
--output-format="webdataset" \ | ||
--output_folder="dataset" \ | ||
--url_col="contentUrl" \ | ||
--caption_col="name" \ | ||
--save_additional_columns='[videoid,page_idx,page_dir,duration]' \ | ||
--enable_wandb=True \ | ||
--config="path/to/config.yaml" \ | ||
``` | ||
For more datails, please refer to [video2dataset](https://github.com/iejMac/video2dataset/blob/main/dataset_examples/WebVid.md). | ||
|
||
|
||
### Postprocess | ||
Once you've downloaded the dataset, please verify the download status, as some video files may not have been successfully downloaded. Afterward, organize the dataset into a json file with the following format: | ||
```angular2html | ||
[ | ||
{ | ||
"caption": "Merida, mexico - may 23, 2017: tourists are walking on a roadside near catholic church in the street of mexico at sunny summer day.", | ||
"video_name": "31353427.mp4" | ||
}, | ||
{ | ||
"caption": "Happy family using laptop on bed at home", | ||
"video_name": "14781349.mp4" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
The data file structure should be: | ||
```angular2html | ||
data/T-X_pair_data/webvid | ||
├── webvid.json | ||
├── videos | ||
| ├── 31353427.mp4 | ||
| ├── 14781349.mp4 | ||
| └── ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# in this file, we will unzip the downloaded data and preprocess it | ||
D_NUM=0 | ||
for i in {100..226}; do | ||
if [ $D_NUM -lt 10 ]; then | ||
rm -f ./data/webvid/videos/*.txt | ||
D_NUM=1 | ||
else | ||
D_NUM=$((D_NUM + 1)) | ||
fi | ||
echo "Extracting 00${i}.tar" | ||
|
||
tar -xf ./data/webvid/dataset/00${i}.tar -C ./data/webvid/videos/ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
|
||
|
||
# =================== Encoding-side Training ====================== | ||
DATASET_NAME_LIST=( | ||
"" | ||
) | ||
DATASET_NAME_LIST="${DATASET_NAME_LIST[@]}" | ||
|
||
LLM_MODEL_NAME="./pretrain_ckpt/vicuna-7b-v1.5" | ||
MM_MODEL_NAME="./pretrain_ckpt/clip" | ||
|
||
echo "DATASET_NAME_LIST: $DATASET_NAME_LIST" | ||
echo "LLM_MODEL_NAME: $LLM_MODEL_NAME" | ||
echo "MM_MODEL_NAME: $MM_MODEL_NAME" | ||
|
||
|
||
accelerate launch --main_process_port 8922 train_mem.py \ | ||
--lora_enable True --lora_r 128 --lora_alpha 256 \ | ||
--mm_input_projector_lr 2e-5 --mm_output_projector_lr 2e-5 \ | ||
--deepspeed ./scripts/zero2.json \ | ||
--model_name_or_path $LLM_MODEL_NAME \ | ||
--version v1 \ | ||
--dataset_name_list $DATASET_NAME_LIST \ | ||
--multimodal_tower $MM_MODEL_NAME \ | ||
--group_by_modality_length True \ | ||
--group_by_modality_type False \ | ||
--pretrain_mm_input_adapter ./checkpoints/pretrain/mm_input_projector.bin \ | ||
--tune_mm_input_adapter True \ | ||
--freeze_mm_input_adapter False \ | ||
--mm_input_projector_type mlp \ | ||
--mm_use_vid_start_end False \ | ||
--mm_use_vid_patch_token False \ | ||
--image_aspect_ratio pad \ | ||
--bf16 True \ | ||
--output_dir ./checkpoints/finetune \ | ||
--num_train_epochs 1 \ | ||
--per_device_train_batch_size 32 \ | ||
--per_device_eval_batch_size 4 \ | ||
--gradient_accumulation_steps 1 \ | ||
--evaluation_strategy "no" \ | ||
--save_strategy "steps" \ | ||
--save_steps 50000 \ | ||
--save_total_limit 1 \ | ||
--learning_rate 2e-4 \ | ||
--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 tensorboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import argparse | ||
from motionepic.model.builder import load_pretrained_model | ||
from motionepic.mm_utils import get_model_name_from_path | ||
|
||
|
||
def merge_lora(args): | ||
# model_name = get_model_name_from_path(args.model_path) | ||
model_name = 'motionepic-v1.5-7b-lora' | ||
tokenizer, model, video_processor, context_len, model_config = load_pretrained_model(args.model_path, args.model_base, model_name, device_map='cpu') | ||
|
||
model.save_pretrained(args.save_model_path) | ||
tokenizer.save_pretrained(args.save_model_path) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--model-path", type=str, default='./checkpoints/finetune') | ||
parser.add_argument("--model-base", type=str, default='./checkpoints/pretrain') | ||
parser.add_argument("--save-model-path", type=str, default='./checkpoints/motionepic-v1.5-7b-lora') | ||
|
||
args = parser.parse_args() | ||
|
||
merge_lora(args) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
CONTROLLER_HEART_BEAT_EXPIRATION = 30 | ||
WORKER_HEART_BEAT_INTERVAL = 15 | ||
LOGDIR = "." | ||
IGNORE_INDEX = -100 | ||
VIDEO_TOKEN_INDEX = -300 | ||
DEFAULT_VIDEO_TOKEN = "<video>" | ||
DEFAULT_VIDEO_PATCH_TOKEN = "<vid_patch>" | ||
DEFAULT_VID_START_TOKEN = "<vid_start>" | ||
DEFAULT_VID_END_TOKEN = "<vid_end>" | ||
VIDEO_PLACEHOLDER = "<video-placeholder>" | ||
MAX_VIDEO_LENGTH = 16 | ||
|
||
SG_TOKEN_INDEX = -200 | ||
MAX_SG_LENGTH = 16 | ||
SG_PLACEHOLDER = "<sg-placeholder>" | ||
DEFAULT_SG_TOKEN = "<sg>" | ||
DEFAULT_SG_PATCH_TOKEN = "<sg_patch>" | ||
DEFAULT_SG_START_TOKEN = "<sg_start>" | ||
DEFAULT_SG_END_TOKEN = "<sg_end>" | ||
|
||
|
||
|
Oops, something went wrong.