wandb 0.20.0__py3-none-any.whl → 0.20.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.
- wandb/__init__.py +1 -1
- wandb/__init__.pyi +1 -1
- wandb/sdk/data_types/image.py +31 -17
- {wandb-0.20.0.dist-info → wandb-0.20.1.dist-info}/METADATA +1 -1
- {wandb-0.20.0.dist-info → wandb-0.20.1.dist-info}/RECORD +8 -8
- {wandb-0.20.0.dist-info → wandb-0.20.1.dist-info}/WHEEL +0 -0
- {wandb-0.20.0.dist-info → wandb-0.20.1.dist-info}/entry_points.txt +0 -0
- {wandb-0.20.0.dist-info → wandb-0.20.1.dist-info}/licenses/LICENSE +0 -0
wandb/__init__.py
CHANGED
wandb/__init__.pyi
CHANGED
wandb/sdk/data_types/image.py
CHANGED
@@ -58,25 +58,39 @@ def _warn_on_invalid_data_range(
|
|
58
58
|
)
|
59
59
|
|
60
60
|
|
61
|
-
def
|
62
|
-
"""
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
def _guess_and_rescale_to_0_255(data: "np.ndarray") -> "np.ndarray":
|
62
|
+
"""Guess the image's format and rescale its values to the range [0, 255].
|
63
|
+
|
64
|
+
This is an unfortunate design flaw carried forward for backward
|
65
|
+
compatibility. A better design would have been to document the expected
|
66
|
+
data format and not mangle the data provided by the user.
|
67
|
+
|
68
|
+
If given data in the range [0, 1], we multiply all values by 255
|
69
|
+
and round down to get integers.
|
70
|
+
|
71
|
+
If given data in the range [-1, 1], we rescale it by mapping -1 to 0 and
|
72
|
+
1 to 255, then round down to get integers.
|
73
|
+
|
74
|
+
We clip and round all other data.
|
75
|
+
"""
|
76
|
+
try:
|
77
|
+
import numpy as np
|
78
|
+
except ImportError:
|
79
|
+
raise wandb.Error(
|
80
|
+
"wandb.Image requires numpy if not supplying PIL images: pip install numpy"
|
81
|
+
) from None
|
67
82
|
|
68
|
-
|
69
|
-
|
70
|
-
if np.min(data) < 0:
|
71
|
-
data = data - np.min(data)
|
83
|
+
data_min: float = data.min()
|
84
|
+
data_max: float = data.max()
|
72
85
|
|
73
|
-
if
|
74
|
-
|
86
|
+
if 0 <= data_min and data_max <= 1:
|
87
|
+
return (data * 255).astype(np.uint8)
|
75
88
|
|
76
|
-
|
77
|
-
|
89
|
+
elif -1 <= data_min and data_max <= 1:
|
90
|
+
return (255 * 0.5 * (data + 1)).astype(np.uint8)
|
78
91
|
|
79
|
-
|
92
|
+
else:
|
93
|
+
return data.clip(0, 255).astype(np.uint8)
|
80
94
|
|
81
95
|
|
82
96
|
def _convert_to_uint8(data: "np.ndarray") -> "np.ndarray":
|
@@ -393,7 +407,7 @@ class Image(BatchableMedia):
|
|
393
407
|
|
394
408
|
_warn_on_invalid_data_range(data, normalize)
|
395
409
|
|
396
|
-
data =
|
410
|
+
data = _guess_and_rescale_to_0_255(data) if normalize else data # type: ignore [arg-type]
|
397
411
|
data = _convert_to_uint8(data)
|
398
412
|
|
399
413
|
if data.ndim > 2:
|
@@ -413,7 +427,7 @@ class Image(BatchableMedia):
|
|
413
427
|
_warn_on_invalid_data_range(data, normalize) # type: ignore [arg-type]
|
414
428
|
|
415
429
|
mode = mode or self.guess_mode(data, file_type)
|
416
|
-
data =
|
430
|
+
data = _guess_and_rescale_to_0_255(data) if normalize else data # type: ignore [arg-type]
|
417
431
|
data = _convert_to_uint8(data) # type: ignore [arg-type]
|
418
432
|
self._image = pil_image.fromarray(
|
419
433
|
data,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
package_readme.md,sha256=U9047nyMDICgctm1HLm4HfXwFnFKsEn2m77hsYPUZ1I,4298
|
2
|
-
wandb/__init__.py,sha256=
|
3
|
-
wandb/__init__.pyi,sha256=
|
2
|
+
wandb/__init__.py,sha256=voeAUjikukV1wUbzWpSRKezgf6AEE6NODckD2qsuHCU,7072
|
3
|
+
wandb/__init__.pyi,sha256=nWUVGrUbymxXWlYwbkoakcN5EbXF-15ZJkXThTGKXTg,48123
|
4
4
|
wandb/__main__.py,sha256=gripuDgB7J8wMMeJt4CIBRjn1BMSFr5zvsrt585Pnj4,64
|
5
5
|
wandb/_iterutils.py,sha256=NX6MaIE3JzPXsqKNXUKdnpIlX0spGG8HwGIQt5VASrk,2400
|
6
6
|
wandb/data_types.py,sha256=M-wqAO0FtIqvj28556u3h4nzSwlRcbxhXoX0B9jlJSo,2283
|
@@ -325,7 +325,7 @@ wandb/sdk/data_types/bokeh.py,sha256=RuMsi7v_yJyMEuYjfrwTL1q1B8svdCW9t_eNge9aEJA
|
|
325
325
|
wandb/sdk/data_types/graph.py,sha256=_P_z2dNj2mCJeSvusIfVHkSkVB9AL0AEO-6KaguC1ys,12089
|
326
326
|
wandb/sdk/data_types/histogram.py,sha256=syx3fUDoP6vYqA3r5m7bHXK6MAWo2MkRhpCKasihwvg,3145
|
327
327
|
wandb/sdk/data_types/html.py,sha256=HTh2nNlJsncLgou1gXz6e-f_loaHInMEJerzlDLqKzc,4381
|
328
|
-
wandb/sdk/data_types/image.py,sha256=
|
328
|
+
wandb/sdk/data_types/image.py,sha256=xdYth860StgcqoUJ0o4NPncj83XB5BRWI7ypY5PbrUY,34811
|
329
329
|
wandb/sdk/data_types/molecule.py,sha256=_eVzkFEO-uydch8dsw6GjaW_hNGrZwUFfU_inMj70gM,8549
|
330
330
|
wandb/sdk/data_types/object_3d.py,sha256=83ordMmzmmFun2fp2z9P3dffNJ0fW_Hv7MfpDZROYcc,16282
|
331
331
|
wandb/sdk/data_types/plotly.py,sha256=LEIHRqtHHpSou04AEUsyH8_UMXP4adrEHHaKoEtQkxo,2913
|
@@ -906,8 +906,8 @@ wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py,sha256=cJIaJ2EQso
|
|
906
906
|
wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py,sha256=UORYTNVcUSE2NpFcq9UVLIS-tsS0TS_Qw8akhKxn2eY,1506
|
907
907
|
wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py,sha256=UWX8DB97ygkEeSxWQUYCHR4MahNilux7vl5TCTQtPPk,2190
|
908
908
|
wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py,sha256=ZOevOTbSo8NRiIxkuBVGaG4yigWnPoO0goxAi-jsBkM,3828
|
909
|
-
wandb-0.20.
|
910
|
-
wandb-0.20.
|
911
|
-
wandb-0.20.
|
912
|
-
wandb-0.20.
|
913
|
-
wandb-0.20.
|
909
|
+
wandb-0.20.1.dist-info/METADATA,sha256=EcYDqPeeoZYy-r-YORdy-49B7a9AswwzGfIU1lA61-k,10307
|
910
|
+
wandb-0.20.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
911
|
+
wandb-0.20.1.dist-info/entry_points.txt,sha256=v4FCOZ9gW7Pc6KLsmgQqpCiKTrA1wh2XHmNf-NUP1-I,67
|
912
|
+
wandb-0.20.1.dist-info/licenses/LICENSE,sha256=izOKRJpGOx1PrJiGOKR0HsNdlB5JdH2d0Z4P7a7ssTc,1081
|
913
|
+
wandb-0.20.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|