Instructions to use DataCanvas/MMAlaya with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DataCanvas/MMAlaya 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="DataCanvas/MMAlaya", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("DataCanvas/MMAlaya", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload 18 files
Browse files- inference.py +1 -1
- modeling_mmalaya.py +3 -3
inference.py
CHANGED
|
@@ -43,7 +43,7 @@ def main(args):
|
|
| 43 |
stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
|
| 44 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, timeout=20.0)
|
| 45 |
# 加载图像
|
| 46 |
-
image = Image.open('./
|
| 47 |
image_tensor = image_processor(image, return_tensors='pt')['pixel_values'].half().cuda()
|
| 48 |
# 推理
|
| 49 |
with torch.inference_mode():
|
|
|
|
| 43 |
stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
|
| 44 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, timeout=20.0)
|
| 45 |
# 加载图像
|
| 46 |
+
image = Image.open('./chang_chen.jpg').convert("RGB")
|
| 47 |
image_tensor = image_processor(image, return_tensors='pt')['pixel_values'].half().cuda()
|
| 48 |
# 推理
|
| 49 |
with torch.inference_mode():
|
modeling_mmalaya.py
CHANGED
|
@@ -8,9 +8,9 @@ import math
|
|
| 8 |
from transformers import AutoConfig, AutoModelForCausalLM
|
| 9 |
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 10 |
|
| 11 |
-
from
|
| 12 |
-
from mmalaya_arch import MMAlayaMetaModel, MMAlayaMetaForCausalLM
|
| 13 |
-
from configuration_mmalaya import MMAlayaMPTConfig
|
| 14 |
|
| 15 |
|
| 16 |
class MMAlayaMPTModel(MMAlayaMetaModel, MPTModel):
|
|
|
|
| 8 |
from transformers import AutoConfig, AutoModelForCausalLM
|
| 9 |
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 10 |
|
| 11 |
+
from .modeling_mpt import MPTConfig, MPTForCausalLM, MPTModel
|
| 12 |
+
from .mmalaya_arch import MMAlayaMetaModel, MMAlayaMetaForCausalLM
|
| 13 |
+
from .configuration_mmalaya import MMAlayaMPTConfig
|
| 14 |
|
| 15 |
|
| 16 |
class MMAlayaMPTModel(MMAlayaMetaModel, MPTModel):
|