Browse Source
        
      
      update readme
      
        Signed-off-by: junjie.jiang <junjie.jiang@zilliz.com>
      
      
        main
      
      
     
    
    
    
	
		
			
				 1 changed files with 
9 additions and 
5 deletions
			 
			
		 
		
			
				- 
					
					
					 
					README.md
				
 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -18,20 +18,24 @@ Read data from sqlite or mysql. | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					### Example | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					```python | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					from towhee import DataLoader, pipe, ops | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					p = ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    pipe.input('image_path') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .map('image_path', 'image', ops.image_decode.cv2()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .map('image', 'vec', ops.image_embedding.timm(model_name='resnet50')) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .output('vec') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .map('image_path', 'image', ops.image_decode.cv2()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            .map('image', 'vec', ops.image_embedding.timm(model_name='resnet50')) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                .output('vec') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					for data in DataLoader(ops.data_source.sql('sqlite:///./sqlite.db')): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					# table cols: id, image_path, label | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					for data in DataLoader(ops.data_source.sql('sqlite:///./sqlite.db', 'image_table'), parser=lambda x: x[1]): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    print(p(data).to_list(kv_format=True)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					# batch | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					for data in DataLoader(ops.data_source.sql('sqlite:///./sqlite.db'), batch_size=10): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					for data in DataLoader(ops.data_source.sql('sqlite:///./sqlite.db', 'image_table'), parser=lambda x: x[1], batch_size=10): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    p.batch(data) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					``` | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |