问题描述
我已经为def changeBandwith( node ):
for intf in node.intfList(): # loop on interfaces of node
#info( ' %s:'%intf )
if intf.link: # get link that connects to interface(if any)
newBW = 5
intfs = [ intf.link.intf1,intf.link.intf2 ] #intfs[0] is source of link and intfs[1] is dst of link
intfs[0].config(bw=newBW)
intfs[1].config(bw=newBW)
else:
info( ' \n' )
def manageLinks():
nodes = net.switches + net.hosts
for node in nodes:
changeBandwith(node)
训练了SVM
模型。但是在推断视频时,它变得太慢了。
我遇到了一个类似的问题:Why is dlib so slow finding an object?,其中一个答案是说要安装simple_object_detector()
时启用USE_AVX_INSTRUCTIONS
标志。但对我而言并非如此。我发现默认情况下该标志为启用状态。我也遇到了以下常见问题解答:Why is dlib slow,其中的解决方案是在dlib
中选择Release
模式,但我没有使用Visual Studio
,而只是从终端运行代码。
但是有趣的是,如果我运行内置的人脸检测器Visual Studio
,它将运行完全没有延迟。但是该程序只会在运行根据自定义数据训练的dlib.get_frontal_face_detector()
时变慢。
解决方法
好的!我找到了解决方案。实际上,我在运行检测器时错过了提供标志的机会。可能与某些优化有关。
首先初始化检测器对象:
detector = dlib.simple_object_detector("/path/to/your/trained/SVM/detector")
现在从此更改以下行:
detections = detector(gray_image)
对此:
detections = detector(gray_image,0)
参考: https://github.com/davisking/dlib/issues/557#issuecomment-297679025