• YosuaMichael's avatar
    Refactor swin transfomer so later we can reuse component for 3d version (#6088) · 952f4806
    YosuaMichael authored
    * Use List[int] instead of int for window_size and shift_size
    
    * Make PatchMerging and SwinTransformerBlock able to handle 2d and 3d cases
    
    * Separate patch embedding from SwinTransformer and enable to get model without head by specifying num_heads=None
    
    * Dont use if before padding so it is fx friendly
    
    * Put the handling on window_size edge cases on separate function and wrap with torch.fx.wrap so it is excluded from tracing
    
    * Update the weight url to the converted weight with new structure
    
    * Update the accuracy of swin_transformer
    
    * Change assert to Exception and nit
    
    * Make num_classes optional
    
    * Add typing output for _fix_window_and_shift_size function
    
    * init head to None to make it jit scriptable
    
    * Revert the change to make num_classes optional
    
    * Revert unneccesarry changes that might be risky
    
    * Remove self.head declaration
    952f4806
swin_transformer.py 22.6 KB