Skip to content

Commit

Permalink
Fix doc_vqa lmms_eval
Browse files Browse the repository at this point in the history
Signed-off-by: elronbandel <[email protected]>
  • Loading branch information
elronbandel committed Oct 20, 2024
1 parent 3d027e9 commit 6b5216f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion prepare/cards/doc_vqa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unitxt.blocks import LoadHF, Set, TaskCard
from unitxt.catalog import add_to_catalog
from unitxt.collections_operators import Explode, Wrap
from unitxt.image_operators import ToImage
from unitxt.image_operators import ToImage, ToRGB
from unitxt.operators import Copy
from unitxt.splitters import RenameSplits
from unitxt.test_utils.card import test_card
Expand Down Expand Up @@ -43,6 +43,7 @@
),
preprocess_steps=[
RenameSplits(mapper={"validation": "test"}),
ToRGB(field="image"),
ToImage(field="image", to_field="context"),
Set(fields={"context_type": "image"}),
],
Expand Down
4 changes: 4 additions & 0 deletions src/unitxt/catalog/cards/doc_vqa/lmms_eval.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"validation": "test"
}
},
{
"__type__": "to_rgb",
"field": "image"
},
{
"__type__": "to_image",
"field": "image",
Expand Down
5 changes: 5 additions & 0 deletions src/unitxt/image_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ def process_image(self, image):

# Convert back to a PIL image with 3 channels
return self.image.fromarray(grayscale_array)


class ToRGB(ImageFieldOperator):
def process_image(self, image):
return image.convert("RGB")

0 comments on commit 6b5216f

Please sign in to comment.