mrfakename commited on
Commit
5c990d6
1 Parent(s): 1a02ee6

cpu support

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -22,7 +22,7 @@ DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
 
23
  model = AutoModelForCausalLM.from_pretrained(
24
  model_id,
25
- device_map="cuda",
26
  trust_remote_code=True,
27
  torch_dtype="auto",
28
  # _attn_implementation='flash_attention_2',
@@ -43,7 +43,7 @@ def phi_ocr(image_url):
43
  }]
44
 
45
  prompt = processor.tokenizer.apply_chat_template(prompt_message, tokenize=False, add_generation_prompt=True)
46
- inputs = processor(prompt, [image], return_tensors="pt").to("cuda")
47
 
48
  generation_args = {
49
  "max_new_tokens": 1024,
 
22
 
23
  model = AutoModelForCausalLM.from_pretrained(
24
  model_id,
25
+ device_map=DEVICE,
26
  trust_remote_code=True,
27
  torch_dtype="auto",
28
  # _attn_implementation='flash_attention_2',
 
43
  }]
44
 
45
  prompt = processor.tokenizer.apply_chat_template(prompt_message, tokenize=False, add_generation_prompt=True)
46
+ inputs = processor(prompt, [image], return_tensors="pt").to(DEVICE)
47
 
48
  generation_args = {
49
  "max_new_tokens": 1024,