Upload modeling_mplug_owl2_huggingface.py with huggingface_hub
Browse files
modeling_mplug_owl2_huggingface.py
CHANGED
|
@@ -381,9 +381,11 @@ class MPLUGOwl2LlamaForCausalLM(LlamaForCausalLM, MPLUGOwl2MetaForCausalLM):
|
|
| 381 |
def _init_processors(self):
|
| 382 |
"""Lazily initialize tokenizer and image processor from the model's directory."""
|
| 383 |
if self._tokenizer is None:
|
| 384 |
-
#
|
| 385 |
-
model_path =
|
| 386 |
-
|
|
|
|
|
|
|
| 387 |
self._image_processor = CLIPImageProcessor.from_pretrained(model_path)
|
| 388 |
self._preferential_ids = [id_[1] for id_ in self._tokenizer(
|
| 389 |
["excellent", "good", "fair", "poor", "bad"]
|
|
|
|
| 381 |
def _init_processors(self):
|
| 382 |
"""Lazily initialize tokenizer and image processor from the model's directory."""
|
| 383 |
if self._tokenizer is None:
|
| 384 |
+
# Use the model's name_or_path from config, fallback to HF repo name
|
| 385 |
+
model_path = getattr(self.config, '_name_or_path', None)
|
| 386 |
+
if model_path is None or model_path == './' or not model_path.startswith(('/', 'http', 'mapo80')):
|
| 387 |
+
model_path = "mapo80/DeQA-Doc-Overall"
|
| 388 |
+
self._tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
| 389 |
self._image_processor = CLIPImageProcessor.from_pretrained(model_path)
|
| 390 |
self._preferential_ids = [id_[1] for id_ in self._tokenizer(
|
| 391 |
["excellent", "good", "fair", "poor", "bad"]
|