Spaces:
Sleeping
Sleeping
Update helper.py
Browse files
helper.py
CHANGED
@@ -61,14 +61,17 @@ def summarize_predictions_natural_language(predictions):
|
|
61 |
result_string = "In this image, there are "
|
62 |
for i, (label, count) in enumerate(summary.items()):
|
63 |
count_string = p.number_to_words(count)
|
64 |
-
|
|
|
|
|
|
|
65 |
if count > 1:
|
66 |
result_string += "s"
|
67 |
|
68 |
result_string += " "
|
69 |
|
70 |
if i == len(summary) - 2:
|
71 |
-
result_string += "and "
|
72 |
|
73 |
# Remove the trailing comma and space
|
74 |
result_string = result_string.rstrip(', ') + "."
|
|
|
61 |
result_string = "In this image, there are "
|
62 |
for i, (label, count) in enumerate(summary.items()):
|
63 |
count_string = p.number_to_words(count)
|
64 |
+
if i == 0 or i != len(summary) - 2:
|
65 |
+
result_string += f"{count_string} {label}"
|
66 |
+
else:
|
67 |
+
result_string += f",{count_string} {label}"
|
68 |
if count > 1:
|
69 |
result_string += "s"
|
70 |
|
71 |
result_string += " "
|
72 |
|
73 |
if i == len(summary) - 2:
|
74 |
+
result_string += ", and "
|
75 |
|
76 |
# Remove the trailing comma and space
|
77 |
result_string = result_string.rstrip(', ') + "."
|