Update modeling_florence2.py
Browse files- modeling_florence2.py +3 -1
modeling_florence2.py
CHANGED
|
@@ -2758,7 +2758,7 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
|
|
| 2758 |
results = []
|
| 2759 |
|
| 2760 |
for generated_text, batch_indices_of_bboxes_in_generated_text, list_of_list_of_bboxes in zip(generated_texts, batch_indices_of_bboxes_in_generated_text, list_of_list_of_list_of_bboxes):
|
| 2761 |
-
categories = [map_to_category
|
| 2762 |
result_for_this_image = {
|
| 2763 |
"panels": [],
|
| 2764 |
"texts": [],
|
|
@@ -2766,6 +2766,8 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
|
|
| 2766 |
"tails": [],
|
| 2767 |
}
|
| 2768 |
for category, list_of_bboxes in zip(categories, list_of_list_of_bboxes):
|
|
|
|
|
|
|
| 2769 |
result_for_this_image[category].extend(list_of_bboxes)
|
| 2770 |
results.append(result_for_this_image)
|
| 2771 |
|
|
|
|
| 2758 |
results = []
|
| 2759 |
|
| 2760 |
for generated_text, batch_indices_of_bboxes_in_generated_text, list_of_list_of_bboxes in zip(generated_texts, batch_indices_of_bboxes_in_generated_text, list_of_list_of_list_of_bboxes):
|
| 2761 |
+
categories = [map_to_category.get(generated_text[j:j+3], None) for i, j in batch_indices_of_bboxes_in_generated_text]
|
| 2762 |
result_for_this_image = {
|
| 2763 |
"panels": [],
|
| 2764 |
"texts": [],
|
|
|
|
| 2766 |
"tails": [],
|
| 2767 |
}
|
| 2768 |
for category, list_of_bboxes in zip(categories, list_of_list_of_bboxes):
|
| 2769 |
+
if category is None:
|
| 2770 |
+
continue
|
| 2771 |
result_for_this_image[category].extend(list_of_bboxes)
|
| 2772 |
results.append(result_for_this_image)
|
| 2773 |
|