-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathws01.py
151 lines (126 loc) · 4.1 KB
/
ws01.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import os
import shutil
import piq
import torch
from glob import glob
from scipy import ndimage
from typing import Any, Dict, Optional
import cv2
import numpy as np
import matplotlib.pyplot as plt
from iquaflow.datasets import DSModifier, DSWrapper,DSModifier_jpg
from iquaflow.experiments import ExperimentInfo, ExperimentSetup
from iquaflow.experiments.experiment_visual import ExperimentVisual
from iquaflow.experiments.task_execution import PythonScriptTaskExecution
from iquaflow.metrics import BBDetectionMetrics, SNRMetric , RERMetric
from custom_iqf import DSModifierMFSR, SimilarityMetricsForMFSR, SlicedWassersteinMetric
#Define name of IQF experiment
experiment_name = "xview-test-v5-200samples"
#Define path of the original(reference) dataset
data_path = "./xviewds/xview-ds/test"
#DS wrapper is the class that encapsulate a dataset
ds_wrapper = DSWrapper(data_path=data_path)
#Define path of the training script
python_ml_script_path = 'custom_train.py'
#List of modifications that will be applied to the original dataset:
# ds_modifiers_list = [
# DSModifierMFSR( params={
# 'algo':algo,
# 'zoom': 3,
# 'n_jobs': 20
# } )
# for algo in ['fake','warpw','agk','msrn']
# ]
# ds_modifiers_list += [
# DSModifierMFSR( params={
# 'algo':algo,
# 'zoom': 3,
# 'config':conf,
# 'model':model
# } )
# for algo, conf, model in zip(
# [
# 'hrn',
# 'hrn',
# 'hrn',
# 'hrn',
# 'hrn'
# ],
# [
# "hrn_exp27.json",
# "hrn_exp27-histmatch-v5.json",
# "hrn_exp27-histmatch-v6.json",
# "hrn_exp27+inria-histmatch-v5.json",
# "hrn_exp27+inria-histmatch-v6.json"
# ],
# [
# "exp27/HRNet_30.pth",
# "exp27-histmatch-v5/HRNet.pth",
# "exp27-histmatch-v6/HRNet.pth",
# "exp27+inria-histmatch-v5/HRNet.pth",
# "exp27+inria-histmatch-v6/HRNet.pth"
# ]
# )
# ]
# Task execution executes the training loop
# In this case the training loop is an empty script,
# this is because we evaluate the performance directly on the result of the modifiers.
task = PythonScriptTaskExecution( model_script_path = python_ml_script_path )
#Experiment definition, pass as arguments all the components defined beforehand
# experiment = ExperimentSetup(
# experiment_name=experiment_name,
# task_instance=task,
# ref_dsw_train=ds_wrapper,
# ds_modifiers_list=ds_modifiers_list,
# repetitions=1
# )
# Execute the experiment
# experiment.execute()
# ExperimentInfo is used to retrieve all the information of the whole experiment.
# It contains built in operations but also it can be used to retrieve raw data for futher analysis
experiment_info = ExperimentInfo(experiment_name)
# print('Calculating similarity metrics...')
# _ = experiment_info.apply_metric_per_run(
# SimilarityMetricsForMFSR( experiment_info, cut=12//2, n_jobs=20 ),
# ds_wrapper.json_annotations,
# )
print('Calculating Sliced Wasserstein Distance Metric...')
win = 128
_ = experiment_info.apply_metric_per_run(
SlicedWassersteinMetric(
experiment_info,
n_jobs = -1,
ext = 'png',
n_pyramids = 2,
slice_size = 7,
n_descriptors = win*2,
n_repeat_projection = win,
proj_per_repeat = 4,
device = 'cpu',
return_by_resolution = False,
pyramid_batchsize = win
),
ds_wrapper.json_annotations,
)
# print('Calculating RER Metric...')
# _ = experiment_info.apply_metric_per_run(
# RERMetric(
# experiment_info,
# win=16,
# stride=16,
# ext="png",
# n_jobs=20
# ),
# ds_wrapper.json_annotations,
# )
# print('Calculating SNR Metric...')
# _ = experiment_info.apply_metric_per_run(
# SNRMetric(
# experiment_info,
# ext="png",
# patch_sizes=[30],
# confidence_limit=50.0,
# n_jobs=20
# ),
# ds_wrapper.json_annotations,
# )