예제 #1
0
 def __init__(
     self,
     annotation_file: str,
     image_dir: str,
     batch_size: int,
     shuffle: bool = True,
     random_seed: Optional[int] = None,
     group_by_aspect_ratio: bool = True,
     stride_partition: bool = True,
     name: str = None,
 ):
     assert name is not None
     if random_seed is None:
         random_seed = random.randrange(sys.maxsize)
     module_util.Module.__init__(self, name)
     self.op_module_builder = (
         flow.consistent_user_op_module_builder("COCOReader")
         .Op("COCOReader")
         .Output("image")
         .Output("image_id")
         .Output("image_size")
         .Output("gt_bbox")
         .Output("gt_label")
         .Output("gt_segm")
         .Output("gt_segm_index")
         .Attr("annotation_file", annotation_file)
         .Attr("image_dir", image_dir)
         .Attr("batch_size", batch_size)
         .Attr("shuffle_after_epoch", shuffle)
         .Attr("random_seed", random_seed)
         .Attr("group_by_ratio", group_by_aspect_ratio)
         .Attr("stride_partition", stride_partition)
         .CheckAndComplete()
     )
     self.op_module_builder.user_op_module.InitOpKernel()
예제 #2
0
 def __init__(self):
     flow.nn.Module.__init__(self)
     self.module_builder_ = flow.consistent_user_op_module_builder("add_n")
     self.module_builder_.InputSize("in", 2).Output("out")
     self.module_builder_.user_op_module.InitOpKernel()