kenenet 1.1.7__py3-none-any.whl → 1.1.8__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 CHANGED
@@ -186,34 +186,32 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
186
186
  if os.path.exists(file):
187
187
  if reset and ospid is None:
188
188
  zhmiscellany.fileio.empty_directory(file)
189
- quick_print(f'Cleaned folder {file}')
189
+ if not mute: quick_print(f'Cleaned folder {file}')
190
190
  else:
191
191
  quick_print(f'New folder created {file}')
192
- zhmiscellany.fileio.create_folder(file)
192
+ if not mute: zhmiscellany.fileio.create_folder(file)
193
193
  ospid = True
194
194
  frame = inspect.currentframe().f_back
195
195
  lineno = frame.f_lineno
196
-
197
- if not isinstance(img, np.ndarray):
196
+ if isinstance(img, np.ndarray):
197
+ # detect mask arrays: floating-point, single-channel
198
+ is_mask = img.dtype.kind == 'f' and (img.ndim == 2 or (img.ndim == 3 and img.shape[-1] == 1))
199
+ save_name = name + f'{time.time()}'
200
+ if is_mask:
201
+ # scale mask values [0.0,1.0] to [0,255] grayscale
202
+ mask_uint8 = (img.squeeze() * 255).clip(0,255).astype(np.uint8)
203
+ img_to_save = Image.fromarray(mask_uint8)
204
+ else:
205
+ img_to_save = Image.fromarray(img)
206
+ img_to_save.save(fr'{file}\{save_name}.png')
207
+ if not mute:
208
+ quick_print(f'Saved image as {save_name}', lineno)
209
+ else:
198
210
  quick_print(f"Your img is not a fucking numpy array you twat, couldn't save {name}", lineno)
199
- return
200
211
 
201
- save_name = name + f'{time.time()}'
202
- arr = img
203
- if arr.ndim == 3 and arr.shape[2] == 3:
204
- im = Image.fromarray(arr)
205
- else:
206
- g = arr.squeeze()
207
- if np.issubdtype(g.dtype, np.floating):
208
- g = (np.clip(g, 0, 1) * 255).astype(np.uint8)
209
- else:
210
- g = g.astype(np.uint8)
211
- im = Image.fromarray(g, mode='L')
212
212
 
213
- path = os.path.join(file, f'{save_name}.png')
214
- im.save(path)
215
- if not mute:
216
- quick_print(f'Saved image as {save_name}', lineno)
213
+
214
+
217
215
 
218
216
  class _load_audio:
219
217
  def __init__(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 1.1.7
3
+ Version: 1.1.8
4
4
  Summary: dude what the fuck even is this package
5
5
  Home-page: https://www.youtube.com/@KiddyKene
6
6
  Author: kiddykene
@@ -0,0 +1,5 @@
1
+ kenenet/__init__.py,sha256=wuv2RfvLgHl7TacGdyUVDpfzIhKdNKKfGBU1dUXrKqI,21607
2
+ kenenet-1.1.8.dist-info/METADATA,sha256=1bYhd3iloCZLoOxHEq2f3RbT--rJPcN-fTcWMUrpNKk,1693
3
+ kenenet-1.1.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.1.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.1.8.dist-info/RECORD,,
@@ -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,,