ditli 0.0.1__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.
- ditli/__init__.py +1 -0
- ditli/config.py +32 -0
- ditli/dataset.py +29 -0
- ditli/features.py +29 -0
- ditli/modeling/__init__.py +0 -0
- ditli/modeling/predict.py +30 -0
- ditli/modeling/train.py +30 -0
- ditli/plots.py +29 -0
- ditli-0.0.1.dist-info/METADATA +81 -0
- ditli-0.0.1.dist-info/RECORD +12 -0
- ditli-0.0.1.dist-info/WHEEL +4 -0
- ditli-0.0.1.dist-info/licenses/LICENSE +10 -0
ditli/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from ditli import config # noqa: F401
|
ditli/config.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
from loguru import logger
|
|
5
|
+
|
|
6
|
+
# Load environment variables from .env file if it exists
|
|
7
|
+
load_dotenv()
|
|
8
|
+
|
|
9
|
+
# Paths
|
|
10
|
+
PROJ_ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
+
logger.info(f"PROJ_ROOT path is: {PROJ_ROOT}")
|
|
12
|
+
|
|
13
|
+
DATA_DIR = PROJ_ROOT / "data"
|
|
14
|
+
RAW_DATA_DIR = DATA_DIR / "raw"
|
|
15
|
+
INTERIM_DATA_DIR = DATA_DIR / "interim"
|
|
16
|
+
PROCESSED_DATA_DIR = DATA_DIR / "processed"
|
|
17
|
+
EXTERNAL_DATA_DIR = DATA_DIR / "external"
|
|
18
|
+
|
|
19
|
+
MODELS_DIR = PROJ_ROOT / "models"
|
|
20
|
+
|
|
21
|
+
REPORTS_DIR = PROJ_ROOT / "reports"
|
|
22
|
+
FIGURES_DIR = REPORTS_DIR / "figures"
|
|
23
|
+
|
|
24
|
+
# If tqdm is installed, configure loguru with tqdm.write
|
|
25
|
+
# https://github.com/Delgan/loguru/issues/135
|
|
26
|
+
try:
|
|
27
|
+
from tqdm import tqdm
|
|
28
|
+
|
|
29
|
+
logger.remove(0)
|
|
30
|
+
logger.add(lambda msg: tqdm.write(msg, end=""), colorize=True)
|
|
31
|
+
except ModuleNotFoundError:
|
|
32
|
+
pass
|
ditli/dataset.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from loguru import logger
|
|
4
|
+
from tqdm import tqdm
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from ditli.config import PROCESSED_DATA_DIR, RAW_DATA_DIR
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
|
|
15
|
+
input_path: Path = RAW_DATA_DIR / "dataset.csv",
|
|
16
|
+
output_path: Path = PROCESSED_DATA_DIR / "dataset.csv",
|
|
17
|
+
# ----------------------------------------------
|
|
18
|
+
):
|
|
19
|
+
# ---- REPLACE THIS WITH YOUR OWN CODE ----
|
|
20
|
+
logger.info("Processing dataset...")
|
|
21
|
+
for i in tqdm(range(10), total=10):
|
|
22
|
+
if i == 5:
|
|
23
|
+
logger.info("Something happened for iteration 5.")
|
|
24
|
+
logger.success("Processing dataset complete.")
|
|
25
|
+
# -----------------------------------------
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
app()
|
ditli/features.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from loguru import logger
|
|
4
|
+
from tqdm import tqdm
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from ditli.config import PROCESSED_DATA_DIR
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
|
|
15
|
+
input_path: Path = PROCESSED_DATA_DIR / "dataset.csv",
|
|
16
|
+
output_path: Path = PROCESSED_DATA_DIR / "features.csv",
|
|
17
|
+
# -----------------------------------------
|
|
18
|
+
):
|
|
19
|
+
# ---- REPLACE THIS WITH YOUR OWN CODE ----
|
|
20
|
+
logger.info("Generating features from dataset...")
|
|
21
|
+
for i in tqdm(range(10), total=10):
|
|
22
|
+
if i == 5:
|
|
23
|
+
logger.info("Something happened for iteration 5.")
|
|
24
|
+
logger.success("Features generation complete.")
|
|
25
|
+
# -----------------------------------------
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
app()
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from loguru import logger
|
|
4
|
+
from tqdm import tqdm
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from ditli.config import MODELS_DIR, PROCESSED_DATA_DIR
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
|
|
15
|
+
features_path: Path = PROCESSED_DATA_DIR / "test_features.csv",
|
|
16
|
+
model_path: Path = MODELS_DIR / "model.pkl",
|
|
17
|
+
predictions_path: Path = PROCESSED_DATA_DIR / "test_predictions.csv",
|
|
18
|
+
# -----------------------------------------
|
|
19
|
+
):
|
|
20
|
+
# ---- REPLACE THIS WITH YOUR OWN CODE ----
|
|
21
|
+
logger.info("Performing inference for model...")
|
|
22
|
+
for i in tqdm(range(10), total=10):
|
|
23
|
+
if i == 5:
|
|
24
|
+
logger.info("Something happened for iteration 5.")
|
|
25
|
+
logger.success("Inference complete.")
|
|
26
|
+
# -----------------------------------------
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
app()
|
ditli/modeling/train.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from loguru import logger
|
|
4
|
+
from tqdm import tqdm
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from ditli.config import MODELS_DIR, PROCESSED_DATA_DIR
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
|
|
15
|
+
features_path: Path = PROCESSED_DATA_DIR / "features.csv",
|
|
16
|
+
labels_path: Path = PROCESSED_DATA_DIR / "labels.csv",
|
|
17
|
+
model_path: Path = MODELS_DIR / "model.pkl",
|
|
18
|
+
# -----------------------------------------
|
|
19
|
+
):
|
|
20
|
+
# ---- REPLACE THIS WITH YOUR OWN CODE ----
|
|
21
|
+
logger.info("Training some model...")
|
|
22
|
+
for i in tqdm(range(10), total=10):
|
|
23
|
+
if i == 5:
|
|
24
|
+
logger.info("Something happened for iteration 5.")
|
|
25
|
+
logger.success("Modeling training complete.")
|
|
26
|
+
# -----------------------------------------
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
app()
|
ditli/plots.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from loguru import logger
|
|
4
|
+
from tqdm import tqdm
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from ditli.config import FIGURES_DIR, PROCESSED_DATA_DIR
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
|
|
15
|
+
input_path: Path = PROCESSED_DATA_DIR / "dataset.csv",
|
|
16
|
+
output_path: Path = FIGURES_DIR / "plot.png",
|
|
17
|
+
# -----------------------------------------
|
|
18
|
+
):
|
|
19
|
+
# ---- REPLACE THIS WITH YOUR OWN CODE ----
|
|
20
|
+
logger.info("Generating plot from data...")
|
|
21
|
+
for i in tqdm(range(10), total=10):
|
|
22
|
+
if i == 5:
|
|
23
|
+
logger.info("Something happened for iteration 5.")
|
|
24
|
+
logger.success("Plot generation complete.")
|
|
25
|
+
# -----------------------------------------
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
app()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ditli
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A small from-scratch implementation of a diffusion transformer (DiT).
|
|
5
|
+
Author: James Kennedy
|
|
6
|
+
Requires-Python: ~=3.12.0
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: loguru
|
|
12
|
+
Requires-Dist: mkdocs
|
|
13
|
+
Requires-Dist: pip
|
|
14
|
+
Requires-Dist: pytest
|
|
15
|
+
Requires-Dist: python-dotenv
|
|
16
|
+
Requires-Dist: ruff
|
|
17
|
+
Requires-Dist: tqdm
|
|
18
|
+
Requires-Dist: typer
|
|
19
|
+
|
|
20
|
+
# DiTli
|
|
21
|
+
|
|
22
|
+
<a target="_blank" href="https://cookiecutter-data-science.drivendata.org/">
|
|
23
|
+
<img src="https://img.shields.io/badge/CCDS-Project%20template-328F97?logo=cookiecutter" />
|
|
24
|
+
</a>
|
|
25
|
+
|
|
26
|
+
A small from-scratch implementation of a diffusion transformer (DiT).
|
|
27
|
+
|
|
28
|
+
## Project Organization
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
├── LICENSE <- Open-source license if one is chosen
|
|
32
|
+
├── Makefile <- Makefile with convenience commands like `make data` or `make train`
|
|
33
|
+
├── README.md <- The top-level README for developers using this project.
|
|
34
|
+
├── data
|
|
35
|
+
│ ├── external <- Data from third party sources.
|
|
36
|
+
│ ├── interim <- Intermediate data that has been transformed.
|
|
37
|
+
│ ├── processed <- The final, canonical data sets for modeling.
|
|
38
|
+
│ └── raw <- The original, immutable data dump.
|
|
39
|
+
│
|
|
40
|
+
├── docs <- A default mkdocs project; see www.mkdocs.org for details
|
|
41
|
+
│
|
|
42
|
+
├── models <- Trained and serialized models, model predictions, or model summaries
|
|
43
|
+
│
|
|
44
|
+
├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering),
|
|
45
|
+
│ the creator's initials, and a short `-` delimited description, e.g.
|
|
46
|
+
│ `1.0-jqp-initial-data-exploration`.
|
|
47
|
+
│
|
|
48
|
+
├── pyproject.toml <- Project configuration file with package metadata for
|
|
49
|
+
│ ditli and configuration for tools like black
|
|
50
|
+
│
|
|
51
|
+
├── references <- Data dictionaries, manuals, and all other explanatory materials.
|
|
52
|
+
│
|
|
53
|
+
├── reports <- Generated analysis as HTML, PDF, LaTeX, etc.
|
|
54
|
+
│ └── figures <- Generated graphics and figures to be used in reporting
|
|
55
|
+
│
|
|
56
|
+
├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
|
|
57
|
+
│ generated with `pip freeze > requirements.txt`
|
|
58
|
+
│
|
|
59
|
+
├── setup.cfg <- Configuration file for flake8
|
|
60
|
+
│
|
|
61
|
+
└── ditli <- Source code for use in this project.
|
|
62
|
+
│
|
|
63
|
+
├── __init__.py <- Makes ditli a Python module
|
|
64
|
+
│
|
|
65
|
+
├── config.py <- Store useful variables and configuration
|
|
66
|
+
│
|
|
67
|
+
├── dataset.py <- Scripts to download or generate data
|
|
68
|
+
│
|
|
69
|
+
├── features.py <- Code to create features for modeling
|
|
70
|
+
│
|
|
71
|
+
├── modeling
|
|
72
|
+
│ ├── __init__.py
|
|
73
|
+
│ ├── predict.py <- Code to run model inference with trained models
|
|
74
|
+
│ └── train.py <- Code to train models
|
|
75
|
+
│
|
|
76
|
+
└── plots.py <- Code to create visualizations
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
--------
|
|
80
|
+
|
|
81
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
ditli/__init__.py,sha256=9qw1ewBqqTQdSWEaX2K8jS69m3v-DtvGl20hP1qLhqw,39
|
|
2
|
+
ditli/config.py,sha256=JuUBHDW2UQvr88Xzpr6VZn8b5YCRGUdJLVMoB8tnZYY,819
|
|
3
|
+
ditli/dataset.py,sha256=cYiQYA--2j6q-W-WIBxN7x9qSxLj5HrN1_yfmWDSd-Q,765
|
|
4
|
+
ditli/features.py,sha256=MdEDCnxQoJ3zd9NyA1XA-QMrBbTIrmZyicbNdvU4OVg,768
|
|
5
|
+
ditli/plots.py,sha256=PX6KtgMOMKDM_QPFLKmCooq_H573xmz9cq5k_WfHLNs,759
|
|
6
|
+
ditli/modeling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
ditli/modeling/predict.py,sha256=ik92lpcVwDX2dCXAR-SniU_JuWumnqBCLwqS5f0fUIw,839
|
|
8
|
+
ditli/modeling/train.py,sha256=Z99WR8S8GwTQGBpycLEVpMPnZGkNlCls8oPcrWswdVg,816
|
|
9
|
+
ditli-0.0.1.dist-info/licenses/LICENSE,sha256=LqHpswN2yLiWuFkxyioCXdA8bfU1UGRnLbLtODEIROU,1082
|
|
10
|
+
ditli-0.0.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
11
|
+
ditli-0.0.1.dist-info/METADATA,sha256=80xKc1_NSLaiyhN2kQSxNQxLERyqDmATYfew9CcSz1I,3245
|
|
12
|
+
ditli-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
The MIT License (MIT)
|
|
3
|
+
Copyright (c) 2026, James Kennedy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|