tensorneko 0.3.19__tar.gz → 0.3.21__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 (101) hide show
  1. {tensorneko-0.3.19 → tensorneko-0.3.21}/PKG-INFO +39 -11
  2. {tensorneko-0.3.19 → tensorneko-0.3.21}/README.md +38 -10
  3. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/list_dataset.py +8 -1
  4. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/nested_dataset.py +8 -1
  5. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/round_robin_dataset.py +7 -1
  6. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/sampler/sequential_iter_sampler.py +8 -1
  7. tensorneko-0.3.21/src/tensorneko/msg/__init__.py +9 -0
  8. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/neko_model.py +3 -3
  9. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/neko_trainer.py +2 -0
  10. tensorneko-0.3.21/src/tensorneko/version.txt +1 -0
  11. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko.egg-info/PKG-INFO +39 -11
  12. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko.egg-info/requires.txt +2 -2
  13. tensorneko-0.3.19/src/tensorneko/msg/__init__.py +0 -3
  14. tensorneko-0.3.19/src/tensorneko/version.txt +0 -1
  15. {tensorneko-0.3.19 → tensorneko-0.3.21}/setup.cfg +0 -0
  16. {tensorneko-0.3.19 → tensorneko-0.3.21}/setup.py +0 -0
  17. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/__init__.py +0 -0
  18. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/__init__.py +0 -0
  19. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/auto_encoder.py +0 -0
  20. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/binary_classifier.py +0 -0
  21. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/gan.py +0 -0
  22. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/vqvae.py +0 -0
  23. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/arch/wgan.py +0 -0
  24. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/backend/__init__.py +0 -0
  25. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/__init__.py +0 -0
  26. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/display_metrics_callback.py +0 -0
  27. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/earlystop_lr.py +0 -0
  28. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/epoch_num_logger.py +0 -0
  29. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/epoch_time_logger.py +0 -0
  30. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/gpu_stats_logger.py +0 -0
  31. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/lr_logger.py +0 -0
  32. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/nil_callback.py +0 -0
  33. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/callback/system_stats_logger.py +0 -0
  34. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/__init__.py +0 -0
  35. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/dataset/sampler/__init__.py +0 -0
  36. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/debug/__init__.py +0 -0
  37. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/__init__.py +0 -0
  38. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/enum.py +0 -0
  39. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/fid.py +0 -0
  40. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/iou.py +0 -0
  41. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/psnr.py +0 -0
  42. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/secs.py +0 -0
  43. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/evaluation/ssim.py +0 -0
  44. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/__init__.py +0 -0
  45. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/mesh/__init__.py +0 -0
  46. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/mesh/mesh_reader.py +0 -0
  47. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/mesh/mesh_writer.py +0 -0
  48. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/reader.py +0 -0
  49. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/weight/__init__.py +0 -0
  50. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/weight/weight_reader.py +0 -0
  51. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/weight/weight_writer.py +0 -0
  52. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/io/writer.py +0 -0
  53. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/__init__.py +0 -0
  54. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/aggregation.py +0 -0
  55. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/attention.py +0 -0
  56. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/concatenate.py +0 -0
  57. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/conv.py +0 -0
  58. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/linear.py +0 -0
  59. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/log.py +0 -0
  60. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/masked_conv2d.py +0 -0
  61. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/noise.py +0 -0
  62. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/patching.py +0 -0
  63. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/positional_embedding.py +0 -0
  64. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/reshape.py +0 -0
  65. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/stack.py +0 -0
  66. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/layer/vector_quantizer.py +0 -0
  67. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/__init__.py +0 -0
  68. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/dense.py +0 -0
  69. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/gated_conv.py +0 -0
  70. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/inception.py +0 -0
  71. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/mlp.py +0 -0
  72. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/residual.py +0 -0
  73. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/module/transformer.py +0 -0
  74. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/neko_module.py +0 -0
  75. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/notebook/__init__.py +0 -0
  76. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/optim/__init__.py +0 -0
  77. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/optim/lr_scheduler/__init__.py +0 -0
  78. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/__init__.py +0 -0
  79. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/crop.py +0 -0
  80. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/enum.py +0 -0
  81. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/face_detector/__init__.py +0 -0
  82. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/pad.py +0 -0
  83. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/preprocess/resize.py +0 -0
  84. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/__init__.py +0 -0
  85. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/configuration.py +0 -0
  86. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/dispatched_misc.py +0 -0
  87. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/gc.py +0 -0
  88. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/misc.py +0 -0
  89. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/reproducibility.py +0 -0
  90. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/string_getter.py +0 -0
  91. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/util/type.py +0 -0
  92. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/visualization/__init__.py +0 -0
  93. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/visualization/image_browser/__init__.py +0 -0
  94. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/visualization/log_graph.py +0 -0
  95. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/visualization/matplotlib.py +0 -0
  96. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko/visualization/watcher/__init__.py +0 -0
  97. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko.egg-info/SOURCES.txt +0 -0
  98. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko.egg-info/dependency_links.txt +0 -0
  99. {tensorneko-0.3.19 → tensorneko-0.3.21}/src/tensorneko.egg-info/top_level.txt +0 -0
  100. {tensorneko-0.3.19 → tensorneko-0.3.21}/test/test_library_info.py +0 -0
  101. {tensorneko-0.3.19 → tensorneko-0.3.21}/test/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tensorneko
3
- Version: 0.3.19
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
@@ -22,7 +22,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
22
22
  <div align="center">
23
23
  <a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/tensorneko?style=flat-square"></a>
24
24
  <a href="https://pytorch.org/"><img src="https://img.shields.io/badge/PyTorch-%3E%3D1.9.0-EE4C2C?style=flat-square&logo=pytorch"></a>
25
- <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.0.*%20|%202.1.*%20|%202.2.*-792EE5?style=flat-square&logo=lightning"></a>
25
+ <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.*-792EE5?style=flat-square&logo=lightning"></a>
26
26
  </div>
27
27
 
28
28
  <div align="center">
@@ -59,7 +59,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
59
59
 
60
60
  Then you can use the CLI tools `tensorneko` in the terminal.
61
61
 
62
- ## Neko Layers, Modules and Architectures
62
+ ## Layers, Modules and Architectures
63
63
 
64
64
  Build an MLP with linear layers. The activation and normalization will be placed in the hidden layers.
65
65
 
@@ -148,7 +148,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
148
148
  # torch.Size([1])
149
149
  ```
150
150
 
151
- ## Neko IO
151
+ ## IO
152
152
 
153
153
  Easily load and save different modal data.
154
154
 
@@ -198,7 +198,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
198
198
  Besides, the read/write for `mat` and `pickle` files is also supported.
199
199
 
200
200
 
201
- ## Neko preprocessing
201
+ ## Preprocessing
202
202
 
203
203
  ```python
204
204
  import tensorneko as neko
@@ -225,7 +225,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
225
225
  - `resample_video_fps`
226
226
  - `mp32wav`
227
227
 
228
- ## Neko Visualization
228
+ ## Visualization
229
229
 
230
230
  ### Variable Web Watcher
231
231
  Start a web server to watch the variable status when the program (e.g. training, inference, data preprocessing) is running.
@@ -376,14 +376,14 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
376
376
  trainer.fit(model, dm)
377
377
  ```
378
378
 
379
- ## Neko Callbacks
379
+ ## Callbacks
380
380
 
381
381
  Some simple but useful pytorch-lightning callbacks are provided.
382
382
 
383
383
  - `DisplayMetricsCallback`
384
384
  - `EarlyStoppingLR`: Early stop training when learning rate reaches threshold.
385
385
 
386
- ## Neko Notebook Helpers
386
+ ## Notebook Helpers
387
387
  Here are some helper functions to better interact with Jupyter Notebook.
388
388
  ```python
389
389
  import tensorneko as neko
@@ -395,7 +395,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
395
395
  neko.notebook.display.code("path/to/code.java")
396
396
  ```
397
397
 
398
- ## Neko Debug Tools
398
+ ## Debug Tools
399
399
 
400
400
  Get the default values from `ArgumentParser` args. It's convenient to use this in the notebook.
401
401
  ```python
@@ -411,7 +411,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
411
411
  print(args.accumulate) # <function sum at ...>
412
412
  ```
413
413
 
414
- ## Neko Evaluation
414
+ ## Evaluation
415
415
 
416
416
  Some metrics function for evaluation are provided.
417
417
 
@@ -422,8 +422,36 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
422
422
  - `ssim_video`
423
423
  - `ssim_image`
424
424
 
425
+ ## Message (Access to other services)
425
426
 
426
- ## Neko Utilities
427
+ ### Gotify
428
+
429
+ Send a message to the Gotify server.
430
+
431
+ The title, URL and APP_TOKEN is the environment variable `GOTIFY_TITLE`, `GOTIFY_URL` and `GOTIFY_TOKEN`, or overwritten
432
+ in the function arguments.
433
+
434
+ ```python
435
+ from tensorneko.msg import gotify
436
+ gotify.push("This is a test message", "<URL>", "<APP_TOKEN>")
437
+ # then the message will be sent to the Gotify server.
438
+ # title = "<HOST_NAME>", message = "This is a test message", priority = 0
439
+ ```
440
+
441
+ ### Postgres
442
+
443
+ Require the `psycopg` package. Provide one single function to execute one SQL query with a temp connection.
444
+
445
+ The database URL is the environment variable `DB_URL`, or overwritten in the function arguments.
446
+ ```python
447
+ from tensorneko.msg import postgres
448
+ result = postgres.execute("<SQL>", "<DB_URL>")
449
+ # also async version is provided
450
+ result = await postgres.execute_async("<SQL>", "<DB_URL>")
451
+ ```
452
+
453
+
454
+ ## Utilities
427
455
 
428
456
  ### Misc functions
429
457
 
@@ -12,7 +12,7 @@
12
12
  <div align="center">
13
13
  <a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/tensorneko?style=flat-square"></a>
14
14
  <a href="https://pytorch.org/"><img src="https://img.shields.io/badge/PyTorch-%3E%3D1.9.0-EE4C2C?style=flat-square&logo=pytorch"></a>
15
- <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.0.*%20|%202.1.*%20|%202.2.*-792EE5?style=flat-square&logo=lightning"></a>
15
+ <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.*-792EE5?style=flat-square&logo=lightning"></a>
16
16
  </div>
17
17
 
18
18
  <div align="center">
@@ -49,7 +49,7 @@ pipx install tensorneko_tool # or `pip install tensorneko_tool`
49
49
 
50
50
  Then you can use the CLI tools `tensorneko` in the terminal.
51
51
 
52
- ## Neko Layers, Modules and Architectures
52
+ ## Layers, Modules and Architectures
53
53
 
54
54
  Build an MLP with linear layers. The activation and normalization will be placed in the hidden layers.
55
55
 
@@ -138,7 +138,7 @@ print(f(torch.rand(16)).shape)
138
138
  # torch.Size([1])
139
139
  ```
140
140
 
141
- ## Neko IO
141
+ ## IO
142
142
 
143
143
  Easily load and save different modal data.
144
144
 
@@ -188,7 +188,7 @@ neko.io.write.json("path/to/json.json", json_obj)
188
188
  Besides, the read/write for `mat` and `pickle` files is also supported.
189
189
 
190
190
 
191
- ## Neko preprocessing
191
+ ## Preprocessing
192
192
 
193
193
  ```python
194
194
  import tensorneko as neko
@@ -215,7 +215,7 @@ if `ffmpeg` is available, you can use below ffmpeg wrappers.
215
215
  - `resample_video_fps`
216
216
  - `mp32wav`
217
217
 
218
- ## Neko Visualization
218
+ ## Visualization
219
219
 
220
220
  ### Variable Web Watcher
221
221
  Start a web server to watch the variable status when the program (e.g. training, inference, data preprocessing) is running.
@@ -366,14 +366,14 @@ trainer = neko.NekoTrainer(log_every_n_steps=100, gpus=1, logger=model.name, pre
366
366
  trainer.fit(model, dm)
367
367
  ```
368
368
 
369
- ## Neko Callbacks
369
+ ## Callbacks
370
370
 
371
371
  Some simple but useful pytorch-lightning callbacks are provided.
372
372
 
373
373
  - `DisplayMetricsCallback`
374
374
  - `EarlyStoppingLR`: Early stop training when learning rate reaches threshold.
375
375
 
376
- ## Neko Notebook Helpers
376
+ ## Notebook Helpers
377
377
  Here are some helper functions to better interact with Jupyter Notebook.
378
378
  ```python
379
379
  import tensorneko as neko
@@ -385,7 +385,7 @@ neko.notebook.display.audio("path/to/audio.wav")
385
385
  neko.notebook.display.code("path/to/code.java")
386
386
  ```
387
387
 
388
- ## Neko Debug Tools
388
+ ## Debug Tools
389
389
 
390
390
  Get the default values from `ArgumentParser` args. It's convenient to use this in the notebook.
391
391
  ```python
@@ -401,7 +401,7 @@ print(args.integers) # [1, 2, 3]
401
401
  print(args.accumulate) # <function sum at ...>
402
402
  ```
403
403
 
404
- ## Neko Evaluation
404
+ ## Evaluation
405
405
 
406
406
  Some metrics function for evaluation are provided.
407
407
 
@@ -412,8 +412,36 @@ Some metrics function for evaluation are provided.
412
412
  - `ssim_video`
413
413
  - `ssim_image`
414
414
 
415
+ ## Message (Access to other services)
415
416
 
416
- ## Neko Utilities
417
+ ### Gotify
418
+
419
+ Send a message to the Gotify server.
420
+
421
+ The title, URL and APP_TOKEN is the environment variable `GOTIFY_TITLE`, `GOTIFY_URL` and `GOTIFY_TOKEN`, or overwritten
422
+ in the function arguments.
423
+
424
+ ```python
425
+ from tensorneko.msg import gotify
426
+ gotify.push("This is a test message", "<URL>", "<APP_TOKEN>")
427
+ # then the message will be sent to the Gotify server.
428
+ # title = "<HOST_NAME>", message = "This is a test message", priority = 0
429
+ ```
430
+
431
+ ### Postgres
432
+
433
+ Require the `psycopg` package. Provide one single function to execute one SQL query with a temp connection.
434
+
435
+ The database URL is the environment variable `DB_URL`, or overwritten in the function arguments.
436
+ ```python
437
+ from tensorneko.msg import postgres
438
+ result = postgres.execute("<SQL>", "<DB_URL>")
439
+ # also async version is provided
440
+ result = await postgres.execute_async("<SQL>", "<DB_URL>")
441
+ ```
442
+
443
+
444
+ ## Utilities
417
445
 
418
446
  ### Misc functions
419
447
 
@@ -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]):
@@ -0,0 +1,9 @@
1
+ from tensorneko_util.msg import gotify
2
+
3
+ __all__ = ["gotify"]
4
+
5
+ try:
6
+ from tensorneko_util.msg import postgres
7
+ __all__.append("postgres")
8
+ except ImportError:
9
+ pass
@@ -214,12 +214,12 @@ class NekoModel(LightningModule, NekoModule):
214
214
  for key in outputs[0].keys():
215
215
  getter = summarize_dict_by(key, torch.mean)
216
216
  value = getter(outputs)
217
- self.history[-1]["val_" + key] = value
217
+ self.history[-1]["val_" + key.split("/")[-1]] = value
218
218
  if self.logger is not None:
219
219
  self.logger.log_metrics({key: value}, step=self.trainer.global_step)
220
220
  self.log(key, value, on_epoch=True, on_step=False, logger=False, sync_dist=self.distributed)
221
- self.log(f"val_{key}", value, on_epoch=True, on_step=False, logger=False, prog_bar=True,
222
- sync_dist=self.distributed)
221
+ self.log(f"val_{key.split('/')[-1]}", value, on_epoch=True, on_step=False, logger=False,
222
+ prog_bar=True, sync_dist=self.distributed)
223
223
 
224
224
  def log_on_training_step_end(self, output: STEP_OUTPUT) -> None:
225
225
  """Log the training step outputs"""
@@ -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"),
@@ -0,0 +1 @@
1
+ 0.3.21
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tensorneko
3
- Version: 0.3.19
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
@@ -22,7 +22,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
22
22
  <div align="center">
23
23
  <a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/tensorneko?style=flat-square"></a>
24
24
  <a href="https://pytorch.org/"><img src="https://img.shields.io/badge/PyTorch-%3E%3D1.9.0-EE4C2C?style=flat-square&logo=pytorch"></a>
25
- <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.0.*%20|%202.1.*%20|%202.2.*-792EE5?style=flat-square&logo=lightning"></a>
25
+ <a href="https://www.pytorchlightning.ai/"><img src="https://img.shields.io/badge/Lightning-2.*-792EE5?style=flat-square&logo=lightning"></a>
26
26
  </div>
27
27
 
28
28
  <div align="center">
@@ -59,7 +59,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
59
59
 
60
60
  Then you can use the CLI tools `tensorneko` in the terminal.
61
61
 
62
- ## Neko Layers, Modules and Architectures
62
+ ## Layers, Modules and Architectures
63
63
 
64
64
  Build an MLP with linear layers. The activation and normalization will be placed in the hidden layers.
65
65
 
@@ -148,7 +148,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
148
148
  # torch.Size([1])
149
149
  ```
150
150
 
151
- ## Neko IO
151
+ ## IO
152
152
 
153
153
  Easily load and save different modal data.
154
154
 
@@ -198,7 +198,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
198
198
  Besides, the read/write for `mat` and `pickle` files is also supported.
199
199
 
200
200
 
201
- ## Neko preprocessing
201
+ ## Preprocessing
202
202
 
203
203
  ```python
204
204
  import tensorneko as neko
@@ -225,7 +225,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
225
225
  - `resample_video_fps`
226
226
  - `mp32wav`
227
227
 
228
- ## Neko Visualization
228
+ ## Visualization
229
229
 
230
230
  ### Variable Web Watcher
231
231
  Start a web server to watch the variable status when the program (e.g. training, inference, data preprocessing) is running.
@@ -376,14 +376,14 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
376
376
  trainer.fit(model, dm)
377
377
  ```
378
378
 
379
- ## Neko Callbacks
379
+ ## Callbacks
380
380
 
381
381
  Some simple but useful pytorch-lightning callbacks are provided.
382
382
 
383
383
  - `DisplayMetricsCallback`
384
384
  - `EarlyStoppingLR`: Early stop training when learning rate reaches threshold.
385
385
 
386
- ## Neko Notebook Helpers
386
+ ## Notebook Helpers
387
387
  Here are some helper functions to better interact with Jupyter Notebook.
388
388
  ```python
389
389
  import tensorneko as neko
@@ -395,7 +395,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
395
395
  neko.notebook.display.code("path/to/code.java")
396
396
  ```
397
397
 
398
- ## Neko Debug Tools
398
+ ## Debug Tools
399
399
 
400
400
  Get the default values from `ArgumentParser` args. It's convenient to use this in the notebook.
401
401
  ```python
@@ -411,7 +411,7 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
411
411
  print(args.accumulate) # <function sum at ...>
412
412
  ```
413
413
 
414
- ## Neko Evaluation
414
+ ## Evaluation
415
415
 
416
416
  Some metrics function for evaluation are provided.
417
417
 
@@ -422,8 +422,36 @@ Description: <h1 style="text-align: center">TensorNeko</h1>
422
422
  - `ssim_video`
423
423
  - `ssim_image`
424
424
 
425
+ ## Message (Access to other services)
425
426
 
426
- ## Neko Utilities
427
+ ### Gotify
428
+
429
+ Send a message to the Gotify server.
430
+
431
+ The title, URL and APP_TOKEN is the environment variable `GOTIFY_TITLE`, `GOTIFY_URL` and `GOTIFY_TOKEN`, or overwritten
432
+ in the function arguments.
433
+
434
+ ```python
435
+ from tensorneko.msg import gotify
436
+ gotify.push("This is a test message", "<URL>", "<APP_TOKEN>")
437
+ # then the message will be sent to the Gotify server.
438
+ # title = "<HOST_NAME>", message = "This is a test message", priority = 0
439
+ ```
440
+
441
+ ### Postgres
442
+
443
+ Require the `psycopg` package. Provide one single function to execute one SQL query with a temp connection.
444
+
445
+ The database URL is the environment variable `DB_URL`, or overwritten in the function arguments.
446
+ ```python
447
+ from tensorneko.msg import postgres
448
+ result = postgres.execute("<SQL>", "<DB_URL>")
449
+ # also async version is provided
450
+ result = await postgres.execute_async("<SQL>", "<DB_URL>")
451
+ ```
452
+
453
+
454
+ ## Utilities
427
455
 
428
456
  ### Misc functions
429
457
 
@@ -2,7 +2,7 @@ av>=8.0.3
2
2
  einops>=0.3.0
3
3
  numpy>=1.20.1
4
4
  pillow>=8.1
5
- tensorneko_util==0.3.19
5
+ tensorneko_util==0.3.21
6
6
  torch>=1.9.0
7
7
  torchaudio>=0.9.0
8
8
  torchmetrics>=0.7.3
@@ -12,5 +12,5 @@ torchvision>=0.10.0
12
12
  pysoundfile>=0.9.0
13
13
 
14
14
  [lightning]
15
- lightning<2.2,>=2.0
15
+ lightning<3,>=2.0
16
16
  tensorboard>=2.0.0
@@ -1,3 +0,0 @@
1
- from tensorneko_util.msg import push_gotify
2
-
3
- __all__ = ["push_gotify"]
@@ -1 +0,0 @@
1
- 0.3.19
File without changes
File without changes