Commit
·
cfd45a6
1
Parent(s):
ea216fe
Removed dependency on icecream
Browse files- modeling_mplug_owl2.py +1 -6
- visual_encoder.py +1 -2
modeling_mplug_owl2.py
CHANGED
|
@@ -37,7 +37,6 @@ from .modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
|
|
| 37 |
IGNORE_INDEX = -100
|
| 38 |
IMAGE_TOKEN_INDEX = -200
|
| 39 |
DEFAULT_IMAGE_TOKEN = "<|image|>"
|
| 40 |
-
from icecream import ic
|
| 41 |
|
| 42 |
def tokenizer_image_token(prompt, tokenizer, image_token_index=IMAGE_TOKEN_INDEX, return_tensors=None):
|
| 43 |
prompt_chunks = [tokenizer(chunk).input_ids if len(chunk) > 0 else [] for chunk in prompt.split(DEFAULT_IMAGE_TOKEN)]
|
|
@@ -391,7 +390,6 @@ replace_llama_modality_adaptive()
|
|
| 391 |
|
| 392 |
if __name__ == "__main__":
|
| 393 |
config = MPLUGOwl2Config.from_pretrained('q-future/one-align')
|
| 394 |
-
from icecream import ic
|
| 395 |
# config = MPLUGOwl2Config()
|
| 396 |
model = AutoModelForCausalLM(config)
|
| 397 |
|
|
@@ -403,10 +401,7 @@ if __name__ == "__main__":
|
|
| 403 |
labels[labels < 0] = -100
|
| 404 |
|
| 405 |
# image_feature = model.encode_images(images)
|
| 406 |
-
# ic(image_feature.shape)
|
| 407 |
|
| 408 |
output = model(images=images, input_ids=input_ids, labels=labels)
|
| 409 |
-
ic(output.loss)
|
| 410 |
-
ic(output.logits.shape)
|
| 411 |
|
| 412 |
-
model.save_pretrained('/cpfs01/shared/public/test/tmp_owl')
|
|
|
|
| 37 |
IGNORE_INDEX = -100
|
| 38 |
IMAGE_TOKEN_INDEX = -200
|
| 39 |
DEFAULT_IMAGE_TOKEN = "<|image|>"
|
|
|
|
| 40 |
|
| 41 |
def tokenizer_image_token(prompt, tokenizer, image_token_index=IMAGE_TOKEN_INDEX, return_tensors=None):
|
| 42 |
prompt_chunks = [tokenizer(chunk).input_ids if len(chunk) > 0 else [] for chunk in prompt.split(DEFAULT_IMAGE_TOKEN)]
|
|
|
|
| 390 |
|
| 391 |
if __name__ == "__main__":
|
| 392 |
config = MPLUGOwl2Config.from_pretrained('q-future/one-align')
|
|
|
|
| 393 |
# config = MPLUGOwl2Config()
|
| 394 |
model = AutoModelForCausalLM(config)
|
| 395 |
|
|
|
|
| 401 |
labels[labels < 0] = -100
|
| 402 |
|
| 403 |
# image_feature = model.encode_images(images)
|
|
|
|
| 404 |
|
| 405 |
output = model(images=images, input_ids=input_ids, labels=labels)
|
|
|
|
|
|
|
| 406 |
|
| 407 |
+
model.save_pretrained('/cpfs01/shared/public/test/tmp_owl')
|
visual_encoder.py
CHANGED
|
@@ -9,7 +9,6 @@ import numpy as np
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
import torch.utils.checkpoint
|
| 12 |
-
from icecream import ic
|
| 13 |
|
| 14 |
def get_abs_pos(abs_pos, tgt_size):
|
| 15 |
# abs_pos: L, C
|
|
@@ -919,4 +918,4 @@ class MplugOwlVisualAbstractorModel(PreTrainedModel):
|
|
| 919 |
hidden_states=encoder_outputs.hidden_states,
|
| 920 |
)
|
| 921 |
|
| 922 |
-
|
|
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
import torch.utils.checkpoint
|
|
|
|
| 12 |
|
| 13 |
def get_abs_pos(abs_pos, tgt_size):
|
| 14 |
# abs_pos: L, C
|
|
|
|
| 918 |
hidden_states=encoder_outputs.hidden_states,
|
| 919 |
)
|
| 920 |
|
| 921 |
+
|