修改了模型和检测类别的选择,是一次大改

main
wangchunlin 3 years ago
parent d50a1b8ef3
commit 8f6244bd1e

7
.gitmodules vendored

@ -1,5 +1,8 @@
[submodule "learn/yolov5"]
path = learn/yolov5
url = http://192.168.0.51:3000/wangchunlin/yolov5-fire.git
branch = use
depth = 1
branch = use2
[submodule "learn/Darknet2Pytorch2Onnx"]
path = learn/Darknet2Pytorch2Onnx
url = http://192.168.0.51:3000/wangchunlin/Darknet2Pytorch2Onnx.git
branch = use

@ -0,0 +1 @@
Subproject commit 1d4cf9249f723166ceaea3573becbba4a7726916

@ -6,7 +6,17 @@
<meta charset="UTF-8">
<title>WildFire</title>
<script src="../static/layui/layui.js"></script>
<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- 新 Bootstrap4 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单,包含了 popper.min.js -->
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
{% csrf_token %} {#如果不加这个,程序会报错#}
@ -19,25 +29,59 @@
<b><font size="4">获取剪切板在无https情况下失败直接Ctrl+V即可</b>
<p id="mode select">
<h1>模型选择:
<select id="model", style="width: 300px; font-size:30px;">
<option value="1">小模型</option>
<option value="2">大模型</option>
<option value="3">泛模型</option>
</select>
<select id="class", style="width: 600px; font-size:30px;">
<option value="1">火焰与烟雾</option>
<option value="2">一般物体80类</option>
<option value="3">烟火与塔吊</option>
<option value="4">外破ljp4500张四类v5v3</option>
<option value="5">外破ljp4500张四类v5v7</option>
<option value="6">外破ljp4500张四类v5v7m</option>
<option value="7">绝缘子缺陷ljp2000张两类v5v7</option>
</select>
<select id="class" style="width: 200px; font-size:30px;"></select>
<select id="model" style="width: 600px; font-size:30px;"></select>
</h1>
</p>
<p id="img"></p>
<script>
$(function () {
$("#class").change(function () {
$("#model").empty();//清空回调列表;
var val = this.value;
console.log("选择的检测类别:", val);
$.each(dic_class, function (i, n) { //each()方法为每个匹配元素规定要运行的函数;
if (Object.keys(dic_class)[val-1] == i) {
$.each(dic_class[i], function (j,m) {
var text = document.createTextNode(m);//createTextNode()方法创建文本节点;
var op = document.createElement("option");//创建class元素;
op.value = j+1
$(op).append(text);
$("#model").append(op);
})
}
})
})
})
</script>
<script>
var dic_class={};//创建一个字典;
dic_class["外破"]=["外破ljp4500张四类v5v3", "外破ljp4500张四类v5v7", "外破ljp4500张四类v5v7m", "烟火与塔吊"]
dic_class["山火"]=["小模型", "大模型", "泛模型"]
dic_class["绝缘子"]=["绝缘子缺陷ljp2000张两类v5v7"]
dic_class["一般物体80类"]=["v5sv7"]
$(document).ready(function(){
$("#model").empty();//清空回调列表;
var dic_class_count = 1;
for(var key in dic_class){
var text = document.createTextNode(key);//createTextNode()方法创建文本节点;
var op = document.createElement("option");//创建class元素;
op.value = dic_class_count
$(op).append(text);
$("#class").append(op);
dic_class_count++;
}
$.each(dic_class[Object.keys(dic_class)[0]], function (j,m) {
var text = document.createTextNode(m);//createTextNode()方法创建文本节点;
var op = document.createElement("option");//创建class元素;
op.value = j+1
$(op).append(text);
$("#model").append(op);
})
});
document.addEventListener("paste", function () {
if (event.clipboardData || event.originalEvent) {
var clipboardData = (event.clipboardData || window.clipboardData);
@ -46,11 +90,13 @@ document.addEventListener("paste", function () {
// 字典 dict
var model = $('#model option:selected').val();
var model_class = $('#class option:selected').val();
console.log("检测类别与使用模型:", model_class, model)
$.getJSON('/dlurl/', {'url':val, 'model':model, 'class':model_class},function(res){ShowResult(res);});
}
});
</script>
<script>
layui.use('upload', function(){
var upload = layui.upload;
$ = layui.$ //注意要定义$,该符号不是jQuery中的$

@ -56,48 +56,7 @@ def upload(request):
for i in file.chunks():
f.write(i)
f.close()
result = adb_shell("ImageDetect/build/ImageDetect {}".format(img_path))
if result[0]==0:
cast = result[1].split("||")[0]
da = result[1].split("||")[1]
satu = result[1].split("||")[2]
CON = result[1].split("||")[3]
ASM = result[1].split("||")[4]
ENT = result[1].split("||")[5]
MEAN = result[1].split("||")[6]
sb = result[1].split("||")[7]
lap = result[1].split("||")[8]
dev = result[1].split("||")[9]
print(cast, da, satu)
mesg = "颜色分布(0-1合理):{}&nbsp;&nbsp;&nbsp;分布方差(负数偏暗):{}&nbsp;&nbsp;&nbsp;色彩饱和度(零为补光):{}<br/>对比度:{}&nbsp;&nbsp;&nbsp;角度方向二阶矩:{}&nbsp;&nbsp;&nbsp;熵:{}&nbsp;&nbsp;&nbsp;平均值:{}&nbsp;&nbsp;&nbsp;Sobel:{}&nbsp;&nbsp;&nbsp;Lap:{}&nbsp;&nbsp;&nbsp;dev:{}".format(cast, da, satu, CON, ASM, ENT, MEAN,sb,lap,dev)
if(int(m_class)==1):
if(int(m_model)==1): #小模型
RR = DL.run(weights=(curPath+"/yolov5/v3s.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 小模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==2): #大模型
RR = DL.run(weights=(curPath+"/yolov5/v6m6.pt"), source=img_path, imgsz=(1280, 1280), project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 大模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==3): #泛模型
RR = DL.run(weights=(curPath+"/yolov5/best.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 泛模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==2):
RR = DL.run(weights=(curPath+"/yolov5/yolov5s.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【一般物体检测】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==3):
RR = DL.run(weights=(curPath+"/yolov5/fire_smoke_towercrane.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火+塔吊】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==4):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v3.0.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==5):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v7.0.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==6):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v7.0m.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==7):
RR = DL.run(weights=(curPath+"/yolov5/birdpecked_unnormal_version1.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【绝缘子两类】"+RR+' <br/> '+mesg, 'flag': True})
return inference(m_class, m_model, curPath, img_path_res, img_path)
def dlurl(request):
@ -121,6 +80,8 @@ def dlurl(request):
f.close
#返回给前端的图片路径用相对路径,前端用绝对路径反而加载不了图片
img_path_res = '/static/detected/'+fix+name
return inference(m_class, m_model, curPath, img_path_res, img_path)
'''
result = adb_shell("ImageDetect/build/ImageDetect {}".format(img_path))
if result[0]==0:
cast = result[1].split("||")[0]
@ -163,8 +124,61 @@ def dlurl(request):
if(int(m_class)==7):
RR = DL.run(weights=(curPath+"/yolov5/birdpecked_unnormal_version1.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【绝缘子两类】"+RR+' <br/> '+mesg, 'flag': True})
'''
def home(request):
return render(request, 'home.html')
def inference(m_class, m_model, curPath, img_path_res, img_path):
result = adb_shell("ImageDetect/build/ImageDetect {}".format(img_path))
if result[0]==0:
cast = result[1].split("||")[0]
da = result[1].split("||")[1]
satu = result[1].split("||")[2]
CON = result[1].split("||")[3]
ASM = result[1].split("||")[4]
ENT = result[1].split("||")[5]
MEAN = result[1].split("||")[6]
sb = result[1].split("||")[7]
lap = result[1].split("||")[8]
dev = result[1].split("||")[9]
print(cast, da, satu)
mesg = "颜色分布(0-1合理):{}&nbsp;&nbsp;&nbsp;分布方差(负数偏暗):{}&nbsp;&nbsp;&nbsp;色彩饱和度(零为补光):{}<br/>对比度:{}&nbsp;&nbsp;&nbsp;角度方向二阶矩:{}&nbsp;&nbsp;&nbsp;熵:{}&nbsp;&nbsp;&nbsp;平均值:{}&nbsp;&nbsp;&nbsp;Sobel:{}&nbsp;&nbsp;&nbsp;Lap:{}&nbsp;&nbsp;&nbsp;dev:{}".format(cast, da, satu, CON, ASM, ENT, MEAN,sb,lap,dev)
if(int(m_class)==1): #外破
if(int(m_model)==1):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v3.0.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==2):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v7.0.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==3):
RR = DL.run(weights=(curPath+"/yolov5/vehicle_4class_ljp_v7.0m.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【外破四类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==4):
RR = DL.run(weights=(curPath+"/yolov5/fire_smoke_towercrane.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火+塔吊】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==2): #山火
if(int(m_model)==1): # 小
RR = DL.run(weights=(curPath+"/yolov5/v3s.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 小模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==2): # 大
RR = DL.run(weights=(curPath+"/yolov5/v6m6.pt"), source=img_path, imgsz=(1280, 1280), project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 大模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_model)==3): # 范模型
RR = DL.run(weights=(curPath+"/yolov5/best.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【烟火 泛模型】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==3): # 绝缘子
if(int(m_model)==1):
RR = DL.run(weights=(curPath+"/yolov5/birdpecked_unnormal_version1.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【绝缘子两类】"+RR+' <br/> '+mesg, 'flag': True})
if(int(m_class)==4): # 一般物体coco
if(int(m_model)==1): #yolov5s
RR = DL.run(weights=(curPath+"/yolov5/yolov5s.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【一般物体检测】"+RR+' <br/> '+mesg, 'flag': True})
Loading…
Cancel
Save