def __init__(self, name, age, father, mother): Human.__init__(self, name, age) if isinstance(father, Father): self.father = father else: raise ValueError('Father must be of a type Father') if isinstance(mother, Mother): self.mother = mother else: raise ValueError('Mother must be of a type Mother')
def __init__(self, model, boxsize): """ Class constructor. @param model: caffe models @param weights: caffe models weights """ Human.__init__(self, boxsize) # Reshapes the models input accordingly self.model, self.weights = model self.net = None
def __init__(self, *args, **kwargs): # Cách điển hình để thừa kế thuộc tính là gọi super # super(Batman, self).__init__(*args, **kwargs) # Tuy nhiên với đa thừa kế, super() sẽ chỉ gọi lớp cơ sở tiếp theo trong danh sách MRO. # Vì thế, ta sẽ gọi cụ thể hàm __init__ của các lớp chả. # Sử dụng *args và **kwargs cho phép việc truyền đối số gọn gàng hơn, # trong đó mỗi lớp cha sẽ chịu trách nhiệm cho những phần thuộc về nó Human.__init__(self, 'anonymous', *args, **kwargs) Bat.__init__(self, *args, can_fly=False, **kwargs) # ghi đè giá trị của thuộc tính name self.name = 'Sad Affleck'
def __init__(self, *args, **kwargs): # Typically to inherit attributes you have to call super: #super(Batman, self).__init__(*args, **kwargs) # However we are dealing with multiple inheritance here, and super() # only works with the next base class in the MRO list. # So instead we explicitly call __init__ for all ancestors. # The use of *args and **kwargs allows for a clean way to pass arguments, # with each parent "peeling a layer of the onion". Human.__init__(self, 'anonymous', *args, **kwargs) Bat.__init__(self, *args, can_fly=False, **kwargs) # override the value for the name attribute self.name = 'Sad Affleck'
def __init__(self, model, boxsize): """ Class constructor. @param model: tf models @param weights: tf models weights """ Human.__init__(self, boxsize) self.config = tf.ConfigProto(device_count={"GPU": 1}, allow_soft_placement=True, log_device_placement=False) self.config.gpu_options.per_process_gpu_memory_fraction = 0.5 self.sess = None self.weights = model self.first_detection = True self.image_in = None self.map_human_large = None
def __init__(self, age=0, name="", topic=""): Human.__init__(self, age, name) ## This is the topic the student is currently working on self.topic = topic
def __init__(self, model, boxsize=192, confidence_threshold=0.75): """ Class constructor. @param model: tf models @param weights: tf models weights """ Human.__init__(self, boxsize) # boxsize will not be used in this case! self.config = tf.ConfigProto(device_count={"GPU": 1}, allow_soft_placement=True, log_device_placement=False) self.config.gpu_options.per_process_gpu_memory_fraction = 0.5 labels_file = LABELS_DICT[DB] lbl_map = label_map_util.load_labelmap( labels_file) # loads the labels map. categories = label_map_util.convert_label_map_to_categories( lbl_map, 9999) category_index = label_map_util.create_category_index(categories) self.classes = {} # We build is as a dict because of gaps on the labels definitions for cat in category_index: self.classes[cat] = str(category_index[cat]['name']) # Frozen inference graph, written on the file CKPT = model detection_graph = tf.Graph() # new graph instance. with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') self.sess = tf.Session(graph=detection_graph, config=self.config) self.image_tensor = detection_graph.get_tensor_by_name( 'image_tensor:0') # NCHW conversion. not possible #self.image_tensor = tf.transpose(self.image_tensor, [0, 3, 1, 2]) self.detection_boxes = detection_graph.get_tensor_by_name( 'detection_boxes:0') self.detection_scores = detection_graph.get_tensor_by_name( 'detection_scores:0') self.detection_classes = detection_graph.get_tensor_by_name( 'detection_classes:0') self.num_detections = detection_graph.get_tensor_by_name( 'num_detections:0') self.boxes = [] self.scores = [] self.predictions = [] # Dummy initialization (otherwise it takes longer then) dummy_tensor = np.zeros((1, 1, 1, 3), dtype=np.int32) self.sess.run([ self.detection_boxes, self.detection_scores, self.detection_classes, self.num_detections ], feed_dict={self.image_tensor: dummy_tensor}) self.confidence_threshold = confidence_threshold
def __init__(self, fname, lname, school): Human.__init__(self, fname, lname) self.school = school self.debt = 0
def __init__(self, age=0, name=None): Human.__init__(self, age, name)
def __init__(self, name, age, skill): self.skill = skill Human.__init__(self, name, age)
def __init__(self, name, age, children): Human.__init__(self, name, age) self.children = children
def __init__(self, *args, **kwargs): # super(Batman, self).__init__(*args, **kwargs) # doesn't work for multiple inheritance Human.__init__(self, 'anonymous', *args, **kwargs) Bat.__init__(self, *args, can_fly=False, **kwargs) self.name = 'Sad Affleck'