-
Notifications
You must be signed in to change notification settings - Fork 20
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
PR for issue #42 [completed, awaiting review] #50
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f578dcc
feat: add config var for outline thickness
DQ4443 39a4467
Merge branch 'sumn2u:master' into master
DQ4443 0cdf9c6
Merge branch 'master' into master
sumn2u f4c4334
[Feat] add links to README file headings
DQ4443 abd8b5d
Revert "[Feat] add links to README file headings"
DQ4443 431d4b3
[Feat] Update outline thickness config var
DQ4443 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,7 +295,7 @@ def download_image_with_annotations(): | |
points = region['points'] | ||
scaled_points = [(x * width, y * height) for x, y in points] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we define the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I'll make this change |
||
# Draw polygon with thicker outline | ||
draw.line(scaled_points + [scaled_points[0]], fill=color, width=3) # Change width as desired | ||
draw.line(scaled_points + [scaled_points[0]], fill=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['POLYGON']) # Change width as desired | ||
elif all(key in region for key in ('x', 'y', 'w', 'h')): | ||
try: | ||
x = float(region['x'][1:-1]) * width if isinstance(region['x'], str) else float(region['x'][0]) * width | ||
|
@@ -305,7 +305,7 @@ def download_image_with_annotations(): | |
except (ValueError, TypeError) as e: | ||
raise ValueError(f"Invalid format in region dimensions: {region}, Error: {e}") | ||
# Draw rectangle with thicker outline | ||
draw.rectangle([x, y, x + w, y + h], outline=color, width=3) | ||
draw.rectangle([x, y, x + w, y + h], outline=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['BOUNDING_BOX']) | ||
elif all(key in region for key in ('rx', 'ry', 'rw', 'rh')): | ||
try: | ||
rx = float(region['rx'][1:-1]) * width if isinstance(region['rx'], str) else float(region['rx'][0]) * width | ||
|
@@ -315,7 +315,7 @@ def download_image_with_annotations(): | |
except (ValueError, TypeError) as e: | ||
raise ValueError(f"Invalid format in region dimensions: {region}, Error: {e}") | ||
# Draw ellipse (circle if rw and rh are equal) | ||
draw.ellipse([rx, ry, rx + rw, ry + rh], outline=color, width=3) | ||
draw.ellipse([rx, ry, rx + rw, ry + rh], outline=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['CIRCLE']) | ||
|
||
|
||
|
||
|
@@ -375,7 +375,7 @@ def download_image_mask(): | |
if 'points' in region and region['points']: | ||
points = region['points'] | ||
scaled_points = [(int(x * width), int(y * height)) for x, y in points] | ||
draw.polygon(scaled_points, outline=color, fill=color) | ||
draw.polygon(scaled_points, outline=color, fill=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['POLYGON']) | ||
elif all(key in region for key in ('x', 'y', 'w', 'h')): | ||
try: | ||
x = float(region['x'][1:-1]) * width if isinstance(region['x'], str) else float(region['x'][0]) * width | ||
|
@@ -385,7 +385,7 @@ def download_image_mask(): | |
except (ValueError, TypeError) as e: | ||
raise ValueError(f"Invalid format in region dimensions: {region}, Error: {e}") | ||
# Draw rectangle for bounding box | ||
draw.rectangle([x, y, x + w, y + h], outline=color, fill=color) | ||
draw.rectangle([x, y, x + w, y + h], outline=color, fill=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['BOUNDING_BOX']) | ||
elif all(key in region for key in ('rx', 'ry', 'rw', 'rh')): | ||
try: | ||
rx = float(region['rx'][1:-1]) * width if isinstance(region['rx'], str) else float(region['rx'][0]) * width | ||
|
@@ -395,7 +395,7 @@ def download_image_mask(): | |
except (ValueError, TypeError) as e: | ||
raise ValueError(f"Invalid format in region dimensions: {region}, Error: {e}") | ||
# Draw ellipse (circle if rw and rh are equal) | ||
draw.ellipse([rx, ry, rx + rw, ry + rh], outline=color, width=3, fill=color) | ||
draw.ellipse([rx, ry, rx + rw, ry + rh], outline=color, width=app.config['OUTLINE_THICKNESS_CONFIG']['CIRCLE'], fill=color) | ||
|
||
mask_byte_arr = BytesIO() | ||
mask.save(mask_byte_arr, format='PNG') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
MASK_BACKGROUND_COLOR = (0, 0, 0) | ||
MASK_BACKGROUND_COLOR = (0, 0, 0) | ||
OUTLINE_THICKNESS_CONFIG = { | ||
"POLYGON": 3, | ||
"CIRCLE": 3, | ||
"BOUNDING_BOX": 3 | ||
} # change outline thickness (currently only for downloaded files) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to create an object and assign values as per UI tools value. This will give us more flexibility, granularity and will be in sync.