model: Minicpmo (#3023)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import argparse
|
||||
|
||||
import PIL.Image
|
||||
import torch
|
||||
from data_utils import save_json
|
||||
from eval_utils import (
|
||||
@@ -10,22 +11,38 @@ from eval_utils import (
|
||||
process_result,
|
||||
)
|
||||
from tqdm import tqdm
|
||||
from transformers import AutoModelForImageTextToText, AutoProcessor, GenerationConfig
|
||||
from transformers import AutoModel, AutoProcessor, GenerationConfig
|
||||
|
||||
|
||||
@torch.no_grad()
|
||||
def eval_mmmu(args):
|
||||
eval_args = EvalArgs.from_cli_args(args)
|
||||
try:
|
||||
from transformers import AutoModelForImageTextToText
|
||||
|
||||
model = AutoModelForImageTextToText.from_pretrained(
|
||||
args.model_path,
|
||||
torch_dtype="auto",
|
||||
trust_remote_code=True,
|
||||
)
|
||||
except Exception as first_exception:
|
||||
try:
|
||||
model = AutoModel.from_pretrained(
|
||||
args.model_path,
|
||||
torch_dtype="auto",
|
||||
trust_remote_code=True,
|
||||
init_tts=False,
|
||||
)
|
||||
except Exception as second_exception:
|
||||
raise RuntimeError(
|
||||
f"Failed to load model: First attempt failed with {first_exception}, "
|
||||
f"second attempt failed with {second_exception}"
|
||||
) from second_exception
|
||||
|
||||
model = AutoModelForImageTextToText.from_pretrained(
|
||||
args.model_path,
|
||||
torch_dtype="auto",
|
||||
trust_remote_code=True,
|
||||
)
|
||||
model = model.eval().cuda()
|
||||
|
||||
processor = AutoProcessor.from_pretrained(
|
||||
args.model_path, torch_dtype="auto", device_map="auto"
|
||||
args.model_path, torch_dtype="auto", device_map="auto", trust_remote_code=True
|
||||
)
|
||||
|
||||
samples = prepare_samples(eval_args)
|
||||
|
||||
Reference in New Issue
Block a user