From 039837f32f753b24fd7503f20bc382e8c2370e05 Mon Sep 17 00:00:00 2001 From: PhuTd03 Date: Wed, 24 Apr 2024 01:13:14 +0700 Subject: [PATCH] fix: fix size in .run_grounding --- tool/detector.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tool/detector.py b/tool/detector.py index c0ccbcc9..d57fea03 100644 --- a/tool/detector.py +++ b/tool/detector.py @@ -62,7 +62,14 @@ def run_grounding(self, origin_frame, grounding_caption, box_threshold, text_thr transfered_boxes: nd.array [N, 4]: [[x0, y0], [x1, y1]] ''' height, width, _ = origin_frame.shape - img_pil = PIL.Image.fromarray(origin_frame) + # width, height = origin_frame.size + # If origin_frame is already a PIL Image object, you don't need to do anything + if isinstance(origin_frame, PIL.Image.Image): + img_pil = origin_frame + else: + # Convert origin_frame to a NumPy array and then to a PIL Image + origin_frame = np.array(origin_frame) + img_pil = PIL.Image.fromarray(origin_frame) re_width, re_height = img_pil.size _, image_tensor = self.image_transform_grounding(img_pil) # img_pil = self.image_transform_grounding_for_vis(img_pil)