kenenet 1.1.7__py3-none-any.whl → 1.1.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kenenet/__init__.py +25 -17
 - {kenenet-1.1.7.dist-info → kenenet-1.1.9.dist-info}/METADATA +1 -1
 - kenenet-1.1.9.dist-info/RECORD +5 -0
 - kenenet-1.1.7.dist-info/RECORD +0 -5
 - {kenenet-1.1.7.dist-info → kenenet-1.1.9.dist-info}/WHEEL +0 -0
 - {kenenet-1.1.7.dist-info → kenenet-1.1.9.dist-info}/top_level.txt +0 -0
 
    
        kenenet/__init__.py
    CHANGED
    
    | 
         @@ -183,6 +183,7 @@ def pp(msg='caca', subdir=None, pps=3): 
     | 
|
| 
       183 
183 
     | 
    
         | 
| 
       184 
184 
     | 
    
         
             
            def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
         
     | 
| 
       185 
185 
     | 
    
         
             
                global ospid
         
     | 
| 
      
 186 
     | 
    
         
            +
                # Ensure directory exists or clean if needed
         
     | 
| 
       186 
187 
     | 
    
         
             
                if os.path.exists(file):
         
     | 
| 
       187 
188 
     | 
    
         
             
                    if reset and ospid is None:
         
     | 
| 
       188 
189 
     | 
    
         
             
                        zhmiscellany.fileio.empty_directory(file)
         
     | 
| 
         @@ -190,30 +191,37 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False): 
     | 
|
| 
       190 
191 
     | 
    
         
             
                else:
         
     | 
| 
       191 
192 
     | 
    
         
             
                    quick_print(f'New folder created {file}')
         
     | 
| 
       192 
193 
     | 
    
         
             
                    zhmiscellany.fileio.create_folder(file)
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
       193 
195 
     | 
    
         
             
                ospid = True
         
     | 
| 
       194 
196 
     | 
    
         
             
                frame = inspect.currentframe().f_back
         
     | 
| 
       195 
197 
     | 
    
         
             
                lineno = frame.f_lineno
         
     | 
| 
       196 
198 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
                if  
     | 
| 
       198 
     | 
    
         
            -
                     
     | 
| 
       199 
     | 
    
         
            -
                     
     | 
| 
      
 199 
     | 
    
         
            +
                if isinstance(img, np.ndarray):
         
     | 
| 
      
 200 
     | 
    
         
            +
                    # Detect mask arrays: floating-point, single-channel
         
     | 
| 
      
 201 
     | 
    
         
            +
                    is_mask = img.dtype.kind == 'f' and (img.ndim == 2 or (img.ndim == 3 and img.shape[-1] == 1))
         
     | 
| 
       200 
202 
     | 
    
         | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
                     
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
                     
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
      
 203 
     | 
    
         
            +
                    # Construct timestamped, sanitized filename
         
     | 
| 
      
 204 
     | 
    
         
            +
                    timestamp = time.time()
         
     | 
| 
      
 205 
     | 
    
         
            +
                    # Sanitize the provided name to remove invalid filesystem chars
         
     | 
| 
      
 206 
     | 
    
         
            +
                    safe_name = re.sub(r'[^A-Za-z0-9._-]', '_', name)
         
     | 
| 
      
 207 
     | 
    
         
            +
                    save_name = f"{safe_name}{timestamp}"
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                    # Prepare image to save
         
     | 
| 
      
 210 
     | 
    
         
            +
                    if is_mask:
         
     | 
| 
      
 211 
     | 
    
         
            +
                        # Scale mask [0.0,1.0] to [0,255] grayscale
         
     | 
| 
      
 212 
     | 
    
         
            +
                        mask_uint8 = (img.squeeze() * 255).clip(0, 255).astype(np.uint8)
         
     | 
| 
      
 213 
     | 
    
         
            +
                        img_to_save = Image.fromarray(mask_uint8)
         
     | 
| 
       209 
214 
     | 
    
         
             
                    else:
         
     | 
| 
       210 
     | 
    
         
            -
                         
     | 
| 
       211 
     | 
    
         
            -
                    im = Image.fromarray(g, mode='L')
         
     | 
| 
      
 215 
     | 
    
         
            +
                        img_to_save = Image.fromarray(img)
         
     | 
| 
       212 
216 
     | 
    
         | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
      
 217 
     | 
    
         
            +
                    # Save file
         
     | 
| 
      
 218 
     | 
    
         
            +
                    save_path = os.path.join(file, f"{save_name}.png")
         
     | 
| 
      
 219 
     | 
    
         
            +
                    img_to_save.save(save_path)
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                    if not mute:
         
     | 
| 
      
 222 
     | 
    
         
            +
                        quick_print(f'Saved image as {save_name}', lineno)
         
     | 
| 
      
 223 
     | 
    
         
            +
                else:
         
     | 
| 
      
 224 
     | 
    
         
            +
                    quick_print(f"Your img is not a fucking numpy array you twat, couldn't save {name}", lineno)
         
     | 
| 
       217 
225 
     | 
    
         | 
| 
       218 
226 
     | 
    
         
             
            class _load_audio:
         
     | 
| 
       219 
227 
     | 
    
         
             
                def __init__(self):
         
     | 
| 
         @@ -0,0 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            kenenet/__init__.py,sha256=1uA-m7NkdOIPdcZOpr4Zb7caDcrwbnXhqY0eR6AsM2U,21946
         
     | 
| 
      
 2 
     | 
    
         
            +
            kenenet-1.1.9.dist-info/METADATA,sha256=OIAT4qSfUC1S_I_VZQsz2qU00812VTSFLaw1TuUJ2yA,1693
         
     | 
| 
      
 3 
     | 
    
         
            +
            kenenet-1.1.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
         
     | 
| 
      
 4 
     | 
    
         
            +
            kenenet-1.1.9.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
         
     | 
| 
      
 5 
     | 
    
         
            +
            kenenet-1.1.9.dist-info/RECORD,,
         
     | 
    
        kenenet-1.1.7.dist-info/RECORD
    DELETED
    
    | 
         @@ -1,5 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            kenenet/__init__.py,sha256=6fDdc-6WpO8jipy2CyfYUYc6E3Q-RlD7M4iVtRZ9-6Y,21482
         
     | 
| 
       2 
     | 
    
         
            -
            kenenet-1.1.7.dist-info/METADATA,sha256=gT81Xu95QgcjcRP1jzRcKn1bMpu2NdQkYb3SF21wDX4,1693
         
     | 
| 
       3 
     | 
    
         
            -
            kenenet-1.1.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
         
     | 
| 
       4 
     | 
    
         
            -
            kenenet-1.1.7.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
         
     | 
| 
       5 
     | 
    
         
            -
            kenenet-1.1.7.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |