Skip to content

Commit 591ce8b

Browse files
tensorflower-gardenerxunkai55
authored andcommitted
Rename whitelist and backlist to allowlist and denylist, respectively in audio classifier library.
PiperOrigin-RevId: 371064486
1 parent 6eb0b7c commit 591ce8b

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

tensorflow_lite_support/cc/task/audio/audio_classifier.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ absl::Status AudioClassifier::SanityCheckOptions(
142142
options.score_threshold()),
143143
TfLiteSupportStatus::kInvalidArgumentError);
144144
}
145-
if (options.class_name_whitelist_size() > 0 &&
146-
options.class_name_blacklist_size() > 0) {
145+
if (options.class_name_allowlist_size() > 0 &&
146+
options.class_name_denylist_size() > 0) {
147147
return CreateStatusWithPayload(
148148
StatusCode::kInvalidArgument,
149-
"`class_name_whitelist` and `class_name_blacklist` are mutually "
149+
"`class_name_allowlist` and `class_name_denylist` are mutually "
150150
"exclusive options.",
151151
TfLiteSupportStatus::kInvalidArgumentError);
152152
}
@@ -470,8 +470,8 @@ AudioClassifier::Postprocess(
470470

471471
bool class_name_found = class_name_set_.values.contains(class_name);
472472

473-
if ((!class_name_found && class_name_set_.is_whitelist) ||
474-
(class_name_found && !class_name_set_.is_whitelist)) {
473+
if ((!class_name_found && class_name_set_.is_allowlist) ||
474+
(class_name_found && !class_name_set_.is_allowlist)) {
475475
continue;
476476
}
477477

tensorflow_lite_support/cc/task/audio/audio_classifier.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ class AudioClassifier
130130
// is currently detected by checking if all output tensors data type is uint8.
131131
bool has_uint8_outputs_;
132132

133-
// Set of whitelisted or blacklisted class names.
133+
// Set of allowlisted or denylisted class names.
134134
struct ClassNameSet {
135135
absl::flat_hash_set<std::string> values;
136-
bool is_whitelist;
136+
bool is_allowlist;
137137
};
138138

139-
// Whitelisted or blacklisted class names based on provided options at
139+
// Allowlisted or denylisted class names based on provided options at
140140
// construction time. These are used to filter out results during
141141
// post-processing.
142142
ClassNameSet class_name_set_;

tensorflow_lite_support/cc/task/audio/proto/audio_classifier_options.proto

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ message AudioClassifierOptions {
3838
// (if any). Results below this value are rejected.
3939
optional float score_threshold = 4;
4040

41-
// Optional whitelist of class names. If non-empty, classifications whose
41+
// Optional allowlist of class names. If non-empty, classifications whose
4242
// class name is not in this set will be filtered out. Duplicate or unknown
43-
// class names are ignored. Mutually exclusive with class_name_blacklist.
44-
repeated string class_name_whitelist = 5;
43+
// class names are ignored. Mutually exclusive with class_name_denylist.
44+
repeated string class_name_allowlist = 5;
4545

46-
// Optional blacklist of class names. If non-empty, classifications whose
46+
// Optional denylist of class names. If non-empty, classifications whose
4747
// class name is in this set will be filtered out. Duplicate or unknown
48-
// class names are ignored. Mutually exclusive with class_name_whitelist.
49-
repeated string class_name_blacklist = 6;
50-
}
48+
// class names are ignored. Mutually exclusive with class_name_allowlist.
49+
repeated string class_name_denylist = 6;
50+
}

tensorflow_lite_support/java/src/native/task/audio/classifier/audio_classifier_jni.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ AudioClassifierOptions ConvertToProtoOptions(JNIEnv* env,
160160
jobject allow_list = env->CallObjectMethod(java_options, allow_list_id);
161161
auto allow_list_vector = StringListToVector(env, allow_list);
162162
for (const auto& class_name : allow_list_vector) {
163-
proto_options.add_class_name_whitelist(class_name);
163+
proto_options.add_class_name_allowlist(class_name);
164164
}
165165

166166
jmethodID deny_list_id = env->GetMethodID(
167167
java_options_class, "getLabelDenyList", "()Ljava/util/List;");
168168
jobject deny_list = env->CallObjectMethod(java_options, deny_list_id);
169169
auto deny_list_vector = StringListToVector(env, deny_list);
170170
for (const auto& class_name : deny_list_vector) {
171-
proto_options.add_class_name_blacklist(class_name);
171+
proto_options.add_class_name_denylist(class_name);
172172
}
173173

174174
return proto_options;

0 commit comments

Comments
 (0)