Rustamshry commited on
Commit
ca62d0e
·
verified ·
1 Parent(s): 5b1863e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -14,5 +14,27 @@ language:
14
  ## How to Get Started with the Model
15
 
16
  ```python
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ```
 
14
  ## How to Get Started with the Model
15
 
16
  ```python
17
+ from transformers import AutoProcessor, AutoModelForImageTextToText
18
 
19
+ processor = AutoProcessor.from_pretrained("khazarai/Math-VL-8B")
20
+ model = AutoModelForImageTextToText.from_pretrained("khazarai/Math-VL-8B")
21
+ messages = [
22
+ {
23
+ "role": "user",
24
+ "content": [
25
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
26
+ {"type": "text", "text": "Resimde verilen matematik problemini çözün."}
27
+ ]
28
+ },
29
+ ]
30
+ inputs = processor.apply_chat_template(
31
+ messages,
32
+ add_generation_prompt=True,
33
+ tokenize=True,
34
+ return_dict=True,
35
+ return_tensors="pt",
36
+ ).to(model.device)
37
+
38
+ outputs = model.generate(**inputs, max_new_tokens=40)
39
+ print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
40
  ```