Enhance output path handling for image distortion#3
Open
krataratha wants to merge 1 commit into
Open
Conversation
Added dynamic output folder naming based on distortion type.
There was a problem hiding this comment.
Pull request overview
This PR enhances add_distortion.py so the output directory can default dynamically to ./perturbations/[type] when --img_out isn’t provided, aligning output paths with the chosen distortion type.
Changes:
- Changed
--img_outdefault from a fixed folder toNone, and derivedoutput_rootfrom distortion type when unset. - Refactored save-path construction to use
output_rootand introduced animg_pathvariable for readability.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
18
to
+21
| parser.add_argument('--img_out', '-o', | ||
| type=str, | ||
| default='./perturbations/CS', | ||
| help='path to the output video') | ||
| default=None, | ||
| help='path to the output video (defaults to ./perturbations/[type])') |
Comment on lines
22
to
26
| parser.add_argument( | ||
| '--type', '-t', | ||
| type=str, | ||
| default='CS', | ||
| help='distortion type: CS | CC | JPEG | GB') |
| if not os.path.exists(os.path.join(args.img_out, dir)): | ||
| os.makedirs(os.path.join(args.img_out, dir)) | ||
| cv2.imwrite(os.path.join(args.img_out, dir, img), per_img) | ||
|
|
Comment on lines
+39
to
+40
| if not os.path.exists(save_dir): | ||
| os.makedirs(save_dir) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added dynamic output folder naming based on distortion type.