Update README.md
Browse files
README.md
CHANGED
@@ -30,23 +30,34 @@ from PIL import Image
|
|
30 |
|
31 |
import torch
|
32 |
from transformers import AutoProcessor
|
33 |
-
from heron.models.git_llm.git_llama import GitLlamaForCausalLM
|
34 |
|
35 |
device_id = 0
|
36 |
|
37 |
# prepare a pretrained model
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
model.eval()
|
40 |
model.to(f"cuda:{device_id}")
|
41 |
|
42 |
# prepare a processor
|
43 |
-
processor = AutoProcessor.from_pretrained(
|
44 |
|
45 |
# prepare inputs
|
46 |
url = "https://www.barnorama.com/wp-content/uploads/2016/12/03-Confusing-Pictures.jpg"
|
47 |
image = Image.open(requests.get(url, stream=True).raw)
|
48 |
|
49 |
-
text = f"##human: What is this picture
|
50 |
|
51 |
# do preprocessing
|
52 |
inputs = processor(
|
|
|
30 |
|
31 |
import torch
|
32 |
from transformers import AutoProcessor
|
33 |
+
from heron.models.git_llm.git_llama import GitLlamaConfig, GitLlamaForCausalLM
|
34 |
|
35 |
device_id = 0
|
36 |
|
37 |
# prepare a pretrained model
|
38 |
+
MODEL_NAME = 'turing-motors/heron-chat-git-Llama-2-7b-v0'
|
39 |
+
|
40 |
+
git_config = GitLlamaConfig.from_pretrained(MODEL_NAME)
|
41 |
+
git_config.set_vision_configs(
|
42 |
+
num_image_with_embedding=1, vision_model_name=git_config.vision_model_name
|
43 |
+
)
|
44 |
+
model = GitLlamaForCausalLM.from_pretrained(
|
45 |
+
MODEL_NAME, config=git_config, torch_dtype=torch.float16
|
46 |
+
)
|
47 |
+
|
48 |
+
|
49 |
+
model = GitLlamaForCausalLM.from_pretrained(MODEL_NAME)
|
50 |
model.eval()
|
51 |
model.to(f"cuda:{device_id}")
|
52 |
|
53 |
# prepare a processor
|
54 |
+
processor = AutoProcessor.from_pretrained(MODEL_NAME)
|
55 |
|
56 |
# prepare inputs
|
57 |
url = "https://www.barnorama.com/wp-content/uploads/2016/12/03-Confusing-Pictures.jpg"
|
58 |
image = Image.open(requests.get(url, stream=True).raw)
|
59 |
|
60 |
+
text = f"##human: What is this picture?\n##gpt: "
|
61 |
|
62 |
# do preprocessing
|
63 |
inputs = processor(
|