Rename whitelist and backlist to allowlist and denylist, respectively in audio classifier library.
PiperOrigin-RevId: 371064486
diff --git a/tensorflow_lite_support/cc/task/audio/audio_classifier.cc b/tensorflow_lite_support/cc/task/audio/audio_classifier.cc
index 609b151..2ca15c8 100644
--- a/tensorflow_lite_support/cc/task/audio/audio_classifier.cc
+++ b/tensorflow_lite_support/cc/task/audio/audio_classifier.cc
@@ -142,11 +142,11 @@
options.score_threshold()),
TfLiteSupportStatus::kInvalidArgumentError);
}
- if (options.class_name_whitelist_size() > 0 &&
- options.class_name_blacklist_size() > 0) {
+ if (options.class_name_allowlist_size() > 0 &&
+ options.class_name_denylist_size() > 0) {
return CreateStatusWithPayload(
StatusCode::kInvalidArgument,
- "`class_name_whitelist` and `class_name_blacklist` are mutually "
+ "`class_name_allowlist` and `class_name_denylist` are mutually "
"exclusive options.",
TfLiteSupportStatus::kInvalidArgumentError);
}
@@ -470,8 +470,8 @@
bool class_name_found = class_name_set_.values.contains(class_name);
- if ((!class_name_found && class_name_set_.is_whitelist) ||
- (class_name_found && !class_name_set_.is_whitelist)) {
+ if ((!class_name_found && class_name_set_.is_allowlist) ||
+ (class_name_found && !class_name_set_.is_allowlist)) {
continue;
}
diff --git a/tensorflow_lite_support/cc/task/audio/audio_classifier.h b/tensorflow_lite_support/cc/task/audio/audio_classifier.h
index f1fbcdb..59f4073 100644
--- a/tensorflow_lite_support/cc/task/audio/audio_classifier.h
+++ b/tensorflow_lite_support/cc/task/audio/audio_classifier.h
@@ -130,13 +130,13 @@
// is currently detected by checking if all output tensors data type is uint8.
bool has_uint8_outputs_;
- // Set of whitelisted or blacklisted class names.
+ // Set of allowlisted or denylisted class names.
struct ClassNameSet {
absl::flat_hash_set<std::string> values;
- bool is_whitelist;
+ bool is_allowlist;
};
- // Whitelisted or blacklisted class names based on provided options at
+ // Allowlisted or denylisted class names based on provided options at
// construction time. These are used to filter out results during
// post-processing.
ClassNameSet class_name_set_;
diff --git a/tensorflow_lite_support/cc/task/audio/proto/audio_classifier_options.proto b/tensorflow_lite_support/cc/task/audio/proto/audio_classifier_options.proto
index 9817a6a..b1d7925 100644
--- a/tensorflow_lite_support/cc/task/audio/proto/audio_classifier_options.proto
+++ b/tensorflow_lite_support/cc/task/audio/proto/audio_classifier_options.proto
@@ -38,13 +38,13 @@
// (if any). Results below this value are rejected.
optional float score_threshold = 4;
- // Optional whitelist of class names. If non-empty, classifications whose
+ // Optional allowlist of class names. If non-empty, classifications whose
// class name is not in this set will be filtered out. Duplicate or unknown
- // class names are ignored. Mutually exclusive with class_name_blacklist.
- repeated string class_name_whitelist = 5;
+ // class names are ignored. Mutually exclusive with class_name_denylist.
+ repeated string class_name_allowlist = 5;
- // Optional blacklist of class names. If non-empty, classifications whose
+ // Optional denylist of class names. If non-empty, classifications whose
// class name is in this set will be filtered out. Duplicate or unknown
- // class names are ignored. Mutually exclusive with class_name_whitelist.
- repeated string class_name_blacklist = 6;
-}
\ No newline at end of file
+ // class names are ignored. Mutually exclusive with class_name_allowlist.
+ repeated string class_name_denylist = 6;
+}
diff --git a/tensorflow_lite_support/java/src/native/task/audio/classifier/audio_classifier_jni.cc b/tensorflow_lite_support/java/src/native/task/audio/classifier/audio_classifier_jni.cc
index a814989..6e1a7ee 100644
--- a/tensorflow_lite_support/java/src/native/task/audio/classifier/audio_classifier_jni.cc
+++ b/tensorflow_lite_support/java/src/native/task/audio/classifier/audio_classifier_jni.cc
@@ -160,7 +160,7 @@
jobject allow_list = env->CallObjectMethod(java_options, allow_list_id);
auto allow_list_vector = StringListToVector(env, allow_list);
for (const auto& class_name : allow_list_vector) {
- proto_options.add_class_name_whitelist(class_name);
+ proto_options.add_class_name_allowlist(class_name);
}
jmethodID deny_list_id = env->GetMethodID(
@@ -168,7 +168,7 @@
jobject deny_list = env->CallObjectMethod(java_options, deny_list_id);
auto deny_list_vector = StringListToVector(env, deny_list);
for (const auto& class_name : deny_list_vector) {
- proto_options.add_class_name_blacklist(class_name);
+ proto_options.add_class_name_denylist(class_name);
}
return proto_options;