Update inference.py
Browse files- inference.py +8 -5
inference.py
CHANGED
@@ -9,8 +9,11 @@ from nets.model import Model
|
|
9 |
from Actor.actor import Actor
|
10 |
from dataloader import VRP_Dataset
|
11 |
|
|
|
|
|
|
|
12 |
# --- تحميل الإعدادات ---
|
13 |
-
params_path = '
|
14 |
if not os.path.exists(params_path):
|
15 |
raise FileNotFoundError(f"Settings file not found at {params_path}")
|
16 |
|
@@ -22,14 +25,14 @@ device = params['device']
|
|
22 |
dataset_path = params['dataset_path']
|
23 |
|
24 |
# --- مسار النموذج المحفوظ ---
|
25 |
-
model_path = "
|
26 |
if not os.path.exists(model_path):
|
27 |
raise FileNotFoundError(f"Model not found at {model_path}")
|
28 |
|
29 |
# --- تحضير مجلد النتائج ---
|
30 |
-
os.makedirs(
|
31 |
-
txt_results_file = "
|
32 |
-
csv_results_file = "
|
33 |
|
34 |
# --- إعداد بيانات inference ---
|
35 |
inference_dataset = VRP_Dataset(
|
|
|
9 |
from Actor.actor import Actor
|
10 |
from dataloader import VRP_Dataset
|
11 |
|
12 |
+
# --- تحديد المجلد الآمن ---
|
13 |
+
safe_data_dir = "/home/user/data"
|
14 |
+
|
15 |
# --- تحميل الإعدادات ---
|
16 |
+
params_path = os.path.join(safe_data_dir, 'params_saved.json')
|
17 |
if not os.path.exists(params_path):
|
18 |
raise FileNotFoundError(f"Settings file not found at {params_path}")
|
19 |
|
|
|
25 |
dataset_path = params['dataset_path']
|
26 |
|
27 |
# --- مسار النموذج المحفوظ ---
|
28 |
+
model_path = os.path.join(safe_data_dir, "model_state_dict.pt")
|
29 |
if not os.path.exists(model_path):
|
30 |
raise FileNotFoundError(f"Model not found at {model_path}")
|
31 |
|
32 |
# --- تحضير مجلد النتائج ---
|
33 |
+
os.makedirs(safe_data_dir, exist_ok=True)
|
34 |
+
txt_results_file = os.path.join(safe_data_dir, "inference_results.txt")
|
35 |
+
csv_results_file = os.path.join(safe_data_dir, "inference_results.csv")
|
36 |
|
37 |
# --- إعداد بيانات inference ---
|
38 |
inference_dataset = VRP_Dataset(
|