Skip to content

Commit

Permalink
allow vis_processor to be None and return the uncropped pillow image …
Browse files Browse the repository at this point in the history
…in that case
  • Loading branch information
simon-ging committed Jul 8, 2024
1 parent ef36a16 commit 5e3ecb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ovqa/datasets/activitynet_vqa_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ def __getitem__(self, index):
if self.return_visual:
image_path = Path(self.vis_root) / ann["file_name"]
image_pil = Image.open(image_path).convert("RGB")
image = self.vis_processor(image_pil)
if self.vis_processor is not None:
image = self.vis_processor(image_pil)
else:
image = image_pil
sample["image"] = image

question = self.config.get("question_type", "none")
Expand Down
5 changes: 4 additions & 1 deletion ovqa/datasets/classifier_vqa_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def __getitem__(self, index):
if self.return_visual:
image_path = Path(self.vis_root) / ann["image"]
image_pil = Image.open(image_path).convert("RGB")
image = self.vis_processor(image_pil)
if self.vis_processor is not None:
image = self.vis_processor(image_pil)
else:
image = image_pil
sample["image"] = image

# add object to ask followup questions about in case it is in the annotation
Expand Down
10 changes: 8 additions & 2 deletions ovqa/datasets/coco_objects_vqa_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ def __getitem__(self, index):
self.config.get("min_side", 40.0),
self.config.get("square_box", False),
)
image = self.vis_processor(image_pil)
if self.vis_processor is not None:
image = self.vis_processor(image_pil)
else:
image = image_pil
sample["image"] = image

question = self.config.get("question_type", "none")
Expand Down Expand Up @@ -497,7 +500,10 @@ def __getitem__(self, index):
self.config.get("min_side", 40.0),
self.config.get("square_box", False),
)
image = self.vis_processor(image_pil)
if self.vis_processor is not None:
image = self.vis_processor(image_pil)
else:
image = image_pil
sample["image"] = image

# debug_loading(self.config.get("debug_dir", ""), original_image, crop_image, sample, annotation)
Expand Down

0 comments on commit 5e3ecb7

Please sign in to comment.