-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctness checking for security_barrier_camera_demo w/ 1 network multi channels with inputting 1 image #3392
base: master
Are you sure you want to change the base?
Changes from 14 commits
8f579f2
fef9a0a
d101b67
7d5ff26
3551ada
3fb15e0
6fb10ef
7eca858
a2f8421
b0845bc
cc86f1d
37f8371
237dcf3
d0e831b
6b9ce5a
85327ef
ab9d19c
f1c5c87
b4d110b
dbe9f13
065ca07
3755135
603c120
2e2ade4
3596cd2
a3e464a
8631f93
91baf7d
2fe3933
128ec7e
0914845
796e315
f33983d
7c47ce7
2f066d1
1562b9b
d2d37e3
65fe33b
1f44622
0ff6d8c
3958ea4
42171be
ba629d0
6c43933
c10b3ce
5ccace4
a5d84dc
77968e6
7c57fd2
f7d7a1d
bb8e615
19f9ff1
8739a29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,8 +220,8 @@ class ClassifiersAggregator { | |
std::mutex& printMutex = static_cast<ReborningVideoFrame*>(sharedVideoFrame.get())->context.classifiersAggregatorPrintMutex; | ||
printMutex.lock(); | ||
if (FLAGS_r && !rawDetections.empty()) { | ||
slog::debug << "Frame #: " << sharedVideoFrame->frameId << slog::endl; | ||
slog::debug << rawDetections; | ||
for (const std::string& rawDetection : rawDetections) | ||
slog::debug << rawDetection << slog::endl; | ||
// destructor assures that none uses the container | ||
for (const std::string& rawAttribute : rawAttributes.container) { | ||
slog::debug << rawAttribute << slog::endl; | ||
|
@@ -292,6 +292,10 @@ ReborningVideoFrame::~ReborningVideoFrame() { | |
context.videoFramesContext.lastFrameIdsMutexes[sourceID].lock(); | ||
const auto frameId = ++context.videoFramesContext.lastframeIds[sourceID]; | ||
context.videoFramesContext.lastFrameIdsMutexes[sourceID].unlock(); | ||
|
||
// Stop reborning when frame ID reached to input queue size | ||
if (!context.isVideo && frameId >= FLAGS_n_iqs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? It just decreases the actual queue size There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From my understanding, the number of frames passing through each channel will be specified by |
||
return; | ||
std::shared_ptr<ReborningVideoFrame> reborn = std::make_shared<ReborningVideoFrame>(context, sourceID, frameId, frame); | ||
worker->push(std::make_shared<Reader>(reborn)); | ||
} catch (const std::bad_weak_ptr&) {} | ||
|
@@ -379,7 +383,9 @@ void Drawer::process() { | |
} else { | ||
if (!context.isVideo) { | ||
try { | ||
std::shared_ptr<Worker>(context.drawersContext.drawersWorker)->stop(); | ||
// Exit only when inferences on all of frames are finished. | ||
if (context.frameCounter >= FLAGS_n_iqs * context.readersContext.inputChannels.size()) | ||
std::shared_ptr<Worker>(context.drawersContext.drawersWorker)->stop(); | ||
} | ||
catch (const std::bad_weak_ptr&) {} | ||
} | ||
|
@@ -428,7 +434,8 @@ bool DetectionsProcessor::isReady() { | |
if (requireGettingNumberOfDetections) { | ||
classifiersAggregator = std::make_shared<ClassifiersAggregator>(sharedVideoFrame); | ||
std::list<Detector::Result> results; | ||
results = context.inferTasksContext.detector.getResults(*inferRequest, sharedVideoFrame->frame.size(), classifiersAggregator->rawDetections); | ||
results = context.inferTasksContext.detector.getResults(*inferRequest, sharedVideoFrame->sourceID, sharedVideoFrame->frameId, sharedVideoFrame->frame.size(), classifiersAggregator->rawDetections); | ||
|
||
for (Detector::Result result : results) { | ||
switch (result.label) { | ||
case 1: | ||
|
@@ -585,7 +592,6 @@ void InferTask::process() { | |
std::reference_wrapper<ov::InferRequest> inferRequest = detectorsInfers.inferRequests.container.back(); | ||
detectorsInfers.inferRequests.container.pop_back(); | ||
detectorsInfers.inferRequests.mutex.unlock(); | ||
|
||
context.inferTasksContext.detector.setImage(inferRequest, sharedVideoFrame->frame); | ||
|
||
inferRequest.get().set_callback( | ||
|
@@ -607,6 +613,7 @@ void InferTask::process() { | |
bool Reader::isReady() { | ||
Context& context = static_cast<ReborningVideoFrame*>(sharedVideoFrame.get())->context; | ||
context.readersContext.lastCapturedFrameIdsMutexes[sharedVideoFrame->sourceID].lock(); | ||
// Look for the next frame | ||
if (context.readersContext.lastCapturedFrameIds[sharedVideoFrame->sourceID] + 1 == sharedVideoFrame->frameId) { | ||
return true; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) 2021 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from abc import ABC, abstractmethod | ||
from unittest import case | ||
|
||
class Demo(ABC): | ||
def __init__(self, name, implementation): | ||
self.name = name | ||
self.implementation = implementation | ||
self.subdirectory = name + '/' + implementation | ||
self.results = {} | ||
|
||
@abstractmethod | ||
def parser(self): | ||
pass | ||
|
||
@abstractmethod | ||
def checker(self): | ||
pass | ||
|
||
class CPPDemo(Demo): | ||
def __init__(self, name, implementation='cpp'): | ||
super().__init__(name, implementation) | ||
self.results = {} | ||
pass | ||
|
||
def parser(self): | ||
fo = None | ||
try: | ||
fo = open('/tmp/' + self.subdirectory + '/results.log', 'r') | ||
except IOError as err: | ||
print("File error: " + str(err)) | ||
output = [i.rstrip() for i in fo.readlines()] | ||
device = '' | ||
case_index = '' | ||
index = 1 | ||
while index < len(output): | ||
if "Device" in output[index]: | ||
device = output[index][output[index].find(":") + 1:] | ||
if device not in self.results: | ||
self.results[device] = {} | ||
|
||
if "CaseId" in output[index]: | ||
case_index = output[index][output[index].find(":") + 1:] | ||
if case_index not in self.results[device]: | ||
self.results[device][case_index] = {} | ||
|
||
if "Execution_time" in output[index]: | ||
execution_time = output[index].split(':')[1] | ||
if execution_time == '-1': | ||
while index < len(output) and 'Device' not in output[index]: | ||
index += 1 | ||
continue | ||
|
||
# Pase the raw data | ||
while index < len(output) and 'ChannelId' in output[index]: | ||
item = output[index][output[index].find('ChannelId'):].split(',') | ||
# Channel ID | ||
frame_results = {} | ||
channel = item[0].split(':') | ||
if channel[1] not in self.results[device][case_index]: | ||
self.results[device][case_index][channel[1]] = frame_results | ||
|
||
# Frame ID | ||
object_results = {} | ||
frame = item[1].split(':') | ||
if frame[1] not in self.results[device][case_index][channel[1]]: | ||
self.results[device][case_index][channel[1]][frame[1]] = object_results | ||
|
||
# Object ID | ||
label_prob_pos_results = [] | ||
objid = item[2].split(':') | ||
if objid[1] not in self.results[device][case_index][channel[1]][frame[1]]: | ||
self.results[device][case_index][channel[1]][frame[1]][objid[1]] = label_prob_pos_results | ||
self.results[device][case_index][channel[1]][frame[1]][objid[1]] = item[3:] | ||
index += 1 | ||
|
||
index += 1 | ||
|
||
|
||
def checker(self): | ||
self.parser() | ||
anzhella-pankratova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
flag = False | ||
if "CPU" in self.results and "AUTO:CPU" in self.results: | ||
if self.results['CPU'] == self.results['AUTO:CPU']: | ||
flag = True | ||
else: | ||
print ("CPU vs AUTO:CPU have inconsistent results") | ||
|
||
if "GPU" in self.results and "AUTO:GPU" in self.results: | ||
if self.results['GPU'] == self.results['AUTO:GPU']: | ||
flag = True | ||
else: | ||
print ("GPU vs AUTO:GPU have inconsistent results") | ||
|
||
if not flag: | ||
for device in self.results: | ||
for case in self.results[device]: | ||
print ("---* Device: {} - Case: {} *----\n".format(device, case)) | ||
for channel in self.results[device][case]: | ||
print ("Channel: {} - :{}".format(channel, self.results[device][case][channel])) | ||
print ('---------------------------------------------------------') | ||
return flag | ||
|
||
|
||
|
||
DEMOS = [ | ||
CPPDemo(name='security_barrier_camera_demo') | ||
] | ||
def main(): | ||
anzhella-pankratova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for demo in DEMOS: | ||
print ("Checking {}...".format(demo.name)) | ||
if demo.checker(): | ||
print("Demo: {} passed.".format(demo.name)) | ||
else: | ||
print("Demo: {} failed.".format(demo.name)) | ||
anzhella-pankratova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import contextlib | ||
import csv | ||
import json | ||
from operator import contains | ||
import os | ||
import shlex | ||
import subprocess # nosec - disable B404:import-subprocess check | ||
|
@@ -261,7 +262,12 @@ def main(): | |
print(header) | ||
print() | ||
demo.set_precisions(args.precisions, model_info) | ||
|
||
filename = '/tmp/' + demo.subdirectory | ||
anzhella-pankratova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
os.makedirs(filename, exist_ok=True) | ||
fo = open(filename + '/results.log', 'w+') | ||
print("Save to {}".format(filename)) | ||
content = '' | ||
content += 'Testing {}...'.format(demo.subdirectory) + '\n' | ||
declared_model_names = set() | ||
for model_data in json.loads(subprocess.check_output( | ||
[sys.executable, '--', str(auto_tools_dir / 'info_dumper.py'), | ||
|
@@ -325,13 +331,20 @@ def option_to_args(key, value): | |
for arg in fixed_args + dev_arg + case_args)) | ||
print(test_descr) | ||
print(flush=True) | ||
content += "Device:{}\nCaseId:{}\n".format(device, test_case_index) | ||
rawResults = '' | ||
execution_time = -1 | ||
try: | ||
start_time = timeit.default_timer() | ||
output = subprocess.check_output(fixed_args + dev_arg + case_args, | ||
stderr=subprocess.STDOUT, universal_newlines=True, encoding='utf-8', | ||
env=demo_environment, timeout=600) | ||
execution_time = timeit.default_timer() - start_time | ||
demo.parse_output(output, test_case, device) | ||
for line in output.split('\n'): | ||
if "DEBUG" in line: | ||
rawResults += line | ||
rawResults += '\n' | ||
demo.parse_output(output, device, test_case_index) | ||
anzhella-pankratova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: | ||
output = e.output | ||
if isinstance(e, subprocess.CalledProcessError): | ||
|
@@ -343,15 +356,20 @@ def option_to_args(key, value): | |
failed_tests.append(test_descr + '\n' + exit_msg) | ||
num_failures += 1 | ||
execution_time = -1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please restore it |
||
|
||
rawResults = {} | ||
|
||
content += "Execution_time:{}\n".format(execution_time) | ||
content += "{}\n".format(rawResults) | ||
fo.write(content) | ||
content = '' | ||
if args.report_file: | ||
collect_result(demo.subdirectory, device, case_model_names, execution_time, args.report_file) | ||
if args.log_file: | ||
if test_case_index == 0: | ||
write_log(header, args.log_file) | ||
write_log(test_descr, args.log_file) | ||
write_log(output, args.log_file) | ||
|
||
fo.close() | ||
print() | ||
|
||
print("{} failures:".format(num_failures)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be required for security_barrier_camera_demo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update