mapo80 commited on
Commit
3a6d599
·
verified ·
1 Parent(s): f1c4295

Upload modeling_mplug_owl2_huggingface.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. modeling_mplug_owl2_huggingface.py +5 -3
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
- # Get the actual model path from where this file is located
385
- model_path = os.path.dirname(os.path.abspath(__file__))
386
- self._tokenizer = AutoTokenizer.from_pretrained(model_path)
 
 
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"]