コード例 #1
0
ファイル: Porn.py プロジェクト: mpskex/PornDetector
 def classify(self, img):
     IHandler = Func.PornImageHandler()
     #img = cv2.imread(filename)
     num = 1
     VecList = []
     label = []
     #   将图片特征向量
     VecList.append(IHandler.GetFeature(img))
     label.append(1)
     num += 1
     if os.path.exists(self.modelpath):
         model = svm.svm_load_model(self.modelpath)
     else:
         self.train()
     p_labs, p_acc, p_vals = svm.svm_predict(label, VecList, model, '-b 1')
     print p_labs, p_acc, p_vals
     if p_labs[0] > 0.5:
         return True
     else:
         return False
コード例 #2
0
ファイル: Porn.py プロジェクト: mpskex/PornDetector
 def ExtractFeature(self, truepath, falsepath):
     num = 1
     VecList = []
     label = []
     self.truelist = self.__load_images(truepath)
     self.falselist = self.__load_images(falsepath)
     IHandler = Func.PornImageHandler()
     #   训练正样本
     for img in self.truelist:
         self.__SubProc(IHandler, VecList, label, img, 1, num,
                        len(self.truelist) + len(self.falselist))
         num += 1
     #   训练负样本
     for img in self.falselist:
         self.__SubProc(IHandler, VecList, label, img, 0, num,
                        len(self.truelist) + len(self.falselist))
         num += 1
     print "[*]  Created Process Pool!"
     print len(VecList), " ", len(label)
     return label, VecList
コード例 #3
0
ファイル: PFeatureMulti.py プロジェクト: mpskex/PornDetector
def run(P, truepath, falsepath):
    IHandler = Func.PornImageHandler()
    truelist = __load_images(truepath)
    falselist = __load_images(falsepath)
    #   Multi Proc
    VecList = []
    label = []
    result = []
    num = 1
    pool = Pool()
    for img in truelist:
        result.append(pool.apply_async(SubProc, args = (IHandler, img, 1, num, len(truelist) + len(falselist), )))
        num += 1
    for img in falselist:
        result.append(pool.apply_async(SubProc, args = (IHandler, img, 0, num, len(truelist) + len(falselist), )))
        num += 1
    pool.close()
    pool.join()
    for r in result:
        print r.get()[1]
        VecList.append(r.get()[0])
        label.append(r.get()[1])
    return label, VecList