helenai commited on
Commit
e1ca814
·
verified ·
1 Parent(s): 3e2b86c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - microsoft/Phi-3.5-vision-instruct
4
+ ---
5
+
6
+ This is the [microsoft/Phi-3.5-vision-instruct](https://huggingface.co/microsoft/Phi-3.5-vision-instruct) model, converted to OpenVINO, with fp16 weights.
7
+
8
+ Use OpenVINO GenAI to run inference on this model:
9
+
10
+ - Install OpenVINO GenAI nightly and pillow:
11
+ ```
12
+ pip install --upgrade --pre pillow openvino-genai openvino openvino-tokenizers --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
13
+ ```
14
+ - Download a test image: `curl -O "https://storage.openvinotoolkit.org/test_data/images/dog.jpg"`
15
+ - Run inference:
16
+
17
+ ```python
18
+ import numpy as np
19
+ import openvino as ov
20
+ import openvino_genai
21
+ from PIL import Image
22
+
23
+ # Setting eos_token_id to tokenizer's eos token id is necessary for Phi-3.5-vision-instruct
24
+ config = openvino_genai.GenerationConfig()
25
+ config.set_eos_token_id(pipe.get_tokenizer().get_eos_token_id())
26
+ config.max_new_tokens = 100
27
+ # Choose GPU instead of CPU in the line below to run the model on Intel integrated or discrete GPU
28
+ pipe = openvino_genai.VLMPipeline("Phi-3.5-vision-instruct-ov-fp16", "CPU")
29
+
30
+ pipe.start_chat()
31
+
32
+ image = Image.open("dog.jpg")
33
+ image_data = np.array(image.getdata()).reshape(1, image.size[1], image.size[0], 3).astype(np.uint8)
34
+ image_data = ov.Tensor(image_data)
35
+
36
+ prompt = "Can you describe the image?"
37
+ result = pipe.generate(prompt, image=image_data, generation_config=config)
38
+ print(result.texts[0])
39
+ ```
40
+
41
+ See [OpenVINO GenAI repository](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#performing-visual-language-text-generation)