过滤机器学习模型结果

时间:2019-12-31 05:36:54

标签: python tensorflow machine-learning

我有一个基于Tensorflow的ML模型,该模型将视频帧作为输入并检测少量对象并返回结果。当前每秒传输10帧。由于传递了多个相似的帧,因此每秒可获得紧密匹配的结果。有没有一种方法可以过滤/检查结果是否彼此紧密匹配并删除它们。

每帧我的输出如下。每分钟我都有成千上万的输出-

{'captured_on': '1574861019023', 
 'model_result': [{'VEST': [{'bbox': {'x1':'813.0','x2':'946.0','y1': '363.0','y2':'503.0'},'score': 0.7191920876502991','violation': True,'attributes': {}}, 
                   'HELMET': [{'bbox': {'x1':'856.0','x2': '929.0','y1': '315.0','y2': 380.0'},'score': '0.7238528728485107','violation': False,'attributes': {}}]

{'captured_on': '1574861019023', 
 'model_result': [{'VEST': [{'bbox': {'x1':'813.0','x2':'946.0','y1': '363.0','y2':'503.0'},'score': 0.7191920876502991','violation': True,'attributes': {}}, 
                   'HELMET': [{'bbox': {'x1':'856.0','x2': '929.0','y1': '315.0','y2': 380.0'},'score': '0.7238528728485107','violation': False,'attributes': {}}]

{'captured_on': '1574861019023', 
 'model_result': [{'VEST': [{'bbox': {'x1':'813.0','x2':'946.0','y1': '363.0','y2':'503.0'},'score': 0.7191920876502991','violation': True,'attributes': {}}, 
                   'HELMET': [{'bbox': {'x1':'856.0','x2': '929.0','y1': '315.0','y2': 380.0'},'score': '0.7238528728485107','violation': False,'attributes': {}},{'bbox': {'x1':'696.0','x2': '744.0','y1': '309.0','y2': 381.0'},'score': '0.7238528728485107','violation': False,'attributes': {}}]

现在,我将根据每分钟的结果编制索引,并与同一分钟的结果进行比较,并检查它们是否相似,并消除得分较低的结果。的代码如下

import pandas as pd
import more_itertools
import datetime
import json
df = pd.DataFrame(rows[1:5])
df.columns = colnames
times = pd.DatetimeIndex(df.captured_on)
grouped = df.groupby([times.hour, times.minute])
for i in grouped:
    data = [j for j in i[1]['model_result']]
    for a, b in more_itertools.pairwise(data):
        compare(a, b)

在比较中,我正在检查bbox值(矩形坐标)是否相互重叠。我想知道是否还有更好的方法。

0 个答案:

没有答案