Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM2: image pipeline #358

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

SAM2: image pipeline #358

wants to merge 16 commits into from

Conversation

parthchadha
Copy link
Collaborator

@parthchadha parthchadha commented Nov 12, 2024

This PR adds Tripy implementation of SAM2.

Work done by @yizhuoz004, @akhilg-nv, @parthchadha.

Comment on lines 100 to 116
specs = []
placeholder_regex = r"{(\d+\.?\d*)±(\d+)%}"
pattern = expected_output

# Replace tolerance patterns with more flexible capture group
matches = list(re.finditer(placeholder_regex, pattern))
for match in matches:
specs.append((match.group(1), match.group(2)))
pattern = pattern.replace(match.group(0), r"(\d+\.?\d*)", 1)

# Escape parentheses but not our capture group
pattern = pattern.replace("(", r"\(")
pattern = pattern.replace(")", r"\)")
pattern = pattern.replace(r"\(\d+\.?\d*\)", r"(\d+\.?\d*)")

# Make whitespace flexible
pattern = pattern.replace(" ", r"\s+")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand what's happening here. Can we encode the flexibility into the regex itself?

@pranavm-nvidia
Copy link
Collaborator

Very cool tolerance mechanism for example testing!

@parthchadha parthchadha marked this pull request as ready for review November 27, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants