新增7个模型,优化两个模型
This commit is contained in:
parent
4bfab36df0
commit
bb4a79ff90
38
AI.py
38
AI.py
|
|
@ -18,6 +18,7 @@ import torch.nn.functional as F
|
|||
from copy import deepcopy
|
||||
from scipy import interpolate
|
||||
import glob
|
||||
from loguru import logger
|
||||
|
||||
def get_images_videos(impth, imageFixs=['.jpg','.JPG','.PNG','.png'],videoFixs=['.MP4','.mp4','.avi']):
|
||||
imgpaths=[];###获取文件里所有的图像
|
||||
|
|
@ -74,6 +75,17 @@ def score_filter_byClass(pdetections,score_para_2nd):
|
|||
if score > score_th:
|
||||
ret.append(det)
|
||||
return ret
|
||||
# 按类过滤
|
||||
def filter_byClass(pdetections,allowedList):
|
||||
ret=[]
|
||||
for det in pdetections:
|
||||
score,cls = det[4],det[5]
|
||||
if int(cls) in allowedList:
|
||||
ret.append(det)
|
||||
elif str(int(cls)) in allowedList:
|
||||
ret.append(det)
|
||||
|
||||
return ret
|
||||
|
||||
def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False,'score_byClass':{x:0.1 for x in range(30)} }, font={ 'line_thickness':None, 'fontSize':None,'boxLine_thickness':None,'waterLineColor':(0,255,255),'waterLineWidth':3} ,segPar={'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'numpy':False, 'RGB_convert_first':True},mode='others',postPar=None):
|
||||
|
||||
|
|
@ -118,13 +130,22 @@ def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'h
|
|||
img /= 255.0
|
||||
time01=time.time()
|
||||
|
||||
|
||||
if segmodel:
|
||||
seg_pred,segstr = segmodel.eval(im0s[0] )
|
||||
segFlag=True
|
||||
else:
|
||||
seg_pred = None;segFlag=False;segstr='Not implemented'
|
||||
|
||||
if segmodel:
|
||||
seg_pred, segstr = segmodel.eval(im0s[0])
|
||||
# 当不存在分割信息,无需做分类检测
|
||||
# segFlag = True
|
||||
logger.info("分割信息seg_prd: {} 数据类型:{} ", seg_pred, np.count_nonzero(seg_pred))
|
||||
if not np.any(seg_pred != 0):
|
||||
time_info = 'No SegMentInfo'
|
||||
return [], time_info
|
||||
|
||||
else:
|
||||
# seg_pred = None;
|
||||
# segFlag = False;
|
||||
# segstr = 'Not implemented'
|
||||
time_info = 'No SegMentInfo'
|
||||
return [], time_info
|
||||
|
||||
time1=time.time()
|
||||
if trtFlag_det:
|
||||
pred = yolov5Trtforward(model,img)
|
||||
|
|
@ -154,7 +175,8 @@ def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'h
|
|||
timeMixPost=':0 ms'
|
||||
#print('#### line121: segstr:%s timeMixPost:%s timeOut:%s'%( segstr.strip(), timeMixPost,timeOut ))
|
||||
time_info = 'letterbox:%.1f, seg:%.1f , infer:%.1f,%s, seginfo:%s ,timeMixPost:%s '%( (time01-time0)*1000, (time1-time01)*1000 ,(time2-time1)*1000,timeOut , segstr.strip(),timeMixPost )
|
||||
#if mode=='highWay3.0':
|
||||
if allowedList:
|
||||
p_result[2] = filter_byClass(p_result[2],allowedList)
|
||||
|
||||
print('-'*10,p_result[2])
|
||||
return p_result,time_info
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"labelnames":["危化品","罐体","危险标识","普通车"]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"post_process":{ "name":"post_process","conf_thres":0.88,"iou_thres":0.45,"classes":5,"rainbows":[ [0,0,255],[0,255,0],[255,0,0],[255,0,255],[255,255,0],[255,129,0],[255,0,127],[127,255,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]] }
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"post_process":{
|
||||
"name":"post_process","conf_thres":0.5,"iou_thres":0.25,"classes":3,
|
||||
"rainbows":[ [0,0,255],[0,255,0],[255,0,0],[255,0,0],[255,255,0],[255,0,0],[255,0,127],[255,0,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"labelnames":["行人"]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
|
||||
|
||||
"post_process":{ "name":"post_process","conf_thres":0.25,"iou_thres":0.45,"classes":1,"rainbows":[ [0,0,255],[0,255,0],[255,0,0],[255,0,255],[255,255,0],[255,129,0],[255,0,127],[127,255,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]] }
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"labelnames":["火","烟"]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
|
||||
|
||||
"post_process":{ "name":"post_process","conf_thres":0.25,"iou_thres":0.45,"classes":1,"rainbows":[ [0,0,255],[0,255,0],[255,0,0],[255,0,255],[255,255,0],[255,129,0],[255,0,127],[127,255,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]] }
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"labelnames":[ "光伏板","覆盖物","裂缝" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"post_process":{
|
||||
"name":"post_process","conf_thres":0.5,"iou_thres":0.25,"classes":3,
|
||||
"rainbows":[ [0,0,255],[0,255,0],[255,0,0],[255,0,0],[255,255,0],[255,0,0],[255,0,127],[255,0,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue