Myosotis-Researches 0.1.41__py3-none-any.whl → 0.1.42__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.
- myosotis_researches/CcGAN/utils/similarity.py +29 -0
- {myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/METADATA +1 -1
- {myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/RECORD +6 -6
- {myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/WHEEL +1 -1
- {myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/licenses/LICENSE +0 -0
- {myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,7 @@ import cv2
|
|
2
2
|
import math
|
3
3
|
import numpy as np
|
4
4
|
from PIL import Image
|
5
|
+
from scipy.special import rel_entr
|
5
6
|
from skimage.metrics import structural_similarity as ssim
|
6
7
|
|
7
8
|
|
@@ -120,6 +121,33 @@ def histogram_intersection(images):
|
|
120
121
|
return histogram_intersection_sum / (n * (n - 1) / 2)
|
121
122
|
|
122
123
|
|
124
|
+
# KL divergence
|
125
|
+
def _kl_divergence(image_1, image_2, bins=256):
|
126
|
+
kl_values = []
|
127
|
+
|
128
|
+
for c in range(3):
|
129
|
+
arr1 = np.array(image_1)[:, :, c].flatten()
|
130
|
+
arr2 = np.array(image_2)[:, :, c].flatten()
|
131
|
+
hist1, _ = np.histogram(arr1, bins=bins, range=(0, 256), density=True)
|
132
|
+
hist2, _ = np.histogram(arr2, bins=bins, range=(0, 256), density=True)
|
133
|
+
hist1 += 1e-10
|
134
|
+
hist2 += 1e-10
|
135
|
+
kl_1_2 = np.sum(rel_entr(hist1, hist2))
|
136
|
+
kl_2_1 = np.sum(rel_entr(hist2, hist1))
|
137
|
+
sym_kl = 0.5 * (kl_1_2 + kl_2_1)
|
138
|
+
kl_values.append(sym_kl)
|
139
|
+
return float(np.mean(kl_values))
|
140
|
+
|
141
|
+
|
142
|
+
def kl_divergence(images):
|
143
|
+
kl_divergence_sum = 0
|
144
|
+
n = len(images)
|
145
|
+
for i in range(n):
|
146
|
+
for j in range(i + 1, n):
|
147
|
+
kl_divergence_sum += _kl_divergence(images[i], images[j])
|
148
|
+
return kl_divergence_sum / (n * (n - 1) / 2)
|
149
|
+
|
150
|
+
|
123
151
|
# Similarity
|
124
152
|
_method_dict = {
|
125
153
|
"MSE": MSE,
|
@@ -127,6 +155,7 @@ _method_dict = {
|
|
127
155
|
"PSNR": PSNR,
|
128
156
|
"cross-correlation": cross_correlation,
|
129
157
|
"histogram-intersection": histogram_intersection,
|
158
|
+
"kl-divergence": kl_divergence,
|
130
159
|
}
|
131
160
|
|
132
161
|
|
@@ -29,13 +29,13 @@ myosotis_researches/CcGAN/train/train_net_for_label_embed.py,sha256=4j6r4_o4rXgA
|
|
29
29
|
myosotis_researches/CcGAN/utils/__init__.py,sha256=yH4I2QzSoBsjcdjvOH0YKLTeEji_oWrzBGm5EkVZpoI,146
|
30
30
|
myosotis_researches/CcGAN/utils/concat_image.py,sha256=BIGKz52Inn9S7M5fBFKye2V9bLJ0DqEQILoOVWAXUiE,2165
|
31
31
|
myosotis_researches/CcGAN/utils/dataset.py,sha256=TXJSLMpwI1h0xb6lXpq5iUjjurheKPZnPbR2KIU-Py4,4216
|
32
|
-
myosotis_researches/CcGAN/utils/similarity.py,sha256=
|
32
|
+
myosotis_researches/CcGAN/utils/similarity.py,sha256=9YMcHgebmPXn7R4fhFw9tBG1CcYxv102F9G_nCI5j4k,4582
|
33
33
|
myosotis_researches/CcGAN/utils/src/style.css,sha256=bNp3_nlpg0W5qA7Rx8MM5ayeprEbYH3_6AIDRTN8UhM,566
|
34
34
|
myosotis_researches/CcGAN/utils/src/style.css.map,sha256=GTGPet_xXnKQnsz-E2CMUWtrgu3D5t0g4J_A_amFdvw,246
|
35
35
|
myosotis_researches/CcGAN/utils/src/style.scss,sha256=_Wa7VPmFzCkEHtrzdG35tj89QNwPd-fpiT-YL4ohcMs,526
|
36
36
|
myosotis_researches/CcGAN/utils/src/template.html,sha256=S35ak_uJ0Zd3_PhX-YoCRBP2TMKxdFPMMaBdpARdKcU,3890
|
37
|
-
myosotis_researches-0.1.
|
38
|
-
myosotis_researches-0.1.
|
39
|
-
myosotis_researches-0.1.
|
40
|
-
myosotis_researches-0.1.
|
41
|
-
myosotis_researches-0.1.
|
37
|
+
myosotis_researches-0.1.42.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
38
|
+
myosotis_researches-0.1.42.dist-info/METADATA,sha256=ZOvU_PxDnsWcScz8Xtbb7rISgRJhHDNFvB28JZtQ9Hg,3484
|
39
|
+
myosotis_researches-0.1.42.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
|
40
|
+
myosotis_researches-0.1.42.dist-info/top_level.txt,sha256=zxAiMn5eyZNJM28MewTAkgi_RZJMbfWbzVR-KF0LdZE,20
|
41
|
+
myosotis_researches-0.1.42.dist-info/RECORD,,
|
{myosotis_researches-0.1.41.dist-info → myosotis_researches-0.1.42.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|