phani50101 commited on
Commit
69ec161
·
verified ·
1 Parent(s): fb5b332

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -147
README.md CHANGED
@@ -1,147 +0,0 @@
1
- ---
2
- license: mit
3
- language:
4
- - multilingual
5
- pipeline_tag: image-text-to-text
6
- tags:
7
- - nlp
8
- - vision
9
- - internvl
10
- base_model:
11
- - OpenGVLab/InternVL2-1B
12
- base_model_relation: quantized
13
- ---
14
-
15
- # InternVL2-1B-int8-ov
16
-
17
- * Model creator: [OpenGVLab](https://huggingface.co/OpenGVLab)
18
- * Original model: [InternVL2-1B](https://huggingface.co/OpenGVLab/InternVL2-1B)
19
-
20
- ## Description
21
-
22
- This is [OpenGVLab/InternVL2-1B](https://huggingface.co/OpenGVLab/InternVL2-1B) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT8 by [NNCF](https://github.com/openvinotoolkit/nncf).
23
-
24
-
25
- ## Quantization Parameters
26
-
27
- Weight compression was performed using `nncf.compress_weights` with the following parameters:
28
- * mode: **INT8_ASYM**
29
-
30
- ## Compatibility
31
-
32
- The provided OpenVINO™ IR model is compatible with:
33
-
34
- * OpenVINO version 2025.0.0 and higher
35
- * Optimum Intel 1.21.0 and higher
36
-
37
- ## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
38
-
39
- 1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
40
-
41
- ```
42
- pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino_tokenizers openvino
43
-
44
- pip install git+https://github.com/huggingface/optimum-intel.git
45
- ```
46
-
47
- 2. Run model inference
48
-
49
- ```
50
- from PIL import Image
51
- import requests
52
- from optimum.intel.openvino import OVModelForVisualCausalLM
53
- from transformers import AutoTokenizer, TextStreamer
54
-
55
- model_id = "OpenVINO/InternVL2-1B-int8-ov"
56
-
57
- tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
58
-
59
- ov_model = OVModelForVisualCausalLM.from_pretrained(model_id, trust_remote_code=True)
60
- prompt = "What is unusual on this picture?"
61
-
62
- url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
63
- image = Image.open(requests.get(url, stream=True).raw)
64
-
65
- inputs = ov_model.preprocess_inputs(text=prompt, image=image, tokenizer=tokenizer, config=ov_model.config)
66
-
67
- generation_args = {
68
- "max_new_tokens": 100,
69
- "streamer": TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
70
- }
71
-
72
- generate_ids = ov_model.generate(**inputs, **generation_args)
73
-
74
- generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
75
- response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
76
-
77
- ```
78
-
79
- ## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
80
-
81
- 1. Install packages required for using OpenVINO GenAI.
82
- ```
83
- pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino openvino-tokenizers openvino-genai
84
-
85
- pip install huggingface_hub
86
- ```
87
-
88
- 2. Download model from HuggingFace Hub
89
-
90
- ```
91
- import huggingface_hub as hf_hub
92
-
93
- model_id = "OpenVINO/InternVL2-1B-int8-ov"
94
- model_path = "InternVL2-1B-int8-ov"
95
-
96
- hf_hub.snapshot_download(model_id, local_dir=model_path)
97
-
98
- ```
99
-
100
- 1. Run model inference:
101
-
102
- ```
103
- import openvino_genai as ov_genai
104
- import requests
105
- from PIL import Image
106
- from io import BytesIO
107
- import numpy as np
108
- import openvino as ov
109
-
110
- device = "CPU"
111
- pipe = ov_genai.VLMPipeline(model_path, device)
112
-
113
- def load_image(image_file):
114
- if isinstance(image_file, str) and (image_file.startswith("http") or image_file.startswith("https")):
115
- response = requests.get(image_file)
116
- image = Image.open(BytesIO(response.content)).convert("RGB")
117
- else:
118
- image = Image.open(image_file).convert("RGB")
119
- image_data = np.array(image.getdata()).reshape(1, image.size[1], image.size[0], 3).astype(np.byte)
120
- return ov.Tensor(image_data)
121
-
122
- prompt = "What is unusual on this picture?"
123
-
124
- url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
125
- image_tensor = load_image(url)
126
-
127
- def streamer(subword: str) -> bool:
128
- print(subword, end="", flush=True)
129
- return False
130
-
131
- pipe.start_chat()
132
- output = pipe.generate(prompt, image=image_tensor, max_new_tokens=100, streamer=streamer)
133
- pipe.finish_chat()
134
- ```
135
-
136
- More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://github.com/openvinotoolkit/openvino.genai/blob/master/src/README.md) and [samples](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#openvino-genai-samples)
137
-
138
-
139
- ## Limitations
140
-
141
-
142
- Check the original [model card](https://huggingface.co/OpenGVLab/InternVL2-1B) for limitations.
143
-
144
- ## Legal information
145
-
146
- The original model is distributed under [MIT](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/mit.md) license. More details can be found in [original model card](https://huggingface.co/OpenGVLab/InternVL2-1B).
147
-