| import argparse | |
| import torch | |
| import os | |
| import json | |
| from tqdm import tqdm | |
| from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN | |
| from llava.conversation import conv_templates, SeparatorStyle | |
| from llava.model.builder import load_pretrained_model | |
| from llava.utils import disable_torch_init | |
| from llava.mm_utils import tokenizer_image_token, process_images, get_model_name_from_path | |
| from PIL import Image | |
| import math | |
| def get_model(model_path, model_base): | |
| model_path = os.path.expanduser(model_path) | |
| model_name = get_model_name_from_path(model_path) | |
| tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, model_base, model_name) | |
| return tokenizer, model |