-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrun.py
63 lines (52 loc) · 2.44 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# %%
import numpy as np
import pandas as pd
import os
import subprocess
# %%
# with open('/home/zahraz/hz18_scratch/zahraz/datasets/MSL_SMAP/labeled_anomalies.csv', 'r') as file:
# csv_reader = pd.read_csv(file, delimiter=',')
# data_info = csv_reader[csv_reader['spacecraft'] == 'MSL']
all_files = os.listdir(os.path.join('/home/zahraz/hz18_scratch/zahraz/datasets/', 'SMD/train'))
file_list = [file for file in all_files if file.startswith('machine-')]
file_list = sorted(file_list)
print(file_list)
# file_list = os.listdir(os.path.join('/home/zahraz/hz18_scratch/zahraz/datasets/', 'UCR'))
# file_list = sorted(file_list)
# for filename in files: #['swat']: #files: #data_info['chan_id']:
# if filename != 'GECCO':
# print(filename)
# # Run the pretext script
# subprocess.run([
# 'python', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/carla_pretext.py',
# '--config_env', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/configs/env.yml',
# '--config_exp', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/configs/pretext/carla_pretext_smd.yml',
# '--fname', filename
# ])
# # Run the classification script
# subprocess.run([
# 'python', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/carla_classification.py',
# '--config_env', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/configs/env.yml',
# '--config_exp', '/home/zahraz/hz18_scratch/zahraz/Published/CARLA/configs/classification/carla_classification_smd.yml',
# '--fname', filename
# ])
index = file_list.index("machine-3-11.txt")
for filename in file_list: #[index:]: #['GECCO']: #['machine-2-4.txt']:
# if 'real_' in filename:
if filename != 'GECCO':
print(filename)
genmodel = 'gen_anom_' + filename+'.pth'
# Run the pretext script
subprocess.run([
'python', 'carla_pretext.py',
'--config_env', 'configs/env.yml',
'--config_exp', 'configs/pretext/carla_pretext_smd.yml',
'--fname', filename
], check=True)
# Run the classification script
subprocess.run([
'python', 'carla_classification.py',
'--config_env', 'configs/env.yml',
'--config_exp', 'configs/classification/carla_classification_smd.yml',
'--fname', filename
], check=True)