| 1 | import argparse |
| 2 | import os.path as osp |
| 3 | |
| 4 | import matplotlib.pyplot as plt |
| 5 | |
| 6 | import imgviz |
| 7 | |
| 8 | here = osp.dirname(osp.abspath(__file__)) |
| 9 | |
| 10 | |
| 11 | def run_example(function): |
| 12 | parser = argparse.ArgumentParser( |
| 13 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 14 | ) |
| 15 | parser.add_argument("--save", action="store_true", help="save image") |
| 16 | args = parser.parse_args() |
| 17 | |
| 18 | img = function() |
| 19 | |
| 20 | if args.save: |
| 21 | out_file = osp.join(here, ".readme/{}.jpg".format(function.__name__)) |
| 22 | imgviz.io.imsave(out_file, img) |
| 23 | |
| 24 | plt.imshow(img) |
| 25 | plt.axis("off") |
| 26 | plt.show() |