A package to use the OstrisTraining
Project description
Libs-Ostris (TechTrash_OstrisTraining)
This package provides a small Python wrapper around an Ostris training workflow.
The main entrypoint is OstrisTraining.train().
What train() does
- Download + prepare dataset from a public ZIP URL
- ZIP root must contain image files + matching caption files (
.txt) - Example pair:
photobelle.png+photobelle.txt - Output: files are normalized to
image_0.<ext>,image_0.txt,image_1.<ext>,image_1.txt, ...
- ZIP root must contain image files + matching caption files (
- Write config YAML from a string into a deterministic file:
{absolute_path_racine}/config-{user_name}.yaml- Before writing, we patch the YAML automatically:
config.nameis forced touser_nameconfig.process[*].datasets[*].folder_pathis forced to the prepared dataset folderconfig.process[*].training_folderis forced toabsolute_path_outputconfig.process[*].trigger_wordis forced to:"ohwx woman"ifgender="woman""ohwx man"ifgender="man"
- Run training
- Calls
run.pyinsideabsolute_path_ostriswith the generated config path
- Calls
- Cleanup on success
- Deletes the prepared dataset folder + generated config yaml
- Keeps the produced
.safetensorsmodel file
Install (local dev)
From this folder:
pip install -e .
Usage (recommended)
The best reference is src/ostristraining/example.py.
You can run it directly after installing:
python3 -m ostristraining.example
Or copy/paste this minimal usage:
from ostristraining.main import OstrisTraining
trainer = OstrisTraining(
user_name="demo_user",
absolute_path_ostris="/tmp/ostris_project",
absolute_path_racine="/tmp/ostris_runs",
gender="woman", # "woman" or "man"
absolute_path_output="/tmp/ostris_output",
)
# Public ZIP URL containing images + captions at the ZIP root.
url_zip_dataset = "https://example.com/dataset.zip"
# YAML config must be a STRING. Newlines + indentation matter in YAML.
# Tip: start from `src/ostristraining/example_config.yaml` and customize it.
config_yaml_content = """
job: "extension"
config:
name: "will_be_overwritten"
process:
- type: "diffusion_trainer"
trigger_word: "will_be_overwritten"
datasets:
- folder_path: "will_be_overwritten"
"""
trained_model_path = trainer.train(
url_zip_dataset=url_zip_dataset,
config_yaml_content=config_yaml_content,
)
print(trained_model_path)
Logging
This library uses Python logging (logger name: ostristraining).
In your app/handler you typically enable logs like:
import logging
logging.basicConfig(level=logging.INFO)
Dataset ZIP format (important)
At the root of the ZIP, you must have:
- images:
.png,.jpg,.jpeg,.webp,.bmp,.gif - captions:
.txt
And each image must have a caption with the same base name:
photo001.png+photo001.txtphoto002.jpg+photo002.txt
If an image has no matching .txt, it is skipped.
Config patching rules (quick recap)
If you send a config similar to src/ostristraining/example_config.yaml, the library will ensure:
config.name == user_nameconfig.process[*].datasets[*].folder_path == {absolute_path_ostris}/dataset/{user_name}config.process[*].training_folder == absolute_path_outputconfig.process[*].trigger_word == "ohwx woman" | "ohwx man"based ongender
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file techtrash_ostristraining-0.1.0.tar.gz.
File metadata
- Download URL: techtrash_ostristraining-0.1.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a7f2aeced289fe4667375372e5d7f29f25fa9ee0e9cec19ac17d3d881c389f8
|
|
| MD5 |
73670b6c269ae420c85eb6c1aac693b5
|
|
| BLAKE2b-256 |
b09b24107a96e8bd3deaa054ff97cfebf51b74d955282fccaa0911b373bc0a5d
|
File details
Details for the file techtrash_ostristraining-0.1.0-py3-none-any.whl.
File metadata
- Download URL: techtrash_ostristraining-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17ea906990d196c0468a84aba3c2b5f8f3c4b11279359644d24be8959ebeef18
|
|
| MD5 |
3f75bd4d1a3174ba49a374c7080019ca
|
|
| BLAKE2b-256 |
014839eb22bb80b2b9316497eb0050ea848ebf8f161300a5cf928debfd3d0034
|