|
|
|
|
@ -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合理):{} 分布方差(负数偏暗):{} 色彩饱和度(零为补光):{}<br/>对比度:{} 角度方向二阶矩:{} 熵:{} 平均值:{} Sobel:{} Lap:{} 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合理):{} 分布方差(负数偏暗):{} 色彩饱和度(零为补光):{}<br/>对比度:{} 角度方向二阶矩:{} 熵:{} 平均值:{} Sobel:{} Lap:{} 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})
|
|
|
|
|
|