Spaces:
Sleeping
Sleeping
vickeee465
commited on
Commit
·
40de5cf
1
Parent(s):
2942bd5
debugging for a while
Browse files
app.py
CHANGED
@@ -73,15 +73,24 @@ def get_most_probable_label(probs):
|
|
73 |
probability = f"{round(100 * probs.max(), 2)}%"
|
74 |
return label, probability
|
75 |
|
|
|
76 |
def prepare_heatmap_data(data):
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
for idx, item in enumerate(data):
|
79 |
-
print(item
|
|
|
|
|
|
|
|
|
80 |
confidences = item["emotions"].tolist()
|
81 |
-
|
82 |
-
for idy, confidence in enumerate(confidences): # it's a numpy array...
|
83 |
emotion = id2label[idy]
|
84 |
heatmap_data.at[idx, emotion] = confidence
|
|
|
85 |
heatmap_data.index = [item["sentence"] for item in data]
|
86 |
return heatmap_data
|
87 |
|
|
|
73 |
probability = f"{round(100 * probs.max(), 2)}%"
|
74 |
return label, probability
|
75 |
|
76 |
+
|
77 |
def prepare_heatmap_data(data):
|
78 |
+
print("DEBUG: Data type received in prepare_heatmap_data:", type(data))
|
79 |
+
print("DEBUG: Data content:", data)
|
80 |
+
|
81 |
+
heatmap_data = pd.DataFrame(0.0, index=range(len(data)), columns=id2label.values())
|
82 |
+
|
83 |
for idx, item in enumerate(data):
|
84 |
+
print(f"DEBUG: Item at index {idx}: {item} (type: {type(item)})")
|
85 |
+
|
86 |
+
if not isinstance(item, dict):
|
87 |
+
raise TypeError(f"Expected dict, but got {type(item)} at index {idx}: {item}")
|
88 |
+
|
89 |
confidences = item["emotions"].tolist()
|
90 |
+
for idy, confidence in enumerate(confidences):
|
|
|
91 |
emotion = id2label[idy]
|
92 |
heatmap_data.at[idx, emotion] = confidence
|
93 |
+
|
94 |
heatmap_data.index = [item["sentence"] for item in data]
|
95 |
return heatmap_data
|
96 |
|