kenenet 1.2.0__py3-none-any.whl → 1.2.1__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 +12 -26
- {kenenet-1.2.0.dist-info → kenenet-1.2.1.dist-info}/METADATA +1 -1
- kenenet-1.2.1.dist-info/RECORD +5 -0
- kenenet-1.2.0.dist-info/RECORD +0 -5
- {kenenet-1.2.0.dist-info → kenenet-1.2.1.dist-info}/WHEEL +0 -0
- {kenenet-1.2.0.dist-info → kenenet-1.2.1.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -183,7 +183,6 @@ 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 target directory exists or is cleaned once
|
187
186
|
if os.path.exists(file):
|
188
187
|
if reset and ospid is None:
|
189
188
|
zhmiscellany.fileio.empty_directory(file)
|
@@ -192,35 +191,22 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
|
|
192
191
|
quick_print(f'New folder created {file}')
|
193
192
|
zhmiscellany.fileio.create_folder(file)
|
194
193
|
ospid = True
|
195
|
-
|
196
|
-
# Determine caller line number for logging
|
197
194
|
frame = inspect.currentframe().f_back
|
198
195
|
lineno = frame.f_lineno
|
199
|
-
|
200
196
|
if isinstance(img, np.ndarray):
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
# Prepare image for saving
|
211
|
-
if is_mask:
|
212
|
-
# Scale mask values [0.0,1.0] to [0,255] grayscale
|
213
|
-
mask_uint8 = (img.squeeze() * 255).clip(0, 255).astype(np.uint8)
|
214
|
-
img_to_save = Image.fromarray(mask_uint8)
|
197
|
+
if ((img.ndim == 2 or (img.ndim == 3 and img.shape[-1] == 1)) and img.dtype.kind == "f" and img.min() >= 0.0 and img.max() <= 1.0):
|
198
|
+
img = Image.fromarray((img * 255).astype(np.uint8))
|
199
|
+
img.save(path)
|
200
|
+
elif ((img.ndim == 2 or (img.ndim == 3 and img.shape[-1] == 1)) and (img.min() < 0.0 or img.max() > 1.0)):
|
201
|
+
mask_normalized = np.clip(img / img.max(), 0.0, 1.0)
|
202
|
+
# Convert to uint8 and save as an image
|
203
|
+
img = Image.fromarray((mask_normalized * 255).astype(np.uint8))
|
204
|
+
img.save("normalized_mask_view.png")
|
215
205
|
else:
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
img_to_save.save(filepath)
|
221
|
-
|
222
|
-
if not mute:
|
223
|
-
quick_print(f'Saved image as {save_name}', lineno)
|
206
|
+
save_name = name + f'{time.time()}'
|
207
|
+
img = Image.fromarray(img)
|
208
|
+
img.save(fr'{file}\{save_name}.png')
|
209
|
+
if not mute: quick_print(f'Saved image as {save_name}', lineno)
|
224
210
|
else:
|
225
211
|
quick_print(f"Your img is not a fucking numpy array you twat, couldn't save {name}", lineno)
|
226
212
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=hZ_x82R-w-URXbdtOJH6MJgFX1yqhiw4KVjEwCmUbdA,21766
|
2
|
+
kenenet-1.2.1.dist-info/METADATA,sha256=agCvlIg2Ru7Rl1jXaIcCKViglla8aEt9HtmeWzztrVs,1693
|
3
|
+
kenenet-1.2.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-1.2.1.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-1.2.1.dist-info/RECORD,,
|
kenenet-1.2.0.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=oy4f42bfvN-UX-T7r9zViybxIHsGXhGvcTIPqdnTFMo,22026
|
2
|
-
kenenet-1.2.0.dist-info/METADATA,sha256=CqZ5DO_3bxTDMSbtLuBv_11h_Bk_c_X3SZGp6kO0wk8,1693
|
3
|
-
kenenet-1.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-1.2.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|