velier commited on
Commit
e770f21
·
1 Parent(s): de8e22f

remove .cuda() expressions

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. modeling_GOT.py +6 -6
README.md CHANGED
@@ -42,7 +42,7 @@ from transformers import AutoModel, AutoTokenizer
42
 
43
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
44
  model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True, pad_token_id=tokenizer.eos_token_id)
45
- model = model.eval().cuda()
46
 
47
 
48
  # input your test image
 
42
 
43
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
44
  model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True, pad_token_id=tokenizer.eos_token_id)
45
+ model = model.eval()
46
 
47
 
48
  # input your test image
modeling_GOT.py CHANGED
@@ -558,7 +558,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
558
 
559
  image_tensor_1 = image_processor_high(image)
560
 
561
- input_ids = torch.as_tensor(inputs.input_ids).cuda()
562
 
563
  stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
564
  keywords = [stop_str]
@@ -569,7 +569,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
569
  with torch.autocast("cuda", dtype=torch.bfloat16):
570
  output_ids = self.generate(
571
  input_ids,
572
- images=[image_tensor_1.unsqueeze(0).half().cuda()],
573
  do_sample=False,
574
  num_beams = 1,
575
  no_repeat_ngram_size = 20,
@@ -581,7 +581,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
581
  with torch.autocast("cuda", dtype=torch.bfloat16):
582
  output_ids = self.generate(
583
  input_ids,
584
- images=[image_tensor_1.unsqueeze(0).half().cuda()],
585
  do_sample=False,
586
  num_beams = 1,
587
  no_repeat_ngram_size = 20,
@@ -812,7 +812,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
812
 
813
  inputs = tokenizer([prompt])
814
 
815
- input_ids = torch.as_tensor(inputs.input_ids).cuda()
816
 
817
  stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
818
  keywords = [stop_str]
@@ -823,7 +823,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
823
  with torch.autocast("cuda", dtype=torch.bfloat16):
824
  output_ids = self.generate(
825
  input_ids,
826
- images=[image_list.half().cuda()],
827
  do_sample=False,
828
  num_beams = 1,
829
  # no_repeat_ngram_size = 20,
@@ -835,7 +835,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
835
  with torch.autocast("cuda", dtype=torch.bfloat16):
836
  output_ids = self.generate(
837
  input_ids,
838
- images=[image_list.half().cuda()],
839
  do_sample=False,
840
  num_beams = 1,
841
  # no_repeat_ngram_size = 20,
 
558
 
559
  image_tensor_1 = image_processor_high(image)
560
 
561
+ input_ids = torch.as_tensor(inputs.input_ids)
562
 
563
  stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
564
  keywords = [stop_str]
 
569
  with torch.autocast("cuda", dtype=torch.bfloat16):
570
  output_ids = self.generate(
571
  input_ids,
572
+ images=[image_tensor_1.unsqueeze(0).half()],
573
  do_sample=False,
574
  num_beams = 1,
575
  no_repeat_ngram_size = 20,
 
581
  with torch.autocast("cuda", dtype=torch.bfloat16):
582
  output_ids = self.generate(
583
  input_ids,
584
+ images=[image_tensor_1.unsqueeze(0).half()],
585
  do_sample=False,
586
  num_beams = 1,
587
  no_repeat_ngram_size = 20,
 
812
 
813
  inputs = tokenizer([prompt])
814
 
815
+ input_ids = torch.as_tensor(inputs.input_ids)
816
 
817
  stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
818
  keywords = [stop_str]
 
823
  with torch.autocast("cuda", dtype=torch.bfloat16):
824
  output_ids = self.generate(
825
  input_ids,
826
+ images=[image_list.half()],
827
  do_sample=False,
828
  num_beams = 1,
829
  # no_repeat_ngram_size = 20,
 
835
  with torch.autocast("cuda", dtype=torch.bfloat16):
836
  output_ids = self.generate(
837
  input_ids,
838
+ images=[image_list.half()],
839
  do_sample=False,
840
  num_beams = 1,
841
  # no_repeat_ngram_size = 20,