-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_pipeline.py
55 lines (49 loc) · 1.55 KB
/
run_pipeline.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
from utils import *
from model_utils import *
from data import *
from c2d_models import *
from test_pipeline import *
model_path = "trained_models/C2D_AE_128_3x3_MVTec/model.h5"
train_data = MVTec(isTrain = True)
output_path = join_paths(["results/", train_data.__name__, ""])
create_directory(output_path)
config = {
# 'lime': {
# 'num_features': 128*128,
# 'mask_features': 5,
# 'num_samples': 1000,
# },
# 'counterfactual': {
# 'threshold_pct': 0.98,
# 'block_size': 32
# },
'shap': {
'blend_alpha': 0.7,
'background_samples': 100
},
# 'elrp': {
# 'max_loss_value': 1000
# },
'output_path': output_path,
'test_data_path': join_paths(["TEST_SETS/", train_data.__name__, ""]),
'train_data': train_data.data, # np.array of normal images
'max_loss_value': 1000,
'batch_size': 64,
'data_name': train_data.__name__,
'model_path': model_path
}
rec_model = get_model(model_path)
loss_model = get_model(model_path, rec=False)
# p = Pipeline(rec_model, loss_model, config)
# p.run()
output_path = config["output_path"]
test_path = config['test_data_path']
for category_dir in read_directory_contents(test_path):
category_type = os.path.split(category_dir)[-1]
INFO(category_type)
config["output_path"] = join_paths([output_path, category_type, ""])
config['data_name'] = category_type
create_directory(config["output_path"])
config['test_data_path'] = category_dir
_pipline = Pipeline(rec_model, loss_model, config)
_pipline.run()