Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.
Open

Test #149

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b597a75
Remove some errors
YifeiLin0226 Apr 18, 2025
5a7d824
add notebook & directly used finetuned result
YifeiLin0226 Apr 18, 2025
feee3ce
rename evaluation result of the given finetuned checkpoint
YifeiLin0226 Apr 19, 2025
a0d1f2b
Upload our own finetuned result + config + notebook
YifeiLin0226 Apr 19, 2025
9f32a82
Remove distributed mode in evaluation
YifeiLin0226 Apr 19, 2025
83564f0
Created using Colab
VickieRanran Apr 19, 2025
411516d
Created using Colab
VickieRanran Apr 19, 2025
e083025
Created using Colab
VickieRanran Apr 19, 2025
313836e
Created using Colab
VickieRanran Apr 19, 2025
3880611
Created using Colab
VickieRanran Apr 19, 2025
0890a4c
Created using Colab
VickieRanran Apr 19, 2025
ee61ec7
Created using Colab
VickieRanran Apr 19, 2025
ff1063a
Created using Colab
VickieRanran Apr 19, 2025
3aec524
Created using Colab
VickieRanran Apr 19, 2025
9e66915
Created using Colab
VickieRanran Apr 19, 2025
860d5d0
Created using Colab
VickieRanran Apr 19, 2025
320a75f
Created using Colab
VickieRanran Apr 19, 2025
381ab66
Created using Colab
VickieRanran Apr 19, 2025
95ebb92
Created using Colab
VickieRanran Apr 19, 2025
a087acb
Created using Colab
VickieRanran Apr 19, 2025
52749d4
Created using Colab
VickieRanran Apr 19, 2025
c95a636
Created using Colab
VickieRanran Apr 19, 2025
01d3bb8
Created using Colab
VickieRanran Apr 19, 2025
77f2858
Created using Colab
VickieRanran Apr 19, 2025
2563f05
Created using Colab
VickieRanran Apr 19, 2025
058eb3c
Created using Colab
VickieRanran Apr 19, 2025
607e9d1
Created using Colab
VickieRanran Apr 19, 2025
5ead711
Created using Colab
VickieRanran Apr 19, 2025
f2632a5
Created using Colab
VickieRanran Apr 19, 2025
b092d7b
Created using Colab
VickieRanran Apr 19, 2025
14454d7
Created using Colab
VickieRanran Apr 19, 2025
3827588
Created using Colab
VickieRanran Apr 19, 2025
8321ca3
Created using Colab
VickieRanran Apr 19, 2025
cc71a16
Created using Colab
VickieRanran Apr 19, 2025
0993d3e
Created using Colab
VickieRanran Apr 19, 2025
153974e
Created using Colab
VickieRanran Apr 19, 2025
322ca39
clean up the code
VickieRanran Apr 20, 2025
beeca25
Created using Colab
VickieRanran Apr 20, 2025
5cbae41
Created using Colab
VickieRanran Apr 20, 2025
0bd4f0c
Created using Colab
VickieRanran Apr 20, 2025
b35ddb2
Created using Colab
VickieRanran Apr 23, 2025
d83d818
Created using Colab
VickieRanran Apr 24, 2025
4104edc
Created using Colab
VickieRanran Apr 24, 2025
a70a1dc
Created using Colab
VickieRanran Apr 24, 2025
54edfc6
Created using Colab
VickieRanran Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,715 changes: 2,715 additions & 0 deletions ALBEF.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ALBEF_finetune.ipynb

Large diffs are not rendered by default.

1,501 changes: 1,501 additions & 0 deletions Pretrain.ipynb

Large diffs are not rendered by default.

676 changes: 676 additions & 0 deletions VQA.yaml

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions configs/VQA.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
train_file: ['data/vqa_train.json',
'data/vqa_val.json',
'data/vg_qa.json']
'data/vqa_val.json',
# 'data/vg_qa.json'
]

test_file: ['data/vqa_test.json']
answer_list: 'data/answer_list.json'

vqa_root: '/export/share/datasets/vision/VQA/Images/mscoco/' #train2014/
vg_root: '/export/share/datasets/vision/visual-genome/' #image/
vqa_root: 'data/' #train2014/
vg_root: 'data/' #image/

image_res: 384
batch_size_train: 32
Expand Down
2 changes: 1 addition & 1 deletion configs/config_bert.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"max_position_embeddings": 512,
"model_type": "bert",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"num_hidden_layers": 3,
"pad_token_id": 0,
"type_vocab_size": 2,
"vocab_size": 30522,
Expand Down
4 changes: 2 additions & 2 deletions dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def save_result(result, result_dir, filename, is_json=True, is_list=True):
final_result_file = os.path.join(result_dir, '%s.pth'%filename)
torch.save(result,result_file)

dist.barrier()
# dist.barrier()

if utils.is_main_process():
# combine results from all processes
Expand All @@ -141,7 +141,7 @@ def save_result(result, result_dir, filename, is_json=True, is_list=True):
torch.save(result,final_result_file)

print('result file saved to %s'%final_result_file)
dist.barrier()
# dist.barrier()
return final_result_file


Expand Down
6 changes: 3 additions & 3 deletions models/model_vqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ def __init__(self,
self.distill = config['distill']

self.visual_encoder = VisionTransformer(
img_size=config['image_res'], patch_size=16, embed_dim=768, depth=12, num_heads=12,
img_size=config['image_res'], patch_size=16, embed_dim=768, depth=6, num_heads=12,
mlp_ratio=4, qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6))

config_encoder = BertConfig.from_json_file(config['bert_config'])
self.text_encoder = BertModel.from_pretrained(text_encoder, config=config_encoder, add_pooling_layer=False)

config_decoder = BertConfig.from_json_file(config['bert_config'])
config_decoder.fusion_layer = 0
config_decoder.num_hidden_layers = 6
config_decoder.num_hidden_layers = 3
self.text_decoder = BertLMHeadModel.from_pretrained(text_decoder, config=config_decoder)

if self.distill:
self.visual_encoder_m = VisionTransformer(
img_size=config['image_res'], patch_size=16, embed_dim=768, depth=12, num_heads=12,
img_size=config['image_res'], patch_size=16, embed_dim=768, depth=6, num_heads=12,
mlp_ratio=4, qkv_bias=True, norm_layer=partial(nn.LayerNorm, eps=1e-6))
self.text_encoder_m = BertModel.from_pretrained(text_encoder, config=config_encoder, add_pooling_layer=False)
self.text_decoder_m = BertLMHeadModel.from_pretrained(text_decoder, config=config_decoder)
Expand Down
12 changes: 6 additions & 6 deletions models/xbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ class PreTrainedModel

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=BaseModelOutputWithPoolingAndCrossAttentions,
config_class=_CONFIG_FOR_DOC,
Expand Down Expand Up @@ -1362,7 +1362,7 @@ def set_output_embeddings(self, new_embeddings):

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=MaskedLMOutput,
config_class=_CONFIG_FOR_DOC,
Expand Down Expand Up @@ -1567,7 +1567,7 @@ def __init__(self, config):

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=SequenceClassifierOutput,
config_class=_CONFIG_FOR_DOC,
Expand Down Expand Up @@ -1651,7 +1651,7 @@ def __init__(self, config):

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, num_choices, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=MultipleChoiceModelOutput,
config_class=_CONFIG_FOR_DOC,
Expand Down Expand Up @@ -1746,7 +1746,7 @@ def __init__(self, config):

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=TokenClassifierOutput,
config_class=_CONFIG_FOR_DOC,
Expand Down Expand Up @@ -1836,7 +1836,7 @@ def __init__(self, config):

@add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
@add_code_sample_docstrings(
tokenizer_class=_TOKENIZER_FOR_DOC,
processor_class=_TOKENIZER_FOR_DOC,
checkpoint="bert-base-uncased",
output_type=QuestionAnsweringModelOutput,
config_class=_CONFIG_FOR_DOC,
Expand Down
17 changes: 17 additions & 0 deletions output_eval/vqa/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
alpha: 0.4
answer_list: data/answer_list.json
batch_size_test: 32
batch_size_train: 32
bert_config: configs/config_bert.json
distill: true
eos: '[SEP]'
image_res: 384
k_test: 128
optimizer: {lr: 2e-05, opt: adamW, weight_decay: 0.02}
schedular: {cooldown_epochs: 0, decay_rate: 1, epochs: 8, lr: 2e-05, min_lr: 1e-06,
sched: cosine, warmup_epochs: 4, warmup_lr: 1e-05}
test_file: [data/vqa_test.json]
train_file: [data/vqa_train.json]
vg_root: data/
vqa_root: data/
warm_up: true
1 change: 1 addition & 0 deletions output_eval/vqa/result/vqa_result_epoch0.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions output_eval/vqa/result/vqa_result_epoch0_rank0.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions output_finetune/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
alpha: 0.4
answer_list: data/answer_list.json
batch_size_test: 16
batch_size_train: 32
bert_config: configs/config_bert.json
distill: true
eos: '[SEP]'
image_res: 384
k_test: 128
optimizer: {lr: 2e-05, opt: adamW, weight_decay: 0.02}
schedular: {cooldown_epochs: 0, decay_rate: 1, epochs: 8, lr: 2e-05, min_lr: 1e-06,
sched: cosine, warmup_epochs: 4, warmup_lr: 1e-05}
test_file: [data/vqa_test.json]
train_file: [data/vqa_train.json, data/vqa_val.json]
vg_root: data/
vqa_root: data/
warm_up: true
8 changes: 8 additions & 0 deletions output_finetune/log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"train_lr": "0.000", "train_loss": "3.903", "epoch": 0}
{"train_lr": "0.000", "train_loss": "3.409", "epoch": 1}
{"train_lr": "0.000", "train_loss": "3.258", "epoch": 2}
{"train_lr": "0.000", "train_loss": "3.159", "epoch": 3}
{"train_lr": "0.000", "train_loss": "3.085", "epoch": 4}
{"train_lr": "0.000", "train_loss": "3.027", "epoch": 5}
{"train_lr": "0.000", "train_loss": "2.987", "epoch": 6}
{"train_lr": "0.000", "train_loss": "2.961", "epoch": 7}
1 change: 1 addition & 0 deletions output_finetune/result/vqa_result_epoch0.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions output_finetune/result/vqa_result_epoch0_rank0.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions output_finetune/result/vqa_result_epoch7.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions output_finetune/result/vqa_result_epoch7_rank0.json

Large diffs are not rendered by default.