shinyice commited on
Commit
7214688
1 Parent(s): 3172e36

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -7
README.md CHANGED
@@ -42,12 +42,6 @@ from llava.mm_utils import tokenizer_image_token, process_images
42
  model_path = "shinyice/chatvector-llava-v1.5-plus-houou-v3-7b"
43
  device = "cuda" if torch.cuda.is_available() else "cpu"
44
 
45
- image_url = "https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4/resolve/main/sample.jpg"
46
-
47
- temperature = 0.0
48
- top_p = 1.0
49
- max_new_tokens = 256
50
-
51
  model = LlavaLlamaForCausalLM.from_pretrained(
52
  model_path,
53
  device_map=device,
@@ -69,6 +63,7 @@ eos_token_id_list = [
69
  tokenizer.bos_token_id,
70
  ]
71
 
 
72
  image = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
73
 
74
  if not isinstance(image, list):
@@ -84,7 +79,8 @@ else:
84
 
85
  image_sizes_tensor = torch.tensor(image_sizes, dtype=torch.int32, device=device)
86
 
87
- conv_mode = "v1"
 
88
  conv = conv_templates[conv_mode].copy()
89
  prompt = "猫の隣には何がありますか?"
90
  inp = DEFAULT_IMAGE_TOKEN + '\n' + prompt
@@ -98,6 +94,12 @@ input_ids = tokenizer_image_token(
98
  IMAGE_TOKEN_INDEX,
99
  return_tensors='pt'
100
  ).unsqueeze(0)
 
 
 
 
 
 
101
 
102
  with torch.inference_mode():
103
  output = model.generate(
 
42
  model_path = "shinyice/chatvector-llava-v1.5-plus-houou-v3-7b"
43
  device = "cuda" if torch.cuda.is_available() else "cpu"
44
 
 
 
 
 
 
 
45
  model = LlavaLlamaForCausalLM.from_pretrained(
46
  model_path,
47
  device_map=device,
 
63
  tokenizer.bos_token_id,
64
  ]
65
 
66
+ image_url = "https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4/resolve/main/sample.jpg"
67
  image = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
68
 
69
  if not isinstance(image, list):
 
79
 
80
  image_sizes_tensor = torch.tensor(image_sizes, dtype=torch.int32, device=device)
81
 
82
+
83
+ conv_mode = "v1" #mistral_instruct
84
  conv = conv_templates[conv_mode].copy()
85
  prompt = "猫の隣には何がありますか?"
86
  inp = DEFAULT_IMAGE_TOKEN + '\n' + prompt
 
94
  IMAGE_TOKEN_INDEX,
95
  return_tensors='pt'
96
  ).unsqueeze(0)
97
+ if device == "cuda":
98
+ input_ids = input_ids.to(device)
99
+
100
+ temperature = 0.0
101
+ top_p = 1.0
102
+ max_new_tokens = 256
103
 
104
  with torch.inference_mode():
105
  output = model.generate(