Skip to content

Commit

Permalink
add RESIZE_RATIO
Browse files Browse the repository at this point in the history
  • Loading branch information
jesicasusanto committed May 29, 2023
1 parent ce3bcbf commit f221598
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions openadapt/strategies/mixins/sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MyReplayStrategy(SAMReplayStrategyMixin):
}
MODEL_NAME = "default"
CHECKPOINT_DIR_PATH = "./checkpoints"

RESIZE_RATIO = 0.1

class SAMReplayStrategyMixin(BaseReplayStrategy):
def __init__(
Expand Down Expand Up @@ -98,8 +98,8 @@ def get_click_event_bbox(self, screenshot: Screenshot) -> str:
array_resized = np.array(image_resized)

# Resize mouse coordinates
resized_mouse_x = int(action_event.mouse_x * 0.1)
resized_mouse_y = int(action_event.mouse_y * 0.1)
resized_mouse_x = int(action_event.mouse_x * RESIZE_RATIO)
resized_mouse_y = int(action_event.mouse_y * RESIZE_RATIO)
self.sam_predictor.set_image(array_resized)
input_point = np.array([[resized_mouse_x, resized_mouse_y]])
input_label = np.array([1])
Expand Down Expand Up @@ -139,8 +139,7 @@ def resize_image(image: Image) -> Image:
PIL.Image.Image: The resized image.
"""
resize_ratio = 0.1
new_size = [int(dim * resize_ratio) for dim in image.size]
new_size = [int(dim * RESIZE_RATIO) for dim in image.size]
image_resized = image.resize(new_size)
return image_resized

Expand Down

0 comments on commit f221598

Please sign in to comment.