Image-to-Text
Transformers
PyTorch
English
mplug_owl2
feature-extraction
image-quality-assessment
document-quality
mplug-owl2
vision-language
document-analysis
IQA
custom_code
Instructions to use mapo80/DeQA-Doc-Overall with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mapo80/DeQA-Doc-Overall with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="mapo80/DeQA-Doc-Overall", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mapo80/DeQA-Doc-Overall", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
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"]
|