def add_rendering_args(parser): group = parser.add_argument_group("Rendering") options.add_common_eval_args(group) group.add_argument("--render-beam", default=5, type=int, metavar="N", help="beam size for parallel rendering") group.add_argument("--render-resolution", default="512x512", type=str, metavar="N", help='if provide two numbers, means H x W') group.add_argument("--render-angular-speed", default=1, type=float, metavar="D", help="angular speed when rendering around the object") group.add_argument("--render-num-frames", default=500, type=int, metavar="N") group.add_argument("--render-path-style", default="circle", choices=["circle", "zoomin_circle", "zoomin_line"], type=str) group.add_argument("--render-path-args", default="{'radius': 2.5, 'h': 0.0}", help="specialized arguments for rendering paths") group.add_argument("--render-output", default=None, type=str) group.add_argument("--render-at-vector", default="(0,0,0)", type=str) group.add_argument("--render-up-vector", default="(0,0,-1)", type=str) group.add_argument("--render-output-types", nargs="+", type=str, default=["color"], choices=[ "target", "color", "depth", "normal", "voxel", "predn", "point", "featn2", "vcolors" ]) group.add_argument("--render-raymarching-steps", default=None, type=int) group.add_argument("--render-save-fps", default=24, type=int) group.add_argument("--render-combine-output", action='store_true', help="if set, concat the images into one file.") group.add_argument("--render-camera-poses", default=None, type=str, help="text file saved for the testing trajectories") group.add_argument("--render-camera-intrinsics", default=None, type=str) group.add_argument( "--render-views", type=str, default=None, help= "views sampled for rendering, you can set specific view id, or a range" )
def get_lm_scorer_parser(default_task='language_modeling'): parser = options.get_parser('Evaluate Language Model', default_task) options.add_dataset_args(parser, gen=True) options.add_common_eval_args(parser) add_lm_scorer_args(parser) return parser
for arg in vars(parsed_args).keys(): setattr(args, arg, getattr(parsed_args, arg)) task = tasks.setup_task(args) # Load dataset splits task.load_dataset(args.gen_subset) print('| {} {} {} examples'.format(args.data, args.gen_subset, len(task.dataset(args.gen_subset)))) eval_dataset(task, model, task.dataset(args.gen_subset), args.out_file, args.thresholds, args.compute_metrics, use_cuda) if __name__ == '__main__': parser = options.get_parser('Evaluate Single Sentence Classifier', 'sentence_classification') options.add_common_eval_args(parser) options.add_dataset_args(parser, gen=True) parser.add_argument('--out-file', type=str, help='output filename') parser.add_argument('--thresholds', nargs='+', type=float, help='thresholds to try or use') parser.add_argument( '--compute-metrics', action='store_true', help='if set, uses the labels to compute metrics for each threshold') args = options.parse_args_and_arch(parser) main(args)
def add_generation_args(parser): group = parser.add_argument_group('Generation') add_common_eval_args(group) # fmt: off #### bert sampling options #### group.add_argument('--decoding-strategy', default='left_to_right', choices=STRATEGY_REGISTRY.keys()) group.add_argument('--gold-target-len', action='store_true', help='use gold target length') group.add_argument('--dehyphenate', action='store_true', help='turn hyphens into independent tokens') parser.add_argument('--decoding-iterations', default=None, type=int, metavar='N', help='number of decoding iterations in mask-predict') group.add_argument('--length-beam', default=5, type=int, metavar='N', help='length beam size') #### other generation options #### group.add_argument('--beam', default=5, type=int, metavar='N', help='beam size') group.add_argument('--nbest', default=1, type=int, metavar='N', help='number of hypotheses to output') group.add_argument('--max-len-a', default=0, type=float, metavar='N', help=('generate sequences of maximum length ax + b, ' 'where x is the source length')) group.add_argument('--max-len-b', default=200, type=int, metavar='N', help=('generate sequences of maximum length ax + b, ' 'where x is the source length')) group.add_argument('--min-len', default=1, type=float, metavar='N', help=('minimum generation length')) group.add_argument('--match-source-len', default=False, action='store_true', help=('generations should match the source length')) group.add_argument('--no-early-stop', action='store_true', help=('continue searching even after finalizing k=beam ' 'hypotheses; this is more correct, but increases ' 'generation time by 50%%')) group.add_argument('--unnormalized', action='store_true', help='compare unnormalized hypothesis scores') group.add_argument('--no-beamable-mm', action='store_true', help='don\'t use BeamableMM in attention layers') group.add_argument( '--lenpen', default=1, type=float, help='length penalty: <1.0 favors shorter, >1.0 favors longer sentences' ) group.add_argument( '--unkpen', default=0, type=float, help='unknown word penalty: <0 produces more unks, >0 produces fewer') group.add_argument( '--replace-unk', nargs='?', const=True, default=None, help= 'perform unknown replacement (optionally with alignment dictionary)') group.add_argument('--sacrebleu', action='store_true', help='score with sacrebleu') group.add_argument('--score-reference', action='store_true', help='just score the reference translation') group.add_argument( '--prefix-size', default=0, type=int, metavar='PS', help='initialize generation by target prefix of given length') group.add_argument( '--no-repeat-ngram-size', default=0, type=int, metavar='N', help= 'ngram blocking such that this size ngram cannot be repeated in the generation' ) group.add_argument('--sampling', action='store_true', help='sample hypotheses instead of using beam search') group.add_argument( '--sampling-topk', default=-1, type=int, metavar='PS', help='sample from top K likely next words instead of all words') group.add_argument( '--sampling-topp', default=-1.0, type=float, metavar='PS', help= 'sample from the smallest set whose cumulative probability mass exceeds p for next words' ) group.add_argument('--temperature', default=1., type=float, metavar='N', help='temperature for generation') group.add_argument('--diverse-beam-groups', default=-1, type=int, metavar='N', help='number of groups for Diverse Beam Search') group.add_argument( '--diverse-beam-strength', default=0.5, type=float, metavar='N', help='strength of diversity penalty for Diverse Beam Search') group.add_argument( '--print-alignment', action='store_true', help= 'if set, uses attention feedback to compute and print alignment to source tokens' ) # fmt: on return group