Initializing the application class (class initialization function change and add value)

 

 

a Dataset class (Object): 
DEF the __init __ (Self):
self.image_info = [] # initializes a list
def add_image (self, source, image_id , path, ** kwargs): # a * parameter is a list of two * parameter is a dictionary
image_info = {
"ID": the image_id,
"Source": Source,
"path": path,
}
image_info.update (kwargs) # Update shows a kwargs image_info added to the dictionary, if present key occurs, value is replaced with kwargs
self.image_info.append (image_info) # value image_info to their class self.image_info

a = a Dataset ()
a.add_image ( "Shapes", the image_id = ID, path = 'img_path', width = 26 is, height = 31 is, MASK_PATH = 'MASK_PATH', yaml_path = 'yaml_path')

Print (a.image_info)

 

The results are as follows:

 

 

 

 

Guess you like

Origin www.cnblogs.com/tangjunjun/p/11892656.html