Spaces:
Sleeping
Sleeping
Commit
·
c6f1011
1
Parent(s):
8744263
Fix: Load CPU-safe model for HF Space
Browse files
app.py
CHANGED
@@ -13,11 +13,9 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
|
13 |
# Force CPU-safe model loading
|
14 |
model = AutoModelForCausalLM.from_pretrained(
|
15 |
MODEL_PATH,
|
16 |
-
|
17 |
-
|
18 |
-
)
|
19 |
-
|
20 |
-
device = torch.device("cpu") # Explicitly define CPU
|
21 |
|
22 |
|
23 |
# Dictionaries to decode user inputs
|
@@ -44,7 +42,7 @@ def get_prediction(age, gender, height, weight, ap_hi, ap_lo,
|
|
44 |
|
45 |
Diagnosis:"""
|
46 |
|
47 |
-
inputs = tokenizer(input_text, return_tensors="pt").to(
|
48 |
model.eval()
|
49 |
with torch.no_grad():
|
50 |
outputs = model.generate(**inputs, max_new_tokens=4)
|
|
|
13 |
# Force CPU-safe model loading
|
14 |
model = AutoModelForCausalLM.from_pretrained(
|
15 |
MODEL_PATH,
|
16 |
+
torch_dtype=torch.float32,
|
17 |
+
low_cpu_mem_usage=True
|
18 |
+
).to("cpu")
|
|
|
|
|
19 |
|
20 |
|
21 |
# Dictionaries to decode user inputs
|
|
|
42 |
|
43 |
Diagnosis:"""
|
44 |
|
45 |
+
inputs = tokenizer(input_text, return_tensors="pt").to("cpu")
|
46 |
model.eval()
|
47 |
with torch.no_grad():
|
48 |
outputs = model.generate(**inputs, max_new_tokens=4)
|