Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	Commit 
							
							·
						
						7afa5a1
	
1
								Parent(s):
							
							840b51f
								
Update weights.
Browse files
    	
        BiRefNet-massive-epoch_260.pth → BiRefNet-portrait-TR_P3M_10k-epoch_120.pth
    RENAMED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            -
            oid sha256: | 
| 3 | 
             
            size 885038517
         | 
|  | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:9a31ed736e17bc36a7ab539b71419b27f69b839e8ba132c6a67fe77edceb4141
         | 
| 3 | 
             
            size 885038517
         | 
    	
        app.py
    CHANGED
    
    | @@ -41,7 +41,7 @@ class ImagePreprocessor(): | |
| 41 |  | 
| 42 |  | 
| 43 | 
             
            model = BiRefNet(bb_pretrained=False)
         | 
| 44 | 
            -
            state_dict = ['./BiRefNet-DIS-epoch_590.pth', 'BiRefNet-massive-epoch_240.pth', 'BiRefNet- | 
| 45 | 
             
            if os.path.exists(state_dict):
         | 
| 46 | 
             
                birefnet_dict = torch.load(state_dict, map_location="cpu")
         | 
| 47 | 
             
                unwanted_prefix = '_orig_mod.'
         | 
| @@ -81,7 +81,7 @@ def predict(image, resolution): | |
| 81 | 
             
                for image, pred in zip(images, preds):
         | 
| 82 | 
             
                    image = image.resize(pred.shape[::-1])
         | 
| 83 | 
             
                    pred = np.repeat(np.expand_dims(pred, axis=-1), 3, axis=-1)
         | 
| 84 | 
            -
                    image_preds.append((pred * image).astype(np.uint8))
         | 
| 85 |  | 
| 86 | 
             
                return image, image_preds[0]
         | 
| 87 |  | 
|  | |
| 41 |  | 
| 42 |  | 
| 43 | 
             
            model = BiRefNet(bb_pretrained=False)
         | 
| 44 | 
            +
            state_dict = ['./BiRefNet-DIS-epoch_590.pth', 'BiRefNet-massive-epoch_240.pth', 'BiRefNet-portrait-TR_P3M_10k-epoch_120.pth'][1]
         | 
| 45 | 
             
            if os.path.exists(state_dict):
         | 
| 46 | 
             
                birefnet_dict = torch.load(state_dict, map_location="cpu")
         | 
| 47 | 
             
                unwanted_prefix = '_orig_mod.'
         | 
|  | |
| 81 | 
             
                for image, pred in zip(images, preds):
         | 
| 82 | 
             
                    image = image.resize(pred.shape[::-1])
         | 
| 83 | 
             
                    pred = np.repeat(np.expand_dims(pred, axis=-1), 3, axis=-1)
         | 
| 84 | 
            +
                    image_preds.append(((pred>0.5) * image).astype(np.uint8))
         | 
| 85 |  | 
| 86 | 
             
                return image, image_preds[0]
         | 
| 87 |  | 
