Project import generated by Copybara.

GitOrigin-RevId: bb059a0721c92e8154d33ce8057b3915a25b3d7d
This commit is contained in:
MediaPipe Team
2021-12-13 15:56:02 -08:00
committed by jqtang
parent cf101e62a9
commit e6c19885c6
96 changed files with 554 additions and 486 deletions
@@ -38,7 +38,6 @@ constexpr char kDetectionsTag[] = "DETECTIONS";
constexpr char kLabelsTag[] = "LABELS";
constexpr char kLabelsCsvTag[] = "LABELS_CSV";
using mediapipe::ContainsKey;
using mediapipe::RE2;
using Detections = std::vector<Detection>;
using Strings = std::vector<std::string>;
@@ -161,24 +160,24 @@ absl::Status FilterDetectionCalculator::Open(CalculatorContext* cc) {
limit_labels_ = cc->InputSidePackets().HasTag(kLabelsTag) ||
cc->InputSidePackets().HasTag(kLabelsCsvTag);
if (limit_labels_) {
Strings whitelist_labels;
Strings allowlist_labels;
if (cc->InputSidePackets().HasTag(kLabelsCsvTag)) {
whitelist_labels = absl::StrSplit(
allowlist_labels = absl::StrSplit(
cc->InputSidePackets().Tag(kLabelsCsvTag).Get<std::string>(), ',',
absl::SkipWhitespace());
for (auto& e : whitelist_labels) {
for (auto& e : allowlist_labels) {
absl::StripAsciiWhitespace(&e);
}
} else {
whitelist_labels = cc->InputSidePackets().Tag(kLabelsTag).Get<Strings>();
allowlist_labels = cc->InputSidePackets().Tag(kLabelsTag).Get<Strings>();
}
allowed_labels_.insert(whitelist_labels.begin(), whitelist_labels.end());
allowed_labels_.insert(allowlist_labels.begin(), allowlist_labels.end());
}
if (limit_labels_ && allowed_labels_.empty()) {
if (options_.fail_on_empty_labels()) {
cc->GetCounter("VideosWithEmptyLabelsWhitelist")->Increment();
cc->GetCounter("VideosWithEmptyLabelsAllowlist")->Increment();
return tool::StatusFail(
"FilterDetectionCalculator received empty whitelist with "
"FilterDetectionCalculator received empty allowlist with "
"fail_on_empty_labels = true.");
}
if (options_.empty_allowed_labels_means_allow_everything()) {