Browse Source

update model safety

tags/v1.22.10.1^2
chenshihai 3 years ago
parent
commit
6cd7f96040
9 changed files with 149 additions and 75 deletions
  1. +2
    -0
      routers/repo/aisafety.go
  2. +2
    -2
      routers/repo/cloudbrain.go
  3. +3
    -3
      templates/repo/cloudbrain/benchmark/new.tmpl
  4. +62
    -0
      templates/repo/modelsafety/indicators_descr.tmpl
  5. +74
    -68
      templates/repo/modelsafety/new.tmpl
  6. +1
    -0
      templates/repo/modelsafety/newgpu.tmpl
  7. +1
    -0
      templates/repo/modelsafety/newnpu.tmpl
  8. +2
    -1
      web_src/js/components/dataset/selectDataset.vue
  9. +2
    -1
      web_src/js/components/images/selectImages.vue

+ 2
- 0
routers/repo/aisafety.go View File

@@ -351,6 +351,7 @@ func DelAiSafetyTask(ctx *context.Context) {
func AiSafetyCreateForGetGPU(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true
ctx.Data["IsCreate"] = true
ctx.Data["datasetType"] = models.TypeCloudBrainOne
ctx.Data["BaseDataSetName"] = setting.ModelSafetyTest.BaseDataSetName
ctx.Data["BaseDataSetUUID"] = setting.ModelSafetyTest.BaseDataSetUUID
ctx.Data["CombatDataSetName"] = setting.ModelSafetyTest.CombatDataSetName
@@ -362,6 +363,7 @@ func AiSafetyCreateForGetGPU(ctx *context.Context) {
func AiSafetyCreateForGetNPU(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true
ctx.Data["IsCreate"] = true
ctx.Data["datasetType"] = models.TypeCloudBrainTwo
ctx.Data["BaseDataSetName"] = setting.ModelSafetyTest.BaseDataSetName
ctx.Data["BaseDataSetUUID"] = setting.ModelSafetyTest.BaseDataSetUUID
ctx.Data["CombatDataSetName"] = setting.ModelSafetyTest.CombatDataSetName


+ 2
- 2
routers/repo/cloudbrain.go View File

@@ -51,8 +51,8 @@ const (
tplCloudBrainBenchmarkNew base.TplName = "repo/cloudbrain/benchmark/new"
tplCloudBrainBenchmarkShow base.TplName = "repo/cloudbrain/benchmark/show"

tplCloudBrainModelSafetyNewGpu base.TplName = "repo/cloudbrain/modelsafety/newgpu"
tplCloudBrainModelSafetyNewNpu base.TplName = "repo/cloudbrain/modelsafety/newnpu"
tplCloudBrainModelSafetyNewGpu base.TplName = "repo/modelsafety/newgpu"
tplCloudBrainModelSafetyNewNpu base.TplName = "repo/modelsafety/newnpu"

tplCloudBrainImageSubmit base.TplName = "repo/cloudbrain/image/submit"
tplCloudBrainImageEdit base.TplName = "repo/cloudbrain/image/edit"


+ 3
- 3
templates/repo/cloudbrain/benchmark/new.tmpl View File

@@ -51,7 +51,7 @@
<a class="active item model_benchmark"
href="{{.Link}}?benchmarkMode=model">{{.i18n.Tr "repo.cloudbrain.benchmark.model"}}</a>
<a class="item aisafety_benchmark"
href="{{.Link}}?benchmarkMode=aisafety">模型安全评测</a>
href="{{.RepoLink}}/modelsafety/create_gpu">模型安全评测</a>
</div>
</div>
<div>
@@ -168,7 +168,7 @@
<a class="item model_benchmark"
href="{{.Link}}?benchmarkMode=model">{{.i18n.Tr "repo.cloudbrain.benchmark.model"}}</a>
<a class="item aisafety_benchmark"
href="{{.Link}}?benchmarkMode=aisafety">模型安全评测</a>
href="{{.RepoLink}}/modelsafety/create_gpu">模型安全评测</a>
</div>
</div>

@@ -298,7 +298,7 @@
<a class="item model_benchmark"
href="{{.Link}}?benchmarkMode=model">{{.i18n.Tr "repo.cloudbrain.benchmark.model"}}</a>
<a class="active item aisafety_benchmark"
href="{{.Link}}?benchmarkMode=aisafety">模型安全评测</a>
href="{{.RepoLink}}/modelsafety/create_gpu">模型安全评测</a>
</div>
</div>



+ 62
- 0
templates/repo/modelsafety/indicators_descr.tmpl View File

@@ -0,0 +1,62 @@
<span>
<i class="question circle icon indicators_descr" style="cursor:pointer;"></i>
<div class="ui flowing popup bottom left transition hidden" style="inset: 564px auto auto 1px; width: 920px">
<table class="ui celled table">
<thead>
<tr>
<th style="width:80px;">指标</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="指标">ACC</td>
<td data-label="说明">Accuracy,精确度,计算模型预测准确率,该指标越高,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">CAV</td>
<td data-label="说明">Classification Accuracy Variance,用于评估深度学习模型性能的最重要指标为准确性。该指标值越高,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">ASS</td>
<td data-label="说明">Average Structural Similarity,所有攻击成功对抗样本与其原始样本间的平均相似性。该指标越大,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">ALDp</td>
<td data-label="说明">Average LpDistortion,为所有攻击成功的对抗样本的平均归一化Lp失真度,ALDp值越小,对抗样本的不可感知性越强。</td>
</tr>
<tr>
<td data-label="指标">ACAC</td>
<td data-label="说明">Average Confidence of Adversarial Class(ACAC)这个数值越高,攻击算法的攻击能力越强。</td>
</tr>
<tr>
<td data-label="指标">ACTC</td>
<td data-label="说明">Average Confidence of True Class(ACTC) 这个数值越低,攻击算法的攻击能力越强。</td>
</tr>
<tr>
<td data-label="指标">PSD</td>
<td data-label="说明">Perturbation Sensitivity Distance,用于评测人类对扰动的感知能力。该指标值越大,说明评测结果越差。</td>
</tr>
<tr>
<td data-label="指标">CACC</td>
<td data-label="说明">Clean ACC该值计算的是原始未被攻击的样本,使用模型和groundtruth相比较的模型的本身的一个。</td>
</tr>
</tbody>
</table>
</div>
</span>
<script>
;(function() {
setTimeout(function(){
$('.indicators_descr').popup({
inline: true,
hoverable: true,
position: 'top center',
delay: {
show: 300,
hide: 800
}
});
}, 1000);
})();
</script>

+ 74
- 68
templates/repo/modelsafety/new.tmpl View File

@@ -49,19 +49,42 @@
</h4>
<div class="ui attached segment">
<input type="hidden" name="benchmarkMode" value="{{.benchmarkMode}}">
<form id="form_id" class="ui form alogrithm_form" action="{{.Link}}?benchmarkMode=model_safe_benchmark" method="post">
<form id="form_id" class="ui form alogrithm_form" action="{{.RepoLink}}/modelsafety/create" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="update">
<input type="hidden" name="job_type" value="BENCHMARK">
<input type="hidden" name="type" value="{{.datasetType}}">
<div class="required min_title inline field">
<label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_scenes"}}</label>
<div class="ui blue small menu compact selectcloudbrain">
<a class="item alogrithm_benchmark"
href="{{.Link}}?benchmarkMode=alogrithm">{{.i18n.Tr "repo.cloudbrain.benchmark.algorithm"}}</a>
href="{{.RepoLink}}/cloudbrain/benchmark/create?benchmarkMode=alogrithm">{{.i18n.Tr "repo.cloudbrain.benchmark.algorithm"}}</a>
<a class="item model_benchmark"
href="{{.Link}}?benchmarkMode=model">{{.i18n.Tr "repo.cloudbrain.benchmark.model"}}</a>
href="{{.RepoLink}}/cloudbrain/benchmark/create?benchmarkMode=model">{{.i18n.Tr "repo.cloudbrain.benchmark.model"}}</a>
<a class="item active model_safe_benchmark"
href="{{.Link}}?benchmarkMode=model_safe">模型安全评测</a>
href="{{.Link}}">模型安全评测</a>
</div>
</div>
<div class="inline min_title required field">
<label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
<div class="ui blue small menu compact selectcloudbrain">
<a class="{{if eq .datasetType 0}}active{{end}} item" href="{{.RepoLink}}/modelsafety/create_gpu">
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
height="16">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
</svg>
CPU/GPU
</a>
<a class="{{if eq .datasetType 1}}active{{end}} item" href="{{.RepoLink}}/modelsafety/create_npu">
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
height="16">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
</svg>
Ascend NPU</a>
</div>
</div>
<div>
@@ -127,11 +150,18 @@
</span>
<a href="https://git.openi.org.cn/OpenIOSSG/MNIST_PytorchExample_GPU" target="_blank">{{.i18n.Tr "cloudbrain.view_sample"}}</a>
</div>
<div id="select-multi-dataset"></div>
<span class="tooltips" style="margin-left: 11.5rem;margin-bottom: 1rem;"></span>
<div class="inline field min_title required">
<label class="label-fix-width" style="font-weight: normal;">原始数据集</label>
<select id="baseDataSet-sel" class="ui dropdown width48" name="src_dataset"></select>
</div>
<div class="inline field min_title required">
<label class="label-fix-width" style="font-weight: normal;">对抗数据集</label>
<select id="combatDataSet-sel" class="ui dropdown width48 readonly" name="combat_dataset"></select>
</div>
<div class="inline min_title field required">
<label class="label-fix-width" style="font-weight:normal;">评测指标</label>
<select id="job_indicators" class="ui dropdown width48 v-middle" multiple placeholder="选择评测指标" style='width:385px;' name="job_indicators">
<input type="text" style="display:none;" name="evaluation_index" />
<select id="job_indicators" class="ui dropdown width48 v-middle" multiple placeholder="选择评测指标" style='width:385px;'>
<option value="ACC">ACC</option>
<option value="CAV">CAV</option>
<option value="ASS">ASS</option>
@@ -141,53 +171,7 @@
<option value="PSD">PSD</option>
<option value="CACC">CACC</option>
</select>
<span>
<i class="question circle icon indicators_descr" style="cursor:pointer;"></i>
<div class="ui flowing popup bottom left transition hidden" style="inset: 564px auto auto 1px; width: 920px">
<table class="ui celled table">
<thead>
<tr>
<th style="width:80px;">指标</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="指标">ACC</td>
<td data-label="说明">Accuracy,精确度,计算模型预测准确率,该指标越高,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">CAV</td>
<td data-label="说明">Classification Accuracy Variance,用于评估深度学习模型性能的最重要指标为准确性。该指标值越高,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">ASS</td>
<td data-label="说明">Average Structural Similarity,所有攻击成功对抗样本与其原始样本间的平均相似性。该指标越大,说明评测结果越好。</td>
</tr>
<tr>
<td data-label="指标">ALDp</td>
<td data-label="说明">Average LpDistortion,为所有攻击成功的对抗样本的平均归一化Lp失真度,ALDp值越小,对抗样本的不可感知性越强。</td>
</tr>
<tr>
<td data-label="指标">ACAC</td>
<td data-label="说明">Average Confidence of Adversarial Class(ACAC)这个数值越高,攻击算法的攻击能力越强。</td>
</tr>
<tr>
<td data-label="指标">ACTC</td>
<td data-label="说明">Average Confidence of True Class(ACTC) 这个数值越低,攻击算法的攻击能力越强。</td>
</tr>
<tr>
<td data-label="指标">PSD</td>
<td data-label="说明">Perturbation Sensitivity Distance,用于评测人类对扰动的感知能力。该指标值越大,说明评测结果越差。</td>
</tr>
<tr>
<td data-label="指标">CACC</td>
<td data-label="说明">Clean ACC该值计算的是原始未被攻击的样本,使用模型和groundtruth相比较的模型的本身的一个。</td>
</tr>
</tbody>
</table>
</div>
</span>
{{template "repo/modelsafety/indicators_descr".}}
</div>
<div class="inline min_title field">
<label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
@@ -199,7 +183,7 @@
</div>
<div class="required min_title inline field">
<label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
<select id="__specs__" class="ui search dropdown width48"
<select id="__specs__" class="ui dropdown width48"
placeholder="{{.i18n.Tr "cloudbrain.select_specification"}}" style='width:385px' ovalue="{{.spec_id}}"
{{if .CloudBrainPaySwitch}}blance="{{.PointAccount.Balance}}"{{end}}
name="spec_id">
@@ -219,7 +203,7 @@
<button class="ui create_train_job green button">
{{.i18n.Tr "repo.cloudbrain.new"}}
</button>
<a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
<a class="ui button" href="{{.RepoLink}}/cloudbrain/benchmark">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
</div>
</div>
</form>
@@ -237,9 +221,6 @@
if(createFlag) return false
createFlag = true
}
let repolink = {{.RepoLink }}
let url_href = window.location.pathname.split('create')[0]
$(".ui.button").attr('href', url_href)
$('.menu .item').tab();
var isValidate = false;
@@ -285,7 +266,7 @@
})
}

validate()
// validate()
$('.ui.create_train_job.green.button').click(function (e) {
validate()
})
@@ -303,14 +284,39 @@
})();

;(function() {
$('.indicators_descr').popup({
inline: true,
hoverable: true,
position: 'top center',
delay: {
show: 300,
hide: 800
var baseDataSetName = {{.BaseDataSetName}} || '';
var baseDataSetUUID = {{.BaseDataSetUUID}} || '';
var combatDataSetName = {{.CombatDataSetName}} || '';
var combatDataSetUUID = {{.CombatDataSetUUID}} || '';
var baseDataSetSel = $('#baseDataSet-sel');
var combatDataSetSel = $('#combatDataSet-sel');

function initDataSetSelect(names, keys, selectEl) {
selectEl.empty();
var nameList = names.split(';');
var keyList = keys.split(';')
for (var i = 0, iLen = nameList.length; i < iLen; i++) {
selectEl.append(`<option index="${i}" value="${keyList[i]}">${nameList[i]}</option>`);
}
});
selectEl.on('change', function() {
var self = $(this);
var selectIndex = self.find('option:selected').attr('index');
var type = self.attr('id');
if (type === 'baseDataSet-sel') {
var val = combatDataSetSel.find('option[index="'+selectIndex+'"]').attr('value');
combatDataSetSel.dropdown('set selected', val);
} else {
var val = baseDataSetSel.find('option[index="'+selectIndex+'"]').attr('value');
baseDataSetSel.dropdown('set selected', val);
}
}).trigger('change');
}
initDataSetSelect(baseDataSetName, baseDataSetUUID, baseDataSetSel);
initDataSetSelect(combatDataSetName, combatDataSetUUID, combatDataSetSel);
$('#job_indicators').on('change', function() {
var value = $(this).val();
$('input[name="evaluationIndex"]').val(value.join(';'));
}).trigger('change');
})();
</script>

+ 1
- 0
templates/repo/modelsafety/newgpu.tmpl View File

@@ -0,0 +1 @@
{{template "repo/modelsafety/new".}}

+ 1
- 0
templates/repo/modelsafety/newnpu.tmpl View File

@@ -0,0 +1 @@
{{template "repo/modelsafety/new".}}

+ 2
- 1
web_src/js/components/dataset/selectDataset.vue View File

@@ -1011,7 +1011,8 @@ export default {
if (
location.href.indexOf("benchmark") !== -1 ||
location.href.indexOf("train-job") !== -1 ||
location.href.indexOf("inference") !== -1
location.href.indexOf("inference") !== -1 ||
location.href.indexOf("modelsafety") !== -1
) {
this.benchmarkNew = true;
}


+ 2
- 1
web_src/js/components/images/selectImages.vue View File

@@ -505,7 +505,8 @@ export default {
if (
location.href.indexOf("train-job") !== -1 ||
location.href.indexOf("inference-job") !== -1 ||
location.href.indexOf("benchmark") !== -1
location.href.indexOf("benchmark") !== -1 ||
location.href.indexOf("modelsafety") !== -1
) {
this.benchmarkNew = true;
}


Loading…
Cancel
Save