tensorneko 0.3.20__py3-none-any.whl → 0.3.21__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,6 +1,13 @@
1
1
  from typing import List
2
2
 
3
- from torch.utils.data.dataset import Dataset, T_co
3
+ from torch.utils.data.dataset import Dataset
4
+
5
+ try:
6
+ # for pytorch < 2.5
7
+ from torch.utils.data.dataset import T_co
8
+ except ImportError:
9
+ # For pytorch >= 2.5
10
+ from torch.utils.data.dataset import _T_co as T_co
4
11
 
5
12
 
6
13
  class ListDataset(Dataset[T_co]):
@@ -2,7 +2,14 @@ from abc import abstractmethod, ABC
2
2
  from typing import Tuple
3
3
 
4
4
  import numpy as np
5
- from torch.utils.data.dataset import Dataset, T_co
5
+ from torch.utils.data.dataset import Dataset
6
+
7
+ try:
8
+ # for pytorch < 2.5
9
+ from torch.utils.data.dataset import T_co
10
+ except ImportError:
11
+ # For pytorch >= 2.5
12
+ from torch.utils.data.dataset import _T_co as T_co
6
13
 
7
14
 
8
15
  class NestedDataset(Dataset[T_co], ABC):
@@ -2,7 +2,13 @@ import random
2
2
  from typing import List, Optional
3
3
 
4
4
  from torch.utils.data import Dataset
5
- from torch.utils.data.dataset import T_co
5
+
6
+ try:
7
+ # for pytorch < 2.5
8
+ from torch.utils.data.dataset import T_co
9
+ except ImportError:
10
+ # For pytorch >= 2.5
11
+ from torch.utils.data.dataset import _T_co as T_co
6
12
 
7
13
  from ..util import circular_pad
8
14
 
@@ -1,6 +1,13 @@
1
1
  from typing import Sized
2
2
 
3
- from torch.utils.data.sampler import Sampler, T_co
3
+ from torch.utils.data.sampler import Sampler
4
+
5
+ try:
6
+ # for pytorch < 2.5
7
+ from torch.utils.data.sampler import T_co
8
+ except ImportError:
9
+ # For pytorch >= 2.5
10
+ from torch.utils.data.sampler import _T_co as T_co
4
11
 
5
12
 
6
13
  class SequentialIterSampler(Sampler[T_co]):
@@ -1,3 +1,9 @@
1
- from tensorneko_util.msg import push_gotify
1
+ from tensorneko_util.msg import gotify
2
2
 
3
- __all__ = ["push_gotify"]
3
+ __all__ = ["gotify"]
4
+
5
+ try:
6
+ from tensorneko_util.msg import postgres
7
+ __all__.append("postgres")
8
+ except ImportError:
9
+ pass
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import warnings
2
3
  from datetime import timedelta
3
4
  from time import time
4
5
  from typing import Optional, Union, List, Dict
@@ -70,6 +71,7 @@ class NekoTrainer(Trainer):
70
71
  callbacks = []
71
72
  # build checkpoint callback or from user defined
72
73
  if enable_checkpointing and len([c for c in callbacks if isinstance(c, Checkpoint)]) == 0:
74
+ warnings.warn("Checkpoint callback is not defined, using default checkpoint callback.")
73
75
  # use default checkpoint callback
74
76
  new_callback = ModelCheckpoint(
75
77
  dirpath=os.path.join("logs", self.log_name, "checkpoints"),
tensorneko/version.txt CHANGED
@@ -1 +1 @@
1
- 0.3.20
1
+ 0.3.21
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tensorneko
3
- Version: 0.3.20
3
+ Version: 0.3.21
4
4
  Summary: Tensor Neural Engine Kompanion. An util library based on PyTorch and PyTorch Lightning.
5
5
  Home-page: https://github.com/ControlNet/tensorneko
6
6
  Author: ControlNet
@@ -27,14 +27,14 @@ Requires-Dist: av (>=8.0.3)
27
27
  Requires-Dist: einops (>=0.3.0)
28
28
  Requires-Dist: numpy (>=1.20.1)
29
29
  Requires-Dist: pillow (>=8.1)
30
- Requires-Dist: tensorneko-util (==0.3.20)
30
+ Requires-Dist: tensorneko-util (==0.3.21)
31
31
  Requires-Dist: torch (>=1.9.0)
32
32
  Requires-Dist: torchaudio (>=0.9.0)
33
33
  Requires-Dist: torchmetrics (>=0.7.3)
34
34
  Requires-Dist: torchvision (>=0.10.0)
35
35
  Requires-Dist: pysoundfile (>=0.9.0) ; platform_system == "Windows"
36
36
  Provides-Extra: lightning
37
- Requires-Dist: lightning (<2.5,>=2.0) ; extra == 'lightning'
37
+ Requires-Dist: lightning (<3,>=2.0) ; extra == 'lightning'
38
38
  Requires-Dist: tensorboard (>=2.0.0) ; extra == 'lightning'
39
39
 
40
40
  <h1 style="text-align: center">TensorNeko</h1>
@@ -88,7 +88,7 @@ pipx install tensorneko_tool # or `pip install tensorneko_tool`
88
88
 
89
89
  Then you can use the CLI tools `tensorneko` in the terminal.
90
90
 
91
- ## Neko Layers, Modules and Architectures
91
+ ## Layers, Modules and Architectures
92
92
 
93
93
  Build an MLP with linear layers. The activation and normalization will be placed in the hidden layers.
94
94
 
@@ -177,7 +177,7 @@ print(f(torch.rand(16)).shape)
177
177
  # torch.Size([1])
178
178
  ```
179
179
 
180
- ## Neko IO
180
+ ## IO
181
181
 
182
182
  Easily load and save different modal data.
183
183
 
@@ -227,7 +227,7 @@ neko.io.write.json("path/to/json.json", json_obj)
227
227
  Besides, the read/write for `mat` and `pickle` files is also supported.
228
228
 
229
229
 
230
- ## Neko preprocessing
230
+ ## Preprocessing
231
231
 
232
232
  ```python
233
233
  import tensorneko as neko
@@ -254,7 +254,7 @@ if `ffmpeg` is available, you can use below ffmpeg wrappers.
254
254
  - `resample_video_fps`
255
255
  - `mp32wav`
256
256
 
257
- ## Neko Visualization
257
+ ## Visualization
258
258
 
259
259
  ### Variable Web Watcher
260
260
  Start a web server to watch the variable status when the program (e.g. training, inference, data preprocessing) is running.
@@ -405,14 +405,14 @@ trainer = neko.NekoTrainer(log_every_n_steps=100, gpus=1, logger=model.name, pre
405
405
  trainer.fit(model, dm)
406
406
  ```
407
407
 
408
- ## Neko Callbacks
408
+ ## Callbacks
409
409
 
410
410
  Some simple but useful pytorch-lightning callbacks are provided.
411
411
 
412
412
  - `DisplayMetricsCallback`
413
413
  - `EarlyStoppingLR`: Early stop training when learning rate reaches threshold.
414
414
 
415
- ## Neko Notebook Helpers
415
+ ## Notebook Helpers
416
416
  Here are some helper functions to better interact with Jupyter Notebook.
417
417
  ```python
418
418
  import tensorneko as neko
@@ -424,7 +424,7 @@ neko.notebook.display.audio("path/to/audio.wav")
424
424
  neko.notebook.display.code("path/to/code.java")
425
425
  ```
426
426
 
427
- ## Neko Debug Tools
427
+ ## Debug Tools
428
428
 
429
429
  Get the default values from `ArgumentParser` args. It's convenient to use this in the notebook.
430
430
  ```python
@@ -440,7 +440,7 @@ print(args.integers) # [1, 2, 3]
440
440
  print(args.accumulate) # <function sum at ...>
441
441
  ```
442
442
 
443
- ## Neko Evaluation
443
+ ## Evaluation
444
444
 
445
445
  Some metrics function for evaluation are provided.
446
446
 
@@ -451,8 +451,36 @@ Some metrics function for evaluation are provided.
451
451
  - `ssim_video`
452
452
  - `ssim_image`
453
453
 
454
+ ## Message (Access to other services)
454
455
 
455
- ## Neko Utilities
456
+ ### Gotify
457
+
458
+ Send a message to the Gotify server.
459
+
460
+ The title, URL and APP_TOKEN is the environment variable `GOTIFY_TITLE`, `GOTIFY_URL` and `GOTIFY_TOKEN`, or overwritten
461
+ in the function arguments.
462
+
463
+ ```python
464
+ from tensorneko.msg import gotify
465
+ gotify.push("This is a test message", "<URL>", "<APP_TOKEN>")
466
+ # then the message will be sent to the Gotify server.
467
+ # title = "<HOST_NAME>", message = "This is a test message", priority = 0
468
+ ```
469
+
470
+ ### Postgres
471
+
472
+ Require the `psycopg` package. Provide one single function to execute one SQL query with a temp connection.
473
+
474
+ The database URL is the environment variable `DB_URL`, or overwritten in the function arguments.
475
+ ```python
476
+ from tensorneko.msg import postgres
477
+ result = postgres.execute("<SQL>", "<DB_URL>")
478
+ # also async version is provided
479
+ result = await postgres.execute_async("<SQL>", "<DB_URL>")
480
+ ```
481
+
482
+
483
+ ## Utilities
456
484
 
457
485
  ### Misc functions
458
486
 
@@ -1,8 +1,8 @@
1
1
  tensorneko/__init__.py,sha256=uh1HNn1sNpX1bbOqAE_kNJfrH4eMtEzus0hO-Fh9tEw,990
2
2
  tensorneko/neko_model.py,sha256=hUMi7puzxW_6FOpA1jiFN1__oO5DZPlhhp3WXqhJXgg,10581
3
3
  tensorneko/neko_module.py,sha256=qELXvguSjWo_NvcRQibiFl0Qauzd9JWLSnT4dbGNS3Y,1473
4
- tensorneko/neko_trainer.py,sha256=JC8qoKSZ5ngz3grf3S0SjvIFVktDIP_GExth5aFfbGA,10074
5
- tensorneko/version.txt,sha256=QQxQgaQNGgPrr3bVpz_0fCx9e0SwIa-EL3bqC9TFcHE,6
4
+ tensorneko/neko_trainer.py,sha256=GqdRsPkzWj36DJ_Wroe1TI6QKlk3N8Q8gK4uEnI0w9Q,10190
5
+ tensorneko/version.txt,sha256=UfuS4cRkfbFuN1IeX9oKpvyZc11Pi5MXqTuYUmK9f5I,7
6
6
  tensorneko/arch/__init__.py,sha256=w4lTUeyBIZelrnSjlBFWUF0erzOmBFl9FqeWQuSOyKs,248
7
7
  tensorneko/arch/auto_encoder.py,sha256=j6PWWyaNYaYNtw_zZ9ikzhCASqe9viXR3JGBIXSK92Y,2137
8
8
  tensorneko/arch/binary_classifier.py,sha256=1MkEbReXKLdDksRG5Rsife40grJk08EVDcNKp54Xvb4,2316
@@ -20,11 +20,11 @@ tensorneko/callback/lr_logger.py,sha256=28xmAZ_UOFg0wqg1VjJoifwjzvBsOs-g2nd4bog9
20
20
  tensorneko/callback/nil_callback.py,sha256=-vKhOG3Ysv_ZToOdyYEkcZ8h0so9rBRY10f1OIoHeZs,131
21
21
  tensorneko/callback/system_stats_logger.py,sha256=dS4AOhEADU5cop6vSW5HnVew58jO9SdzKh4lkyssgcE,1782
22
22
  tensorneko/dataset/__init__.py,sha256=6980ci9Ce57HSyhzrKMJfDz31PCQxifVz1aSf63JEsA,247
23
- tensorneko/dataset/list_dataset.py,sha256=UhgTHapi7dQF4nEgnZH73oCLzluNAJU--N7Fhaa8P8s,1237
24
- tensorneko/dataset/nested_dataset.py,sha256=lMGW7ODfvBn-aRd7c7HftK6BQUZGCUVkm4XJh4iiPBg,2073
25
- tensorneko/dataset/round_robin_dataset.py,sha256=VcSApfqh218OGhJ6_F783s3pexrv17kM3aEaMHh9YJI,3073
23
+ tensorneko/dataset/list_dataset.py,sha256=kRLIlnLObctqOJYbTwy9pslSw6sBorOLQwMKu7ZqfXk,1407
24
+ tensorneko/dataset/nested_dataset.py,sha256=qVovwAgmBLdEgy6jTYlCHnosLWMG4HMvC-LtDSiDQ4Y,2243
25
+ tensorneko/dataset/round_robin_dataset.py,sha256=5yxeaKe5tEG-t4JkVcrohSU3bQsUKyH33Q6wky8tK-A,3207
26
26
  tensorneko/dataset/sampler/__init__.py,sha256=inj-7M5IjafU5yzSpU2BY9FWAiRp0u7RqkgAcIZj2Qk,102
27
- tensorneko/dataset/sampler/sequential_iter_sampler.py,sha256=DxBwSoWjYlq6kA6g-54gzzjPEAvOjAYtMQuvRbIFviY,1429
27
+ tensorneko/dataset/sampler/sequential_iter_sampler.py,sha256=RHzkFKqab6Azi50t5wAFWN6S9k9aeQAqEfrr9A6XoMY,1599
28
28
  tensorneko/debug/__init__.py,sha256=ZMfU3qquhMhl6EgPzM7Yuvvv0PWy3cR39UjPrrSmQcs,163
29
29
  tensorneko/evaluation/__init__.py,sha256=jW8dh1JRMpx3npjTp7wJLzz-IxFZTBh7F-Ztfoep9xs,296
30
30
  tensorneko/evaluation/enum.py,sha256=s3P8XAobku-as4in5vh6BanvVW5Ccwnff0t124lVFFg,137
@@ -63,7 +63,7 @@ tensorneko/module/inception.py,sha256=2p8AjgTIk5wLGC-JnrmXIehh6yNCu2tYc2axjzUTGM
63
63
  tensorneko/module/mlp.py,sha256=AFN6xmvlrNWOflLqVl-zVkoOJRZpYxYB4bnI10JG5CU,3361
64
64
  tensorneko/module/residual.py,sha256=S59TqiiD_310HQ3a6s3r49XY_7Dc4RGxONQtSvzEfN0,2958
65
65
  tensorneko/module/transformer.py,sha256=h4NvH3zGa0rZt0bv6e8VM31SimbQKRcocSR42zJYVoY,7602
66
- tensorneko/msg/__init__.py,sha256=GHrHjzw__0DcPBHBN6GzHrD8PD_7CwOZPRullOaZyW0,71
66
+ tensorneko/msg/__init__.py,sha256=0v56ICUDhBUKnypwjLj4epnzfqkr9M4p00HuYpPc3x8,172
67
67
  tensorneko/notebook/__init__.py,sha256=4cCi3ZyaX48hLDvJQqW0G3a4z_vdzmh_jtJ-Jzil4SM,197
68
68
  tensorneko/optim/__init__.py,sha256=89XjYQICij8SkrW5iryfZgmbxcTDxA3hhVZTgR4588o,33
69
69
  tensorneko/optim/lr_scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -86,8 +86,8 @@ tensorneko/visualization/log_graph.py,sha256=NvOwWVc_petXWYdgaHosPFLa43sHBeacbYc
86
86
  tensorneko/visualization/matplotlib.py,sha256=xs9Ssc44ojZX65QU8-fftA7Ug_pBuZ3TBtM8vETNq9w,1568
87
87
  tensorneko/visualization/image_browser/__init__.py,sha256=AtykhAE3bXQS6SOWbeYFeeUE9ts9XOFMvrL31z0LoMg,63
88
88
  tensorneko/visualization/watcher/__init__.py,sha256=Nq752qIYvfRUZ8VctKQRSqhxh5KmFbWcqPfZlijVx6s,379
89
- tensorneko-0.3.20.dist-info/LICENSE,sha256=Vd75kwgJpVuMnCRBWasQzceMlXt4YQL13ikBLy8G5h0,1067
90
- tensorneko-0.3.20.dist-info/METADATA,sha256=8namXF_Slh-e8MZDm-v0t3YhURZZyXHng6VSQ4H1d8E,19972
91
- tensorneko-0.3.20.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
92
- tensorneko-0.3.20.dist-info/top_level.txt,sha256=sZHwlP0iyk7_zHuhRHzSBkdY9yEgyC48f6UVuZ6CvqE,11
93
- tensorneko-0.3.20.dist-info/RECORD,,
89
+ tensorneko-0.3.21.dist-info/LICENSE,sha256=Vd75kwgJpVuMnCRBWasQzceMlXt4YQL13ikBLy8G5h0,1067
90
+ tensorneko-0.3.21.dist-info/METADATA,sha256=Wc-2VJsFvNoT8f5d4rliimhmpxRAug5aVBmOL5TahQY,20813
91
+ tensorneko-0.3.21.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
92
+ tensorneko-0.3.21.dist-info/top_level.txt,sha256=sZHwlP0iyk7_zHuhRHzSBkdY9yEgyC48f6UVuZ6CvqE,11
93
+ tensorneko-0.3.21.dist-info/RECORD,,