From 82e708ff94d4f5591f0293969992c904f487e299 Mon Sep 17 00:00:00 2001 From: Askill Date: Sun, 1 Nov 2020 21:50:24 +0100 Subject: [PATCH] ignoring the giraffe --- Application/Classifiers/Classifier.py | 33 ++++++++++++++++++++------- README.md | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Application/Classifiers/Classifier.py b/Application/Classifiers/Classifier.py index d5dc6e8..ad0dc63 100644 --- a/Application/Classifiers/Classifier.py +++ b/Application/Classifiers/Classifier.py @@ -7,6 +7,7 @@ import tensorflow as tf import cv2 import os import json +import imutils from Application.Classifiers.ClassifierInterface import ClassifierInterface @@ -32,20 +33,36 @@ class Classifier(ClassifierInterface): #print(self.classes[classes[i]]) return self.classes[classes[i]] - def tagLayer(self, data): res = [] for cnts in data: for cnt in cnts: if cnt.any(): + cnt= imutils.resize(cnt, width=320) x = self.detect(cnt) - if x not in res: - res.append(x) - if x is not None: - print(x) - cv2.imshow("changes x", cnt) - cv2.waitKey(10) & 0XFF - return res + + res.append(x) + + di = dict() + for re in res: + if re not in di: + di[re] = 0 + di[re]+=1 + + # remove all tags that occour infrequently + # if a giraff is only seen in 2 out of 100 frames, there probably wasn't a giraff in the layer + # + di.pop(None, None) + total = 0 + for value in di.values(): + total += value + + result = [] + for key, value in di.items(): + if value > len(data) / len(di) / 2: + result.append(key) + + return result # Detector API can be changed out given the I/O remains the same # this way you can use a different N-Net if you like to diff --git a/README.md b/README.md index aeffde5..62f67d5 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,5 @@ Time consumed reading video: 240.s 3.06GB 26min 1080p downscaled 500p 30fps contour extraction: 10.5 Sec. when only 2 Threads 8 secs when also mapping getContours() + +install tensorflow==1.15.0 and tensorflow-gpu==1.15.0, cuda 10.2 and 10.0, copy missing files from 10.0 to 10.2, restart computer, set maximum vram \ No newline at end of file