Zhiding commited on
Commit
bc2bd09
1 Parent(s): 3c12542

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +131 -3
README.md CHANGED
@@ -1,3 +1,131 @@
1
- ---
2
- license: cc-by-nc-nd-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - Eagle
7
+ - VLM
8
+ ---
9
+
10
+ # Eagle Model Card
11
+
12
+ ## Model details
13
+
14
+ **Model type:**
15
+ Eagle is a family of Vision-Centric High-Resolution Multimodal LLMs. It presents a thorough exploration to strengthen multimodal LLM perception with a mixture of vision encoders and different input resolutions. The model contains a channel-concatenation-based "CLIP+X" fusion for vision experts with different architectures (ViT/ConvNets) and knowledge (detection/segmentation/OCR/SSL). The resulting family of Eagle models support up to over 1K input resolution and obtain strong results on multimodal LLM benchmarks, especially resolution-sensitive tasks such as optical character recognition and document understanding.
16
+
17
+
18
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64618b9496259bec21d44704/BdAIMvo--yG7SpG5xDeYN.png)
19
+
20
+ **Paper or resources for more information:**
21
+ https://github.com/NVlabs/Eagle
22
+
23
+ [arXiv](https://arxiv.org/pdf/2408.15998) / [Demo](https://huggingface.co/spaces/NVEagle/Eagle-X5-13B-Chat) / [Huggingface](https://huggingface.co/papers/2408.15998)
24
+
25
+ ```
26
+ @article{shi2024eagle,
27
+ title = {Eagle: Exploring The Design Space for Multimodal LLMs with Mixture of Encoders},
28
+ author={Min Shi and Fuxiao Liu and Shihao Wang and Shijia Liao and Subhashree Radhakrishnan and De-An Huang and Hongxu Yin and Karan Sapra and Yaser Yacoob and Humphrey Shi and Bryan Catanzaro and Andrew Tao and Jan Kautz and Zhiding Yu and Guilin Liu},
29
+ journal={arXiv:2408.15998},
30
+ year={2024}
31
+ }
32
+ ```
33
+
34
+ ## License
35
+ - The code is released under the Apache 2.0 license as found in the [LICENSE](./LICENSE) file.
36
+ - The pretrained weights are released under the [CC-BY-NC-SA-4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en).
37
+ - The service is a research preview intended for non-commercial use only, and is subject to the following licenses and terms:
38
+ - [Model License](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) of LLaMA
39
+ - [Terms of Use](https://openai.com/policies/terms-of-use) of the data generated by OpenAI
40
+ - [Dataset Licenses](https://github.com/Efficient-Large-Model/VILA/blob/main/data_prepare/LICENSE) for each one used during training.
41
+
42
+ **Where to send questions or comments about the model:**
43
+ https://github.com/NVlabs/Eagle/issues
44
+
45
+ ## Model Architecture:
46
+
47
+ **Architecture Type:** Transformer
48
+
49
+ ## Input:
50
+
51
+ **Input Type:** Image, Text
52
+
53
+ **Input Format:** Red, Green, Blue; String
54
+
55
+ ## Output:
56
+
57
+ **Output Type:** Text
58
+
59
+ **Output Format:** String
60
+
61
+ ## Inference:
62
+ ```
63
+ import os
64
+ import torch
65
+ import numpy as np
66
+ from eagle import conversation as conversation_lib
67
+ from eagle.constants import DEFAULT_IMAGE_TOKEN
68
+ from eagle.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN
69
+ from eagle.conversation import conv_templates, SeparatorStyle
70
+ from eagle.model.builder import load_pretrained_model
71
+ from eagle.utils import disable_torch_init
72
+ from eagle.mm_utils import tokenizer_image_token, get_model_name_from_path, process_images, KeywordsStoppingCriteria
73
+ from PIL import Image
74
+ import argparse
75
+ from transformers import TextIteratorStreamer
76
+ from threading import Thread
77
+
78
+ model_path = "NVEagle/Eagle-X5-13B-Chat"
79
+ conv_mode = "vicuna_v1"
80
+ image_path = "assets/georgia-tech.jpeg"
81
+ input_prompt = "Describe this image."
82
+
83
+ model_name = get_model_name_from_path(model_path)
84
+ tokenizer, model, image_processor, context_len = load_pretrained_model(model_path,None,model_name,False,False)
85
+ if model.config.mm_use_im_start_end:
86
+ input_prompt = DEFAULT_IM_START_TOKEN + DEFAULT_IMAGE_TOKEN + DEFAULT_IM_END_TOKEN + '\n' + input_prompt
87
+ else:
88
+ input_prompt = DEFAULT_IMAGE_TOKEN + '\n' + input_prompt
89
+
90
+ conv = conv_templates[conv_mode].copy()
91
+ conv.append_message(conv.roles[0], input_prompt)
92
+ conv.append_message(conv.roles[1], None)
93
+ prompt = conv.get_prompt()
94
+
95
+ image = Image.open(image_path).convert('RGB')
96
+ image_tensor = process_images([image], image_processor, model.config)[0]
97
+ input_ids = tokenizer_image_token(prompt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors='pt')
98
+
99
+ input_ids = input_ids.to(device='cuda', non_blocking=True)
100
+ image_tensor = image_tensor.to(dtype=torch.float16, device='cuda', non_blocking=True)
101
+
102
+ with torch.inference_mode():
103
+ output_ids = model.generate(
104
+ input_ids.unsqueeze(0),
105
+ images=image_tensor.unsqueeze(0),
106
+ image_sizes=[image.size],
107
+ do_sample=True,
108
+ temperature=0.2,
109
+ top_p=0.5,
110
+ num_beams=1,
111
+ max_new_tokens=256,
112
+ use_cache=True)
113
+
114
+ outputs = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip()
115
+ print(f"Image:{image_path} \nPrompt:{input_prompt} \nOutput:{outputs}")
116
+ ```
117
+
118
+
119
+ **[Preferred/Supported] Operating System(s):** <br>
120
+ Linux
121
+
122
+ ## Intended use
123
+ **Primary intended uses:**
124
+ The primary use of Eagle is research on large multimodal models and chatbots.
125
+
126
+ **Primary intended users:**
127
+ The primary intended users of the model are researchers and hobbyists in computer vision, natural language processing, machine learning, and artificial intelligence.
128
+
129
+ ## Ethical Considerations
130
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
131
+