Unverified Commit 20abdacb authored by assafbot's avatar assafbot Committed by GitHub
Browse files

OWLv2: bug fix in post_process_object_detection() when using cuda device (#27468)

* OWLv2: bug fix in post_process_object_detection() when using cuda device

* fix copies issue by fixing original function in owlvit
parent 68ae3be7
...@@ -504,7 +504,7 @@ class Owlv2ImageProcessor(BaseImageProcessor): ...@@ -504,7 +504,7 @@ class Owlv2ImageProcessor(BaseImageProcessor):
else: else:
img_h, img_w = target_sizes.unbind(1) img_h, img_w = target_sizes.unbind(1)
scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1) scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1).to(boxes.device)
boxes = boxes * scale_fct[:, None, :] boxes = boxes * scale_fct[:, None, :]
results = [] results = []
......
...@@ -448,7 +448,7 @@ class OwlViTImageProcessor(BaseImageProcessor): ...@@ -448,7 +448,7 @@ class OwlViTImageProcessor(BaseImageProcessor):
# Convert from relative [0, 1] to absolute [0, height] coordinates # Convert from relative [0, 1] to absolute [0, height] coordinates
img_h, img_w = target_sizes.unbind(1) img_h, img_w = target_sizes.unbind(1)
scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1) scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1).to(boxes.device)
boxes = boxes * scale_fct[:, None, :] boxes = boxes * scale_fct[:, None, :]
results = [{"scores": s, "labels": l, "boxes": b} for s, l, b in zip(scores, labels, boxes)] results = [{"scores": s, "labels": l, "boxes": b} for s, l, b in zip(scores, labels, boxes)]
...@@ -498,7 +498,7 @@ class OwlViTImageProcessor(BaseImageProcessor): ...@@ -498,7 +498,7 @@ class OwlViTImageProcessor(BaseImageProcessor):
else: else:
img_h, img_w = target_sizes.unbind(1) img_h, img_w = target_sizes.unbind(1)
scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1) scale_fct = torch.stack([img_w, img_h, img_w, img_h], dim=1).to(boxes.device)
boxes = boxes * scale_fct[:, None, :] boxes = boxes * scale_fct[:, None, :]
results = [] results = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment