Spaces:
Sleeping
Sleeping
Update app/utils.py
Browse files- app/utils.py +2 -3
app/utils.py
CHANGED
@@ -18,9 +18,9 @@ class OCRModel:
|
|
18 |
cls._instance = super(OCRModel, cls).__new__(cls)
|
19 |
cls._instance.initialize()
|
20 |
return cls._instance
|
|
|
21 |
def initialize(self):
|
22 |
try:
|
23 |
-
|
24 |
logger.info("Initializing OCR model...")
|
25 |
# Try loading with use_fast=False if the fast tokenizer fails
|
26 |
try:
|
@@ -41,12 +41,11 @@ class OCRModel:
|
|
41 |
'stepfun-ai/GOT-OCR-2.0-hf',
|
42 |
trust_remote_code=True,
|
43 |
low_cpu_mem_usage=True,
|
44 |
-
device_map='auto',
|
45 |
use_safetensors=True,
|
46 |
pad_token_id=self.tokenizer.eos_token_id
|
47 |
)
|
48 |
|
49 |
-
# Let the model decide device placement
|
50 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
51 |
self.model = self.model.eval().to(self.device)
|
52 |
|
|
|
18 |
cls._instance = super(OCRModel, cls).__new__(cls)
|
19 |
cls._instance.initialize()
|
20 |
return cls._instance
|
21 |
+
|
22 |
def initialize(self):
|
23 |
try:
|
|
|
24 |
logger.info("Initializing OCR model...")
|
25 |
# Try loading with use_fast=False if the fast tokenizer fails
|
26 |
try:
|
|
|
41 |
'stepfun-ai/GOT-OCR-2.0-hf',
|
42 |
trust_remote_code=True,
|
43 |
low_cpu_mem_usage=True,
|
44 |
+
device_map='auto',
|
45 |
use_safetensors=True,
|
46 |
pad_token_id=self.tokenizer.eos_token_id
|
47 |
)
|
48 |
|
|
|
49 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
50 |
self.model = self.model.eval().to(self.device)
|
51 |
|