Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -11,12 +11,15 @@ import tempfile
11
  import time
12
  import shutil
13
  from pathlib import Path
 
 
 
14
 
15
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
16
- model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True)
17
  model = model.eval().cuda()
18
 
19
- UPLOAD_FOLDER = "./uploads"
20
  RESULTS_FOLDER = "./results"
21
 
22
  for folder in [UPLOAD_FOLDER, RESULTS_FOLDER]:
 
11
  import time
12
  import shutil
13
  from pathlib import Path
14
+ import torch
15
+
16
+ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
17
 
18
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
19
+ model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map=DEVICE, use_safetensors=True)
20
  model = model.eval().cuda()
21
 
22
+ UPLOAD_FOLDER = "./uploads
23
  RESULTS_FOLDER = "./results"
24
 
25
  for folder in [UPLOAD_FOLDER, RESULTS_FOLDER]: