Myosotis-Researches 0.0.8__py3-none-any.whl → 0.0.10__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.
@@ -1,5 +1,6 @@
1
1
  from .print_hdf5_structure import print_hdf5_structure
2
2
  from .concat_image_horizontal import concat_image_horizontal
3
3
  from .concat_image_vertical import concat_image_vertical
4
+ from .make_h5 import make_h5
4
5
 
5
- __all__ = ["print_hdf5_structure", "concat_image_horizontal", "concat_image_vertical"]
6
+ __all__ = ["print_hdf5_structure", "concat_image_horizontal", "concat_image_vertical", "make_h5"]
@@ -0,0 +1,39 @@
1
+ import h5py
2
+ import numpy as np
3
+ import os
4
+ from PIL import Image
5
+ from print_hdf5_structure import print_hdf5_structure
6
+
7
+ # Make all images to a HDF5 file
8
+ def make_h5(image_dir: str, h5_path: str, image_names: list[str], image_labels, image_types):
9
+
10
+ N = len(image_names)
11
+
12
+ # Get image data
13
+ image_datas = []
14
+ for i in range(N):
15
+ image_name = image_names[i]
16
+ image_path = os.path.join(image_dir, image_name)
17
+ image = Image.open(image_path).convert("RGB")
18
+ rgb_array = np.array(image).transpose((2, 0, 1))
19
+ image_datas.append(rgb_array)
20
+ img_datas = np.array(img_datas, dtype=np.uint8)
21
+
22
+ # Set train_idx = 1, 3, 5, ...
23
+ train_idx = np.array(range(1, N, 2), dtype=np.int32)
24
+
25
+ # Set val_idx = 0, 2, 4, ...
26
+ val_idx = np.array(range(0, N, 2), dtype=np.int32)
27
+
28
+ # Create a new HDF5 file
29
+ with h5py.File(h5_path, "w") as f:
30
+ f.create_dataset("images", data=image_datas)
31
+ f.create_dataset("indx_train", data=train_idx)
32
+ f.create_dataset("indx_valid", data=val_idx)
33
+ f.create_dataset("labels", data=image_labels)
34
+ f.create_dataset("types", data=image_types)
35
+
36
+ # Visualize
37
+ f.visititems(print_hdf5_structure)
38
+
39
+ __all__ = ["make_h5"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Myosotis-Researches
3
- Version: 0.0.8
3
+ Version: 0.0.10
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
@@ -0,0 +1,12 @@
1
+ myosotis_researches/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ myosotis_researches/CcGAN/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ myosotis_researches/CcGAN/utils/__init__.py,sha256=Pu9COV4zcXHGXuczhObersyeshVChmlEtwqp8VLUDxw,300
4
+ myosotis_researches/CcGAN/utils/concat_image_horizontal.py,sha256=e6WsfO9IiSoP8zkZNz7IGimPUASr9VvyJUJdF-d40iw,954
5
+ myosotis_researches/CcGAN/utils/concat_image_vertical.py,sha256=97-SuE8ZWpaeBm_ed6MAEaUOvtpzlYq_X3yWt4OEUTY,951
6
+ myosotis_researches/CcGAN/utils/make_h5.py,sha256=1Q_a78Yc3TohposEljvE_dr2KAupo467jmO6por2Cz4,1235
7
+ myosotis_researches/CcGAN/utils/print_hdf5_structure.py,sha256=leaR8H3GhlX6EuIXDMh36xG2zBdV-XlJkaXBuoorl6I,320
8
+ myosotis_researches-0.0.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
9
+ myosotis_researches-0.0.10.dist-info/METADATA,sha256=6DhrXi4lJ7yxbuR1LuBqmyPyd-SsZm3gXT29ZL1fOjU,765
10
+ myosotis_researches-0.0.10.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
11
+ myosotis_researches-0.0.10.dist-info/top_level.txt,sha256=zxAiMn5eyZNJM28MewTAkgi_RZJMbfWbzVR-KF0LdZE,20
12
+ myosotis_researches-0.0.10.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- myosotis_researches/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- myosotis_researches/CcGAN/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- myosotis_researches/CcGAN/utils/__init__.py,sha256=WAsBg2lrqxC8T4cmFcfjeVuyfky94UFcrWw7w_q-I5c,260
4
- myosotis_researches/CcGAN/utils/concat_image_horizontal.py,sha256=e6WsfO9IiSoP8zkZNz7IGimPUASr9VvyJUJdF-d40iw,954
5
- myosotis_researches/CcGAN/utils/concat_image_vertical.py,sha256=97-SuE8ZWpaeBm_ed6MAEaUOvtpzlYq_X3yWt4OEUTY,951
6
- myosotis_researches/CcGAN/utils/print_hdf5_structure.py,sha256=leaR8H3GhlX6EuIXDMh36xG2zBdV-XlJkaXBuoorl6I,320
7
- myosotis_researches-0.0.8.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
8
- myosotis_researches-0.0.8.dist-info/METADATA,sha256=AghCaPnyTv6o4mm-IJJVVRXbdLuf0l4N7HzjDlyyu9Y,764
9
- myosotis_researches-0.0.8.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
10
- myosotis_researches-0.0.8.dist-info/top_level.txt,sha256=zxAiMn5eyZNJM28MewTAkgi_RZJMbfWbzVR-KF0LdZE,20
11
- myosotis_researches-0.0.8.dist-info/RECORD,,