Spaces:
Sleeping
Sleeping
Update app/utils.py
Browse files- app/utils.py +0 -14
app/utils.py
CHANGED
@@ -13,24 +13,10 @@ logger = logging.getLogger(__name__)
|
|
13 |
class OCRModel:
|
14 |
_instance = None
|
15 |
|
16 |
-
def clear_huggingface_cache(self):
|
17 |
-
cache_dir = os.path.expanduser("~/.cache/huggingface")
|
18 |
-
if os.path.exists(cache_dir):
|
19 |
-
shutil.rmtree(cache_dir)
|
20 |
-
print("Hugging Face cache cleared.")
|
21 |
-
else:
|
22 |
-
print("No Hugging Face cache found.")
|
23 |
-
def __new__(cls):
|
24 |
-
if cls._instance is None:
|
25 |
-
cls._instance = super(OCRModel, cls).__new__(cls)
|
26 |
-
cls._instance.initialize()
|
27 |
-
return cls._instance
|
28 |
|
29 |
def initialize(self):
|
30 |
try:
|
31 |
|
32 |
-
self.clear_huggingface_cache()
|
33 |
-
|
34 |
logger.info("Initializing OCR model...")
|
35 |
# Try loading with use_fast=False if the fast tokenizer fails
|
36 |
try:
|
|
|
13 |
class OCRModel:
|
14 |
_instance = None
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def initialize(self):
|
18 |
try:
|
19 |
|
|
|
|
|
20 |
logger.info("Initializing OCR model...")
|
21 |
# Try loading with use_fast=False if the fast tokenizer fails
|
22 |
try:
|