Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

gandlf_anonymizer 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  1. #!usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os, argparse, sys, yaml
  4. from GANDLF.anonymize import run_anonymizer
  5. from GANDLF.cli import copyrightMessage
  6. def main():
  7. parser = argparse.ArgumentParser(
  8. prog="GANDLF_Anonymize",
  9. formatter_class=argparse.RawTextHelpFormatter,
  10. description="Anonymize images/scans in the data directory.\n\n"
  11. + copyrightMessage,
  12. )
  13. parser.add_argument(
  14. "-i",
  15. "--inputDir",
  16. metavar="",
  17. type=str,
  18. help="Input directory or file which contains images to be anonymized.",
  19. )
  20. parser.add_argument(
  21. "-c",
  22. "--config",
  23. metavar="",
  24. default="",
  25. type=str,
  26. help="config (in YAML) for running anonymization, optionally, specify modality using '-m' for defaults.",
  27. )
  28. parser.add_argument(
  29. "-m",
  30. "--modality",
  31. metavar="",
  32. default="rad",
  33. type=str,
  34. help="The modality type, can be 'rad' or 'histo'.",
  35. )
  36. parser.add_argument(
  37. "-o",
  38. "--outputFile",
  39. metavar="",
  40. type=str,
  41. help="Output directory or file which will contain the image(s) after anonymization.",
  42. )
  43. args = parser.parse_args()
  44. # check for required parameters - this is needed here to keep the cli clean
  45. for param_none_check in [args.inputDir, args.outputFile]:
  46. if param_none_check is None:
  47. sys.exit("ERROR: Missing required parameter:", param_none_check)
  48. inputDir = os.path.normpath(args.inputDir)
  49. outputFile = os.path.normpath(args.outputFile)
  50. if os.path.isfile(args.config):
  51. config = yaml.safe_load(open(args.config, "r"))
  52. else:
  53. config = None
  54. run_anonymizer(inputDir, outputFile, config, args.modality)
  55. print("Finished successfully.")
  56. # main function
  57. if __name__ == "__main__":
  58. main()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...