tatools01 1.0__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.
tatools01-1.0/LICENSE ADDED
@@ -0,0 +1 @@
1
+ MIT license
tatools01-1.0/PKG-INFO ADDED
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: tatools01
3
+ Version: 1.0
4
+ Summary: Thư viện hữu ích của Tuấn Anh.
5
+ Home-page: https://pypi.org/project/tatools01/
6
+ Author: Tuấn Anh - Foxconn
7
+ Author-email: nt.anh.fai@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: ruamel.yaml
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: summary
25
+
26
+ # Giới thiệu
27
+ tattools01 là 1 thư viện dùng để ghi tham số vào ổ cứng
@@ -0,0 +1,2 @@
1
+ # Giới thiệu
2
+ tattools01 là 1 thư viện dùng để ghi tham số vào ổ cứng
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
tatools01-1.0/setup.py ADDED
@@ -0,0 +1,35 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name="tatools01", # tên của gói thư viện
8
+ version="1.0",
9
+ description="Thư viện hữu ích của Tuấn Anh.",
10
+ url="https://pypi.org/project/tatools01/",
11
+ author="Tuấn Anh - Foxconn",
12
+ author_email="nt.anh.fai@gmail.com",
13
+ license="MIT",
14
+ long_description=long_description,
15
+ long_description_content_type="text/markdown",
16
+ packages=find_packages(),
17
+ install_requires=[
18
+ "ruamel.yaml",
19
+ ], # ultralytics 8.2.84 requires numpy<2.0.0,>=1.23.0 pip install numpy==1.26.4
20
+ classifiers=[
21
+ "Programming Language :: Python :: 3",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ ],
25
+ package_data={"tatools01": [ "Thoi_gian/*", ]},
26
+ # package_dir={"": "ntanh"},
27
+ # packages=find_packages(where="ntanh"),
28
+ Homepage="https://github.com/ntanhfai/tact",
29
+ Issues="https://github.com/ntanhfai/tact/issues",
30
+ entry_points={
31
+ "console_scripts": [
32
+ "tact=tatools01:console_main",
33
+ ],
34
+ },
35
+ )
@@ -0,0 +1,91 @@
1
+ import os
2
+ # import pathlib
3
+ from os.path import join, exists, basename
4
+ from datetime import datetime
5
+ from ruamel.yaml import YAML
6
+
7
+ yaml = YAML()
8
+ yaml.compact(seq_seq=False, seq_map=False)
9
+
10
+ class TactParameters:
11
+ def __init__(self, ModuleName="TACT", logdir="", params_dir=""):
12
+ self.ModuleName = ModuleName
13
+ self.logdir = logdir
14
+ self.fn = ""
15
+ self.AppName = ""
16
+ self.params_dir = params_dir
17
+ self.config_file_path = None
18
+
19
+ def to_yaml(self, file_path):
20
+ file_path = self._get_full_file_path(file_path)
21
+ with open(file_path, "w", encoding="utf-8") as file:
22
+ yml_content = {self.ModuleName: self._clean_dict(self.__dict__)}
23
+ yaml.dump(yml_content, file)
24
+
25
+ def from_yaml(self, file_path):
26
+ file_path = self._get_full_file_path(file_path)
27
+ if exists(file_path):
28
+ with open(file_path, "r", encoding="utf-8") as file:
29
+ data = yaml.load(file)
30
+ if self.ModuleName in data:
31
+ self.__dict__.update(data[self.ModuleName])
32
+
33
+ def load_then_save_to_yaml(self, file_path, ModuleName=None, flogDict=False, save2file=True):
34
+ if ModuleName:
35
+ self.ModuleName = ModuleName
36
+ self.fn = file_path
37
+ self.from_yaml(file_path)
38
+ if save2file:
39
+ self.to_yaml(file_path)
40
+ if flogDict:
41
+ self._log(str(self.__dict__))
42
+
43
+ def save_to_yaml_only(self, filepath=None):
44
+ if filepath is not None:
45
+ self.fn = filepath
46
+ self.to_yaml(self.fn)
47
+
48
+ def get(self, key, default=None):
49
+ return self.__dict__.get(key, default)
50
+
51
+ @staticmethod
52
+ def find_files(mDir, exts=(".jpg", ".jpeg", ".png")):
53
+ return sorted(
54
+ [join(D, fn).replace("\\", "/") for D, _, F in os.walk(mDir) for fn in F if fn.endswith(exts)]
55
+ )
56
+
57
+ def _get_full_file_path(self, file_path):
58
+ if self.AppName and self.params_dir:
59
+ return os.path.join(self.params_dir, basename(file_path))
60
+ return file_path
61
+
62
+ def _clean_dict(self, input_dict):
63
+ keys_to_remove = [
64
+ "ModuleName", "logdir", "fn", "AppName", "saveParam_onlyThis_APP_NAME", "config_file_path", "params_dir"
65
+ ]
66
+ return {k: v for k, v in input_dict.items() if k not in keys_to_remove}
67
+
68
+ def mlog(self, *args):
69
+ logdir = self.logdir
70
+ message = " ".join([str(arg) for arg in args])
71
+ currTime = datetime.now()
72
+ sDT = currTime.strftime("%m/%d, %H:%M:%S")
73
+ log_file = f"{logdir}/logs/{currTime.year}/{currTime.month}/{currTime.day}/logs.txt" if logdir else f"logs/{currTime.year}/{currTime.month}/{currTime.day}/logs.txt"
74
+ os.makedirs(os.path.dirname(log_file), exist_ok=True)
75
+ with open(log_file, "a", encoding="utf-8") as log:
76
+ log.write(f"{sDT} [{self.ModuleName}] {message}\n")
77
+ print(f"{sDT} [{self.ModuleName}] {message}\n")
78
+
79
+
80
+
81
+ if __name__ == "__main__":
82
+ AppName = 'My_Project_Name'
83
+ class Parameters(TactParameters):
84
+ def __init__(self):
85
+ super().__init__(ModuleName="Module 01", params_dir='./' )
86
+ self.HD = ["Chương trình này nhằm xây dựng tham số cho các chương trình khác"]
87
+ self.test1 = "123"
88
+ self.load_then_save_to_yaml(file_path=f"{AppName}.yml")
89
+ self.in_var = 1
90
+ mPs = Parameters()
91
+ mPs.mlog("hello")
@@ -0,0 +1,70 @@
1
+ import time
2
+
3
+
4
+ class MultiTimer:
5
+ def __init__(self):
6
+ self.times = {} # Lưu trữ thời gian của mỗi đoạn code
7
+ self.start_time = None
8
+
9
+ def start(self):
10
+ """Bắt đầu đo thời gian."""
11
+ self.start_time = time.time()
12
+ def stop(self):
13
+ """Bắt đầu đo thời gian."""
14
+ self.start_time = None
15
+
16
+ def update(self, label):
17
+ """Dừng đo thời gian và lưu kết quả cho một đoạn code với nhãn (label)."""
18
+ if self.start_time is None:
19
+ raise Exception("Timer has not been started yet!")
20
+ elapsed_time = time.time() - self.start_time
21
+ if label in self.times:
22
+ self.times[label].append(elapsed_time)
23
+ else:
24
+ self.times[label] = [elapsed_time]
25
+ self.start_time = time.time()
26
+
27
+ def reset(self):
28
+ """Đặt lại bộ đếm thời gian."""
29
+ self.start_time = None
30
+ self.times = {}
31
+
32
+ def summary(self):
33
+ """In ra kết quả đo thời gian cho tất cả các đoạn code."""
34
+ if not self.times:
35
+ print("No times recorded.")
36
+ else:
37
+ print("\n=== Time Summary ===")
38
+ for label, times in self.times.items():
39
+ total_time = sum(times)
40
+ avg_time = total_time / len(times)
41
+ print(f"Code: {label}")
42
+ print(f" Total time: {total_time:.6f} seconds")
43
+ print(f" Average time: {avg_time:.6f} seconds")
44
+ print(f" Runs: {len(times)}\n")
45
+
46
+ if __name__ == "__main__":
47
+ # Ví dụ sử dụng class MultiTimer
48
+ timer = MultiTimer()
49
+
50
+ # Đo thời gian cho đoạn code 1
51
+ timer.start()
52
+ # Đoạn code mà bạn muốn đo (ví dụ 1)
53
+ for _ in range(1000000):
54
+ pass
55
+ timer.update("Code 1")
56
+
57
+ # Đo thời gian cho đoạn code 2
58
+ timer.start()
59
+ # Đoạn code mà bạn muốn đo (ví dụ 2)
60
+ time.sleep(1)
61
+ timer.update("Code 2")
62
+
63
+ # Đo lại thời gian cho Code 1
64
+ timer.start()
65
+ for _ in range(500000):
66
+ pass
67
+ timer.update("Code 1")
68
+
69
+ # In ra kết quả cuối cùng
70
+ timer.summary()
@@ -0,0 +1,57 @@
1
+ """
2
+ ntanh
3
+
4
+ An python parametters library.
5
+ """
6
+
7
+ __version__ = "1.0" # Nhớ update cả Readme.md
8
+
9
+ __author__ = "Nguyễn Tuấn Anh - nt.anh.fai@gmail.com"
10
+ __credits__ = "MIT License"
11
+ __console__ = "ntanh, ntanh_aug, ntanh_img_del"
12
+ import os
13
+ import sys
14
+ import argparse
15
+ import json
16
+
17
+
18
+ from . import ParamsBase
19
+ from tatools01.Thoi_gian.taTimers import MultiTimer
20
+
21
+
22
+ # draw_xyxyn_rectangles_and_show, draw_rectangles_and_show, draw_yolo_boxes_and_show, get_Org_xyxyn__from_Cropped_resized_bboxn
23
+
24
+
25
+ # ImageAugmentation.Augment_image_in_multiple_ways
26
+ # fnPlot_Warp_Text
27
+ # PlotText_UTF8
28
+ # PlotText_UTF8_outline
29
+ # opposite_color
30
+ # putTextWithOutline
31
+ # draw_bounding_box
32
+ # PlotText
33
+
34
+ # rotate_image
35
+ # ImageInfomation
36
+
37
+ # fnPlot_Warp_Text
38
+ # PlotText_UTF8
39
+ # PlotText_UTF8_outline
40
+ # putTextWithOutline
41
+
42
+
43
+ # MultiTimer()
44
+ # test()
45
+ __help__ = """
46
+ from ntanh.ParamsBase import tactParametters
47
+ from ntanh.yolo_boxes import xyxy_to_yolo_str, yolo_str_to_xyxy, calculate_luminance
48
+ """
49
+
50
+ def console_main():
51
+ print(
52
+ """
53
+ Running:
54
+ 1. tact
55
+ """
56
+ )
57
+
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: tatools01
3
+ Version: 1.0
4
+ Summary: Thư viện hữu ích của Tuấn Anh.
5
+ Home-page: https://pypi.org/project/tatools01/
6
+ Author: Tuấn Anh - Foxconn
7
+ Author-email: nt.anh.fai@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: ruamel.yaml
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: summary
25
+
26
+ # Giới thiệu
27
+ tattools01 là 1 thư viện dùng để ghi tham số vào ổ cứng
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ tatools01/ParamsBase.py
5
+ tatools01/__init__.py
6
+ tatools01.egg-info/PKG-INFO
7
+ tatools01.egg-info/SOURCES.txt
8
+ tatools01.egg-info/dependency_links.txt
9
+ tatools01.egg-info/entry_points.txt
10
+ tatools01.egg-info/requires.txt
11
+ tatools01.egg-info/top_level.txt
12
+ tatools01/Thoi_gian/taTimers.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tact = tatools01:console_main
@@ -0,0 +1 @@
1
+ ruamel.yaml
@@ -0,0 +1 @@
1
+ tatools01