Myosotis-Researches 0.1.26__tar.gz → 0.1.28__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 (49) hide show
  1. myosotis_researches-0.1.28/MANIFEST.in +1 -0
  2. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28/Myosotis_Researches.egg-info}/PKG-INFO +1 -1
  3. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/Myosotis_Researches.egg-info/SOURCES.txt +5 -1
  4. {myosotis_researches-0.1.26/Myosotis_Researches.egg-info → myosotis_researches-0.1.28}/PKG-INFO +1 -1
  5. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/__init__.py +2 -0
  6. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/dataset.py +135 -0
  7. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/src/style.css +44 -0
  8. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/src/style.css.map +1 -0
  9. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/src/style.scss +42 -0
  10. myosotis_researches-0.1.28/myosotis_researches/CcGAN/utils/src/template.html +106 -0
  11. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/setup.py +1 -1
  12. myosotis_researches-0.1.26/MANIFEST.in +0 -1
  13. myosotis_researches-0.1.26/myosotis_researches/CcGAN/utils/__init__.py +0 -2
  14. myosotis_researches-0.1.26/myosotis_researches/CcGAN/utils/dataset.py +0 -45
  15. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/LICENSE +0 -0
  16. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/Myosotis_Researches.egg-info/dependency_links.txt +0 -0
  17. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/Myosotis_Researches.egg-info/top_level.txt +0 -0
  18. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/README.md +0 -0
  19. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/__init__.py +0 -0
  20. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/CcGAN_SAGAN.py +0 -0
  21. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/ResNet_class_eval.py +0 -0
  22. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/ResNet_embed.py +0 -0
  23. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/ResNet_regre_eval.py +0 -0
  24. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/__init__.py +0 -0
  25. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/autoencoder.py +0 -0
  26. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/cGAN_SAGAN.py +0 -0
  27. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_128/cGAN_concat_SAGAN.py +0 -0
  28. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/CcGAN_SAGAN.py +0 -0
  29. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/ResNet_class_eval.py +0 -0
  30. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/ResNet_embed.py +0 -0
  31. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/ResNet_regre_eval.py +0 -0
  32. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/__init__.py +0 -0
  33. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/autoencoder.py +0 -0
  34. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/cGAN_SAGAN.py +0 -0
  35. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/models_256/cGAN_concat_SAGAN.py +0 -0
  36. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/old/IMGs_dataset.py +0 -0
  37. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/old/SimpleProgressBar.py +0 -0
  38. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/old/__init__.py +0 -0
  39. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/old/opts.py +0 -0
  40. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/old/train.py +0 -0
  41. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/train/__init__.py +0 -0
  42. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/train/train_ccgan.py +0 -0
  43. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/train/train_cgan.py +0 -0
  44. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/train/train_cgan_concat.py +0 -0
  45. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/train/train_net_for_label_embed.py +0 -0
  46. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/CcGAN/utils/concat_image.py +0 -0
  47. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/myosotis_researches/__init__.py +0 -0
  48. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/pyproject.toml +0 -0
  49. {myosotis_researches-0.1.26 → myosotis_researches-0.1.28}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ include myosotis_researches/CcGAN/utils/src/*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Myosotis-Researches
3
- Version: 0.1.26
3
+ Version: 0.1.28
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
@@ -37,4 +37,8 @@ myosotis_researches/CcGAN/train/train_cgan_concat.py
37
37
  myosotis_researches/CcGAN/train/train_net_for_label_embed.py
38
38
  myosotis_researches/CcGAN/utils/__init__.py
39
39
  myosotis_researches/CcGAN/utils/concat_image.py
40
- myosotis_researches/CcGAN/utils/dataset.py
40
+ myosotis_researches/CcGAN/utils/dataset.py
41
+ myosotis_researches/CcGAN/utils/src/style.css
42
+ myosotis_researches/CcGAN/utils/src/style.css.map
43
+ myosotis_researches/CcGAN/utils/src/style.scss
44
+ myosotis_researches/CcGAN/utils/src/template.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Myosotis-Researches
3
- Version: 0.1.26
3
+ Version: 0.1.28
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,2 @@
1
+ from .concat_image import concat_image
2
+ from .dataset import view_dataset, visualize_dataset, download_datasets
@@ -0,0 +1,135 @@
1
+ import base64
2
+ from flask import Flask, send_file
3
+ import gdown
4
+ import getpass
5
+ import h5py
6
+ import h5py
7
+ import humanize
8
+ from importlib import resources
9
+ from io import BytesIO
10
+ from jinja2 import Template
11
+ import numpy as np
12
+ import os
13
+ from PIL import Image
14
+ import subprocess
15
+ import time
16
+
17
+
18
+ # view_dataset
19
+ def _print_hdf5(name, obj):
20
+ indent = " " * name.count("/")
21
+ if isinstance(obj, h5py.Dataset):
22
+ print(f"{indent}[Dataset] {name} shape={obj.shape} dtype={obj.dtype}")
23
+ elif isinstance(obj, h5py.Group):
24
+ print(f"{indent}[Group] {name}")
25
+
26
+
27
+ def view_dataset(dataset_path):
28
+ with h5py.File(dataset_path, "r") as f:
29
+ f.visititems(_print_hdf5)
30
+
31
+
32
+ # visualize_dataset
33
+ def _nparray_to_Base64(nparray):
34
+ nparray = np.transpose(nparray, (1, 2, 0))
35
+ image = Image.fromarray(nparray)
36
+ buffered = BytesIO()
37
+ image.save(buffered, format="PNG")
38
+ image_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
39
+ return f"data:image/png;base64,{image_base64}"
40
+
41
+
42
+ def visualize_dataset(dataset_path, indexes):
43
+ keys = []
44
+ _data = {}
45
+ with h5py.File(dataset_path, "r") as f:
46
+ for key in f.keys():
47
+ keys.append(key)
48
+ _data[key] = f[key][:]
49
+ if _data[key].dtype.kind == "O":
50
+ _data[key] = _data[key].astype("str")
51
+ keys.append("original_indexes")
52
+ N = len(_data["images"])
53
+ data = []
54
+ for i in indexes:
55
+ item = {}
56
+ for key in keys:
57
+ if key == "images":
58
+ item[key] = _nparray_to_Base64(_data[key][i])
59
+ elif key in ["index_train", "index_valid"]:
60
+ continue
61
+ elif key == "original_indexes":
62
+ item[key] = i
63
+ else:
64
+ item[key] = _data[key][i]
65
+ data.append(item)
66
+ hyperinfo = {
67
+ "template_path": resources.files("myosotis_researches").joinpath(
68
+ "CcGAN", "utils", "src", "template.html"
69
+ ),
70
+ "style_path": resources.files("myosotis_researches").joinpath(
71
+ "CcGAN", "utils", "src", "style.css"
72
+ ),
73
+ "server_path": os.path.abspath(__file__),
74
+ "host": "0.0.0.0",
75
+ "port": "8000",
76
+ "debug": True,
77
+ }
78
+ info = {
79
+ "file": {
80
+ "size": humanize.naturalsize(os.path.getsize(dataset_path), binary=True),
81
+ "created_date": time.strftime(
82
+ "%Y-%m-%d %H:%M:%S", time.localtime(os.path.getctime(dataset_path))
83
+ ),
84
+ "last_edited_date": time.strftime(
85
+ "%Y-%m-%d %H:%M:%S", time.localtime(os.path.getmtime(dataset_path))
86
+ ),
87
+ "path": dataset_path,
88
+ "name": os.path.basename(dataset_path),
89
+ },
90
+ "rows": {"num": N},
91
+ "columns": {"num": len(keys), "list": keys},
92
+ "indexes": indexes,
93
+ }
94
+ all_data = data
95
+
96
+ # Local server
97
+ app = Flask(__name__)
98
+
99
+ @app.route("/")
100
+ def index():
101
+ with open(hyperinfo["template_path"], "r") as f:
102
+ template = Template(f.read())
103
+ return template.render(hyperinfo=hyperinfo, info=info, datas=all_data)
104
+
105
+ @app.route("/style.css")
106
+ def style():
107
+ return send_file(hyperinfo["style_path"])
108
+
109
+ app.run(host=hyperinfo["host"], port=hyperinfo["port"], debug=hyperinfo["debug"])
110
+
111
+
112
+ # download_datasets
113
+ _file_id_dict = {
114
+ "Ra": "1YVLFAaQ1ldre0ASLSRdV_kPIcAMkwGqO",
115
+ "MNIST": "18249ryrDPsznWWtOkJuALZWCVoZqfibC",
116
+ }
117
+
118
+
119
+ def download_datasets(datasets_name, datasets_dir):
120
+ if not os.path.exists(datasets_dir):
121
+ os.makedirs(datasets_dir, exist_ok=True)
122
+ zipped_datasets_path = os.path.join(datasets_dir, f"{datasets_name}.rar")
123
+ file_id = _file_id_dict[datasets_name]
124
+ url = f"https://drive.google.com/uc?id={file_id}"
125
+ gdown.download(url, zipped_datasets_path, quiet=False, use_cookies=False)
126
+ unzip_password = getpass.getpass("Please input the zipped file's password:")
127
+ try:
128
+ cmd = ["unrar", "x", f"-p{unzip_password}", zipped_datasets_path, datasets_dir]
129
+ subprocess.run(cmd, check=True)
130
+ except subprocess.CalledProcessError as e:
131
+ print(e)
132
+ os.remove(zipped_datasets_path)
133
+
134
+
135
+ __all__ = ["view_dataset", "visualize_dataset", "download_datasets"]
@@ -0,0 +1,44 @@
1
+ * {
2
+ font-family: Arial, Helvetica, sans-serif;
3
+ scrollbar-width: none;
4
+ -ms-overflow-style: none;
5
+ }
6
+ * ::-webkit-scrollbar {
7
+ display: none;
8
+ }
9
+
10
+ body {
11
+ margin: 0 1rem;
12
+ border: 0;
13
+ padding: 0;
14
+ }
15
+
16
+ .code {
17
+ font-family: "Courier New", Courier, monospace;
18
+ }
19
+
20
+ .container {
21
+ margin: 0;
22
+ border: 0;
23
+ padding: 0;
24
+ overflow: scroll;
25
+ }
26
+
27
+ .inline-info {
28
+ word-break: break-all;
29
+ }
30
+
31
+ #main-container {
32
+ margin: 1rem auto;
33
+ }
34
+
35
+ table {
36
+ text-align: center;
37
+ margin-inline: auto;
38
+ }
39
+ table th,
40
+ table td {
41
+ padding: 0.5rem 1rem;
42
+ }
43
+
44
+ /*# sourceMappingURL=style.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;;AACA;EACE;;;AAIJ;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;;AACA;AAAA;EAEE","file":"style.css"}
@@ -0,0 +1,42 @@
1
+ * {
2
+ font-family: Arial, Helvetica, sans-serif;
3
+ scrollbar-width: none;
4
+ -ms-overflow-style: none;
5
+ ::-webkit-scrollbar {
6
+ display: none;
7
+ }
8
+ }
9
+
10
+ body {
11
+ margin: 0 1rem;
12
+ border: 0;
13
+ padding: 0;
14
+ }
15
+
16
+ .code {
17
+ font-family: "Courier New", Courier, monospace;
18
+ }
19
+
20
+ .container {
21
+ margin: 0;
22
+ border: 0;
23
+ padding: 0;
24
+ overflow: scroll;
25
+ }
26
+
27
+ .inline-info {
28
+ word-break: break-all;
29
+ }
30
+
31
+ #main-container {
32
+ margin: 1rem auto;
33
+ }
34
+
35
+ table {
36
+ text-align: center;
37
+ margin-inline: auto;
38
+ th,
39
+ td {
40
+ padding: 0.5rem 1rem;
41
+ }
42
+ }
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Dataset Visualize of {{ info.file.name }}</title>
8
+ <link rel="stylesheet" href="./style.css">
9
+ </head>
10
+
11
+ <body>
12
+
13
+ <div class="container" id="main-container">
14
+ <h1>Dataset Visualize of <span class="code">{{ info.file.name }}</span></h1>
15
+
16
+ <hr>
17
+
18
+ <section>
19
+ <h2>Part 1. Hyperinfo</h2>
20
+ <div class="container" id="hyperinfo-container">
21
+ <p><b>Template Path</b></p>
22
+ <p class="code">{{ hyperinfo.template_path }}</p>
23
+ <p><b>Style Path</b></p>
24
+ <p class="code">{{ hyperinfo.style_path }}</p>
25
+ <p><b>Server Path</b></p>
26
+ <p class="code">{{ hyperinfo.server_path }}</p>
27
+ <table>
28
+ <tr>
29
+ <th>Host</th>
30
+ <th>Port</th>
31
+ <th>Debug</th>
32
+ </tr>
33
+ <tr>
34
+ <td>{{ hyperinfo.host }}</td>
35
+ <td>{{ hyperinfo.port }}</td>
36
+ <td>{{ hyperinfo.debug }}</td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </section>
41
+
42
+ <section>
43
+ <h2>Part 2. Info</h2>
44
+ <div class="container" id="info-container">
45
+ <p><b>File Path</b></p>
46
+ <p class="code">{{ info.file.path }}</p>
47
+ <table>
48
+ <tr>
49
+ <th>File Size</th>
50
+ <th>Created Date</th>
51
+ <th>Last Edited Date</th>
52
+ </tr>
53
+ <tr>
54
+ <td>{{ info.file.size }}</td>
55
+ <td>{{ info.file.created_date }}</td>
56
+ <td>{{ info.file.last_edited_date }}</td>
57
+ </tr>
58
+ </table>
59
+ <p><b>Number of Rows</b></p>
60
+ <p>{{ info.rows.num }}</p>
61
+ <p><b>Number of Columns</b></p>
62
+ <p>{{ info.columns.num }}</p>
63
+ <p><b>Columns List</b></p>
64
+ <p class="code">{{ info.columns.list }}</p>
65
+ <p><b>Indexes</b></p>
66
+ <p class="code">{{ info.indexes }}</p>
67
+ </div>
68
+ </section>
69
+ <section>
70
+ <h2>Part 3. Data List</h2>
71
+ <p><b>List</b></p>
72
+ <div class="container" id="data-list-container">
73
+ <table id="main-table">
74
+ <thead>
75
+ <tr>
76
+ <th>Images</th>
77
+ {% for key in info.columns.list %}
78
+ {% if key not in ["images", "index_train", "index_valid"] %}
79
+ <th>{{ key|capitalize }}</th>
80
+ {% endif %}
81
+ {% endfor %}
82
+ </tr>
83
+ </thead>
84
+ {% for data in datas %}
85
+ <tr>
86
+ <td>
87
+ <img src="{{ data.images }}" alt="" style="width: 64px;">
88
+ </td>
89
+ {% for key in info.columns.list %}
90
+ {% if key not in ["images", "index_train", "index_valid"] %}
91
+ <td {% if key == "image_names" %} class="code" {% endif %}>
92
+ {{ data[key] }}
93
+ </td>
94
+ {% endif %}
95
+ {% endfor %}
96
+ </tr>
97
+ {% endfor %}
98
+ </table>
99
+ </div>
100
+ </section>
101
+ </div>
102
+
103
+
104
+ </body>
105
+
106
+ </html>
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="Myosotis-Researches",
5
- version="0.1.26",
5
+ version="0.1.28",
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",
@@ -1 +0,0 @@
1
- include myosotis_researches/CcGAN/visualize/src/*
@@ -1,2 +0,0 @@
1
- from .concat_image import concat_image
2
- from .dataset import view_dataset, download_datasets
@@ -1,45 +0,0 @@
1
- import gdown
2
- import getpass
3
- import h5py
4
- import os
5
- import subprocess
6
-
7
-
8
- # view_dataset
9
- def _print_hdf5(name, obj):
10
- indent = " " * name.count("/")
11
- if isinstance(obj, h5py.Dataset):
12
- print(f"{indent}[Dataset] {name} shape={obj.shape} dtype={obj.dtype}")
13
- elif isinstance(obj, h5py.Group):
14
- print(f"{indent}[Group] {name}")
15
-
16
-
17
- def view_dataset(dataset_path):
18
- with h5py.File(dataset_path, "r") as f:
19
- f.visititems(_print_hdf5)
20
-
21
-
22
- # download_datasets
23
- _file_id_dict = {
24
- "Ra": "1YVLFAaQ1ldre0ASLSRdV_kPIcAMkwGqO",
25
- "MNIST": "18249ryrDPsznWWtOkJuALZWCVoZqfibC",
26
- }
27
-
28
-
29
- def download_datasets(datasets_name, datasets_dir):
30
- if not os.path.exists(datasets_dir):
31
- os.makedirs(datasets_dir, exist_ok=True)
32
- zipped_datasets_path = os.path.join(datasets_dir, f"{datasets_name}.rar")
33
- file_id = _file_id_dict[datasets_name]
34
- url = f"https://drive.google.com/uc?id={file_id}"
35
- gdown.download(url, zipped_datasets_path, quiet=False, use_cookies=False)
36
- unzip_password = getpass.getpass("Please input the zipped file's password:")
37
- try:
38
- cmd = ["unrar", "x", f"-p{unzip_password}", zipped_datasets_path, datasets_dir]
39
- subprocess.run(cmd, check=True)
40
- except subprocess.CalledProcessError as e:
41
- print(e)
42
- os.remove(zipped_datasets_path)
43
-
44
-
45
- __all__ = ["view_dataset", "download_datasets"]