Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -87,11 +87,23 @@ def classify_toxicity(audio_file, selected_sounds, slider):
|
|
87 |
scores = average_logprobs.softmax(-1).tolist()
|
88 |
|
89 |
class_score_dict = {class_name: score for class_name, score in zip(class_names, scores)}
|
90 |
-
|
|
|
91 |
for selected_class_name in selected_sounds:
|
92 |
print(selected_sounds)
|
93 |
if selected_class_name in class_score_dict:
|
94 |
-
score = class_score_dict[selected_class_name]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
print(score)
|
96 |
if score > threshold:
|
97 |
print(f"Threshold exceeded for class '{selected_class_name}': Score = {score:.4f}")
|
@@ -99,6 +111,7 @@ def classify_toxicity(audio_file, selected_sounds, slider):
|
|
99 |
else:
|
100 |
print("under threshold")
|
101 |
affirm = ""
|
|
|
102 |
miso_label_data= {class_name: score for class_name, score in zip(class_names, scores)}
|
103 |
# miso_label_dict = {label: score for label, score in classify_anxiety[0].items()}
|
104 |
|
|
|
87 |
scores = average_logprobs.softmax(-1).tolist()
|
88 |
|
89 |
class_score_dict = {class_name: score for class_name, score in zip(class_names, scores)}
|
90 |
+
matching_label_score = {}
|
91 |
+
exceeding_threshold = []
|
92 |
for selected_class_name in selected_sounds:
|
93 |
print(selected_sounds)
|
94 |
if selected_class_name in class_score_dict:
|
95 |
+
#score = class_score_dict[selected_class_name]
|
96 |
+
matching_label_score[class_name] = label_score_dict[class_name]
|
97 |
+
for label, score in matching_label_score.items():
|
98 |
+
# Check if the score is greater than the threshold
|
99 |
+
if score > threshold:
|
100 |
+
# If it exceeds the threshold, append the label and score to the list
|
101 |
+
exceeding_threshold.append((label, score))
|
102 |
+
affirm = f"Threshold exceeded with "{exceeding_threshold}
|
103 |
+
else:
|
104 |
+
affirm = ""
|
105 |
+
|
106 |
+
'''
|
107 |
print(score)
|
108 |
if score > threshold:
|
109 |
print(f"Threshold exceeded for class '{selected_class_name}': Score = {score:.4f}")
|
|
|
111 |
else:
|
112 |
print("under threshold")
|
113 |
affirm = ""
|
114 |
+
'''
|
115 |
miso_label_data= {class_name: score for class_name, score in zip(class_names, scores)}
|
116 |
# miso_label_dict = {label: score for label, score in classify_anxiety[0].items()}
|
117 |
|