Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -85,11 +85,30 @@ class SafeGeocoder:
|
|
85 |
|
86 |
# Corrected model loading function based on official usage example
|
87 |
|
|
|
88 |
def extract_info(template, text):
|
89 |
global tokenizer, model
|
90 |
|
|
|
91 |
if tokenizer is None:
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
try:
|
95 |
# Load model if not loaded yet
|
|
|
85 |
|
86 |
# Corrected model loading function based on official usage example
|
87 |
|
88 |
+
@spaces.GPU
|
89 |
def extract_info(template, text):
|
90 |
global tokenizer, model
|
91 |
|
92 |
+
# Load tokenizer if not loaded yet
|
93 |
if tokenizer is None:
|
94 |
+
print("Tokenizer not loaded yet, loading now...")
|
95 |
+
try:
|
96 |
+
try:
|
97 |
+
from modelscope import AutoTokenizer as MSAutoTokenizer
|
98 |
+
tokenizer = MSAutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
|
99 |
+
print("Loaded tokenizer using modelscope AutoTokenizer")
|
100 |
+
except:
|
101 |
+
# Fall back to regular tokenizer
|
102 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
103 |
+
MODEL_NAME,
|
104 |
+
trust_remote_code=True,
|
105 |
+
revision="main"
|
106 |
+
)
|
107 |
+
print("Loaded tokenizer using standard AutoTokenizer")
|
108 |
+
except Exception as e:
|
109 |
+
trace = traceback.format_exc()
|
110 |
+
print(f"Error loading tokenizer: {e}\n{trace}")
|
111 |
+
return "❌ Fehler beim Laden des Tokenizers", f"{str(e)}"
|
112 |
|
113 |
try:
|
114 |
# Load model if not loaded yet
|