Spaces:
Runtime error
Runtime error
Alex Strick van Linschoten
commited on
Commit
·
68eace8
1
Parent(s):
d22e7be
fix reference to pred_dict
Browse files
app.py
CHANGED
@@ -33,11 +33,11 @@ labels = learn.dls.vocab
|
|
33 |
|
34 |
|
35 |
def get_content_area(pred_dict) -> int:
|
36 |
-
if "content" not in pred_dict["labels"]:
|
37 |
return 0
|
38 |
content_bboxes = [
|
39 |
-
pred_dict["bboxes"][idx]
|
40 |
-
for idx, label in enumerate(pred_dict["labels"])
|
41 |
if label == "content"
|
42 |
]
|
43 |
cb = content_bboxes[0]
|
@@ -45,11 +45,11 @@ def get_content_area(pred_dict) -> int:
|
|
45 |
|
46 |
|
47 |
def get_redaction_area(pred_dict) -> int:
|
48 |
-
if "redaction" not in pred_dict["labels"]:
|
49 |
return 0
|
50 |
redaction_bboxes = [
|
51 |
-
pred_dict["bboxes"][idx]
|
52 |
-
for idx, label in enumerate(pred_dict["labels"])
|
53 |
if label == "redaction"
|
54 |
]
|
55 |
return sum(
|
@@ -137,7 +137,7 @@ def predict(pdf, confidence, generate_file):
|
|
137 |
font_size=16,
|
138 |
label_color="#FF59D6",
|
139 |
)
|
140 |
-
print(pred_dict)
|
141 |
|
142 |
total_image_areas += pred_dict["width"] * pred_dict["height"]
|
143 |
total_content_areas += get_content_area(pred_dict)
|
|
|
33 |
|
34 |
|
35 |
def get_content_area(pred_dict) -> int:
|
36 |
+
if "content" not in pred_dict["detection"]["labels"]:
|
37 |
return 0
|
38 |
content_bboxes = [
|
39 |
+
pred_dict["detection"]["bboxes"][idx]
|
40 |
+
for idx, label in enumerate(pred_dict["detection"]["labels"])
|
41 |
if label == "content"
|
42 |
]
|
43 |
cb = content_bboxes[0]
|
|
|
45 |
|
46 |
|
47 |
def get_redaction_area(pred_dict) -> int:
|
48 |
+
if "redaction" not in pred_dict["detection"]["labels"]:
|
49 |
return 0
|
50 |
redaction_bboxes = [
|
51 |
+
pred_dict["detection"]["bboxes"][idx]
|
52 |
+
for idx, label in enumerate(pred_dict["detection"]["labels"])
|
53 |
if label == "redaction"
|
54 |
]
|
55 |
return sum(
|
|
|
137 |
font_size=16,
|
138 |
label_color="#FF59D6",
|
139 |
)
|
140 |
+
# print(pred_dict)
|
141 |
|
142 |
total_image_areas += pred_dict["width"] * pred_dict["height"]
|
143 |
total_content_areas += get_content_area(pred_dict)
|