Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	vae slicing and tiling for flux
Browse files
    	
        main.py
    CHANGED
    
    | 
         @@ -270,7 +270,11 @@ def execute_task(args, trainer, device, dtype, shape, enable_grad, settings, pip 
     | 
|
| 270 | 
         | 
| 271 | 
         
             
                        if args.cpu_offloading:
         
     | 
| 272 | 
         
             
                            pipe.enable_sequential_cpu_offload()
         
     | 
| 273 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 274 | 
         | 
| 275 | 
         
             
                    if args.enable_multi_apply:
         
     | 
| 276 | 
         | 
| 
         @@ -299,11 +303,6 @@ def execute_task(args, trainer, device, dtype, shape, enable_grad, settings, pip 
     | 
|
| 299 | 
         
             
                    )
         
     | 
| 300 | 
         
             
                    best_image.save(f"{save_dir}/best_image.png")
         
     | 
| 301 | 
         
             
                    #init_image.save(f"{save_dir}/init_image.png")
         
     | 
| 302 | 
         
            -
             
     | 
| 303 | 
         
            -
                    # Move the pipe back to CPU
         
     | 
| 304 | 
         
            -
                    if args.model != "flux":
         
     | 
| 305 | 
         
            -
                        # Call the function to find and move object to CPU
         
     | 
| 306 | 
         
            -
                        find_and_move_object_to_cpu()
         
     | 
| 307 | 
         | 
| 308 | 
         
             
                    clear_gpu()
         
     | 
| 309 | 
         | 
| 
         | 
|
| 270 | 
         | 
| 271 | 
         
             
                        if args.cpu_offloading:
         
     | 
| 272 | 
         
             
                            pipe.enable_sequential_cpu_offload()
         
     | 
| 273 | 
         
            +
                            pipe.vae.enable_slicing()
         
     | 
| 274 | 
         
            +
                            pipe.vae.enable_tiling()
         
     | 
| 275 | 
         
            +
                            
         
     | 
| 276 | 
         
            +
                            pipe.to(torch.float16) # casting here instead of in the pipeline constructor because doing so in the constructor loads all models into CPU memory at once
         
     | 
| 277 | 
         
            +
                        
         
     | 
| 278 | 
         | 
| 279 | 
         
             
                    if args.enable_multi_apply:
         
     | 
| 280 | 
         | 
| 
         | 
|
| 303 | 
         
             
                    )
         
     | 
| 304 | 
         
             
                    best_image.save(f"{save_dir}/best_image.png")
         
     | 
| 305 | 
         
             
                    #init_image.save(f"{save_dir}/init_image.png")
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 306 | 
         | 
| 307 | 
         
             
                    clear_gpu()
         
     | 
| 308 | 
         |