|
import ml_collections |
|
|
|
YOUCOOK_TRAIN_SIZE = 1333 |
|
|
|
|
|
def get_config(runlocal=''): |
|
"""Returns the base experiment configuration.""" |
|
|
|
runlocal = bool(runlocal) |
|
|
|
config = ml_collections.ConfigDict() |
|
config.token_loss_coef = 1. |
|
config.runlocal = runlocal |
|
config.experiment_name = 'youcook' |
|
|
|
config.count_flops = False |
|
|
|
|
|
config.dataset_name = 'dense_video_captioning' |
|
config.dataset_configs = ml_collections.ConfigDict() |
|
config.dataset_configs.corrupt = 0. |
|
config.dataset_configs.span_len = 3. |
|
config.dataset_configs.preserve = True |
|
config.dataset_configs.corrupt_coef = 0. |
|
config.dataset_configs.proba_corrupt = 0. |
|
notime = ml_collections.config_dict.FieldReference(False) |
|
config.dataset_configs.notime = notime |
|
config.dataset_configs.abs_time_token = False |
|
config.dataset_configs.random_temporal_crop_proba = 0.5 |
|
config.dataset_configs.time_format = 'se' |
|
tmp_only = ml_collections.config_dict.FieldReference(False) |
|
config.dataset_configs.tmp_only = tmp_only |
|
config.dataset_configs.split = False |
|
order = ml_collections.config_dict.FieldReference('ld') |
|
config.dataset_configs.order = order |
|
config.dataset_configs.from_xm = None |
|
|
|
config.data_dtype_str = 'float32' |
|
|
|
config.dataset_configs.base_dir = '/mnt/petrelfs/wangyiqin/vid_cap/examples' |
|
config.dataset_configs.tables = { |
|
'train': 'train.tfrecord.sst@64', |
|
'validation': 'test@1', |
|
} |
|
config.dataset_configs.examples_per_subset = { |
|
'train': 0, |
|
'validation': 1, |
|
} |
|
|
|
|
|
|
|
|
|
config.dataset_configs.modalities = ('features', 'text') |
|
config.dataset_configs.features_dim = 768 |
|
config.dataset_configs.return_as_dict = True |
|
num_frames = ml_collections.config_dict.FieldReference( |
|
100) |
|
config.dataset_configs.num_frames = num_frames |
|
num_bins = ml_collections.config_dict.FieldReference(100) |
|
config.dataset_configs.num_bins = num_bins |
|
config.dataset_configs.one_hot_labels = True |
|
config.dataset_configs.zero_centering = True |
|
config.dataset_configs.val_on_test = False |
|
config.dataset_configs.num_eval_clips = 1 |
|
config.dataset_configs.prefetch_to_device = 2 |
|
|
|
|
|
config.dataset_configs.max_num_output_words = 256 |
|
config.dataset_configs.max_num_input_words = 1000 |
|
config.dataset_configs.tokenizer = ml_collections.ConfigDict() |
|
config.dataset_configs.tokenizer.tokenizer_type = 'sentence_piece' |
|
config.dataset_configs.caption_string = 'caption/string' |
|
config.dataset_configs.train_caption_string = 'caption/string' |
|
config.dataset_configs.input_timestamp_name = 'video/timestamps' |
|
config.dataset_configs.input_duration_name = 'video/duration' |
|
config.dataset_configs.output_raw_timestamp_name = 'timestamp' |
|
config.dataset_configs.output_raw_duration_name = 'duration' |
|
config.dataset_configs.input_feature_name = 'image/clip_embeddings' |
|
config.dataset_configs.output_raw_feature_name = 'features' |
|
config.dataset_configs.vocabulary_size = 32128 |
|
config.dataset_configs.max_events = 20 |
|
config.dataset_configs.asr_notime = False |
|
config.datasets = {'youcook': config.dataset_configs} |
|
|
|
|
|
config.decoding = ml_collections.ConfigDict() |
|
config.decoding.decoding_method = 'beamsearch' |
|
|
|
config.decoding.num_decodes = 4 |
|
config.decoding.alpha = 1 |
|
config.decoding.temperature = 1. |
|
|
|
|
|
config.model_name = 'vid2seq' |
|
config.model = ml_collections.ConfigDict() |
|
config.model.from_xm = None |
|
|
|
|
|
config.model.encoder = ml_collections.ConfigDict() |
|
config.model.encoder.share_encoder = True |
|
config.model.encoder.encoder_type = 'cat_encoder' |
|
config.model.encoder.cat_encoder = ml_collections.ConfigDict() |
|
config.model.encoder.cat_encoder.dim = 2048 |
|
config.model.encoder.cat_encoder.layers = 12 |
|
config.model.encoder.cat_encoder.heads = 12 |
|
config.model.encoder.cat_encoder.pos_embed = 'learned_1d' |
|
config.model.encoder.cat_encoder.dropout_rate = 0. |
|
config.model.encoder.cat_encoder.t5_dropout_rate = 0.1 |
|
config.model.encoder.cat_encoder.stochastic_depth = 0. |
|
config.model.encoder.cat_encoder.pretrained_config = 't5_1_1_base' |
|
config.model.encoder.from_xm = None |
|
|
|
|
|
config.model.decoder_type = 't5_decoder' |
|
config.model.decoder = ml_collections.ConfigDict() |
|
config.model.decoder.order = order |
|
config.model.decoder.t5_decoder = ml_collections.ConfigDict() |
|
config.model.decoder.t5_decoder.logits_via_embedding = False |
|
config.model.decoder.t5_decoder.dropout_rate = 0.1 |
|
config.model.decoder.t5_decoder.num_frames = num_frames |
|
config.model.decoder.notime = notime |
|
config.model.decoder.num_bins = num_bins |
|
config.model.decoder.tmp_only = tmp_only |
|
config.model.decoder.t5_decoder.pretrained_config = 't5_1_1_base' |
|
|
|
|
|
config.init_from = ml_collections.ConfigDict() |
|
|
|
|
|
config.init_from.checkpoint_path = '/mnt/petrelfs/wangyiqin/vid_cap/vid2seq_model' |
|
|
|
config.init_from.step = 200001 |
|
|
|
config.init_from.encoder = ml_collections.ConfigDict() |
|
config.init_from.encoder.checkpoint_path = None |
|
config.init_from.encoder.init_from_vit = False |
|
config.init_from.encoder = ml_collections.ConfigDict() |
|
config.init_from.encoder.load_pretrained_weights = True |
|
|
|
config.init_from.decoder = ml_collections.ConfigDict() |
|
config.init_from.decoder.load_pretrained_weights = True |
|
|
|
config.init_from.t5 = ml_collections.ConfigDict() |
|
config.init_from.t5.load_pretrained_weights = True |
|
|
|
|
|
config.trainer_name = 'densevidcap_trainer' |
|
config.optimizer = 'adam' |
|
config.optimizer_configs = ml_collections.ConfigDict() |
|
config.optimizer_configs.weight_decay = 0. |
|
config.l2_decay_factor = 0. |
|
config.max_grad_norm = 1. |
|
config.label_smoothing = 0.1 |
|
epochs = ml_collections.config_dict.FieldReference(0) |
|
config.num_training_epochs = 0 |
|
batch_size = ml_collections.config_dict.FieldReference(1) |
|
config.batch_size = 1 |
|
config.eval_batch_size = 1 |
|
config.rng_seed = 0 |
|
|
|
|
|
steps_per_epoch = 3 if runlocal else YOUCOOK_TRAIN_SIZE // batch_size |
|
total_steps = epochs * steps_per_epoch |
|
config.lr_configs = ml_collections.ConfigDict() |
|
config.lr_configs.learning_rate_schedule = 'compound' |
|
config.lr_configs.factors = 'constant * cosine_decay * linear_warmup' |
|
config.lr_configs.warmup_steps = total_steps // 10 |
|
config.lr_configs.steps_per_cycle = total_steps |
|
config.lr_configs.total_steps = total_steps |
|
config.lr_configs.base_learning_rate = 3e-4 |
|
|
|
config.eval_metrics = ['cider', 'meteor', 'soda'] |
|
|
|
|
|
config.log_eval_steps = steps_per_epoch |
|
config.log_summary_steps = steps_per_epoch |
|
config.write_summary = True |
|
config.write_xm_measurements = True |
|
config.xprof = True |
|
config.checkpoint = True |
|
config.debug_train = False |
|
config.debug_eval = True |
|
return config |
|
|