Myosotis-Researches 0.1.40__tar.gz → 0.1.42__tar.gz

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.
Files changed (47) hide show
  1. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42/Myosotis_Researches.egg-info}/PKG-INFO +1 -1
  2. {myosotis_researches-0.1.40/Myosotis_Researches.egg-info → myosotis_researches-0.1.42}/PKG-INFO +1 -1
  3. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/similarity.py +36 -5
  4. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/setup.py +1 -1
  5. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/LICENSE +0 -0
  6. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/MANIFEST.in +0 -0
  7. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/Myosotis_Researches.egg-info/SOURCES.txt +0 -0
  8. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/Myosotis_Researches.egg-info/dependency_links.txt +0 -0
  9. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/Myosotis_Researches.egg-info/top_level.txt +0 -0
  10. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/README.md +0 -0
  11. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/__init__.py +0 -0
  12. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/CcGAN_SAGAN.py +0 -0
  13. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/ResNet_class_eval.py +0 -0
  14. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/ResNet_embed.py +0 -0
  15. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/ResNet_regre_eval.py +0 -0
  16. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/__init__.py +0 -0
  17. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/autoencoder.py +0 -0
  18. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/cGAN_SAGAN.py +0 -0
  19. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_128/cGAN_concat_SAGAN.py +0 -0
  20. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/CcGAN_SAGAN.py +0 -0
  21. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/ResNet_class_eval.py +0 -0
  22. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/ResNet_embed.py +0 -0
  23. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/ResNet_regre_eval.py +0 -0
  24. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/__init__.py +0 -0
  25. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/autoencoder.py +0 -0
  26. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/cGAN_SAGAN.py +0 -0
  27. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/models_256/cGAN_concat_SAGAN.py +0 -0
  28. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/old/IMGs_dataset.py +0 -0
  29. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/old/SimpleProgressBar.py +0 -0
  30. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/old/__init__.py +0 -0
  31. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/old/opts.py +0 -0
  32. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/old/train.py +0 -0
  33. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/train/__init__.py +0 -0
  34. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/train/train_ccgan.py +0 -0
  35. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/train/train_cgan.py +0 -0
  36. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/train/train_cgan_concat.py +0 -0
  37. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/train/train_net_for_label_embed.py +0 -0
  38. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/__init__.py +0 -0
  39. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/concat_image.py +0 -0
  40. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/dataset.py +0 -0
  41. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/src/style.css +0 -0
  42. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/src/style.css.map +0 -0
  43. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/src/style.scss +0 -0
  44. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/CcGAN/utils/src/template.html +0 -0
  45. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/myosotis_researches/__init__.py +0 -0
  46. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/pyproject.toml +0 -0
  47. {myosotis_researches-0.1.40 → myosotis_researches-0.1.42}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Myosotis-Researches
3
- Version: 0.1.40
3
+ Version: 0.1.42
4
4
  Summary: A repository for storing my progress of researches.
5
5
  Home-page: https://github.com/Zeyu-Xie/Myosotis-Researches
6
6
  Author: Zeyu Xie
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Myosotis-Researches
3
- Version: 0.1.40
3
+ Version: 0.1.42
4
4
  Summary: A repository for storing my progress of researches.
5
5
  Home-page: https://github.com/Zeyu-Xie/Myosotis-Researches
6
6
  Author: Zeyu Xie
@@ -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
 
@@ -92,12 +93,14 @@ def cross_correlation(images):
92
93
  def _rgb_histogram(image, bins=32):
93
94
  """
94
95
  image: numpy array of shape (H, W, 3), RGB format
95
- returns: concatenated histogram for R, G, B channels
96
+ returns: concatenated and normalized histogram for R, G, B channels
96
97
  """
97
- hist_r, _ = np.histogram(image[:, :, 0], bins=bins, range=(0, 255))
98
- hist_g, _ = np.histogram(image[:, :, 1], bins=bins, range=(0, 255))
99
- hist_b, _ = np.histogram(image[:, :, 2], bins=bins, range=(0, 255))
100
- hist = np.concatenate([hist_r, hist_g, hist_b])
98
+ image = np.asarray(image)
99
+ hist_r, _ = np.histogram(image[:, :, 0], bins=bins, range=(0, 256))
100
+ hist_g, _ = np.histogram(image[:, :, 1], bins=bins, range=(0, 256))
101
+ hist_b, _ = np.histogram(image[:, :, 2], bins=bins, range=(0, 256))
102
+ hist = np.concatenate([hist_r, hist_g, hist_b]).astype(np.float64)
103
+ hist /= np.sum(hist) # Normalize to make it a probability distribution
101
104
  return hist
102
105
 
103
106
 
@@ -118,6 +121,33 @@ def histogram_intersection(images):
118
121
  return histogram_intersection_sum / (n * (n - 1) / 2)
119
122
 
120
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
+
121
151
  # Similarity
122
152
  _method_dict = {
123
153
  "MSE": MSE,
@@ -125,6 +155,7 @@ _method_dict = {
125
155
  "PSNR": PSNR,
126
156
  "cross-correlation": cross_correlation,
127
157
  "histogram-intersection": histogram_intersection,
158
+ "kl-divergence": kl_divergence,
128
159
  }
129
160
 
130
161
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="Myosotis-Researches",
5
- version="0.1.40",
5
+ version="0.1.42",
6
6
  description="A repository for storing my progress of researches.",
7
7
  long_description=open("README.md").read(),
8
8
  long_description_content_type="text/markdown",