Skip to main content

A Python library for managing YOLO datasets, allowing seamless conversion between filesystem-based datasets and PostgreSQL storage. Features include inserting datasets into a database, retrieving and rebuilding datasets, and preserving YOLO-compliant folder structures.

Project description

YoloDatasetDBManager

YoloDatasetDBManager is a Python library designed to efficiently manage YOLO datasets stored in a PostgreSQL database. It enables saving images and their associated annotations, rebuilding folder structures from the database, and performing flexible operations on datasets.

📥 Installation

Ensure Python 3.11+ is installed.

Via pip

pip install YoloDatasetDBManager

Via pdm

If you use PDM, run:

pdm add YoloDatasetDBManager

🚀 Usage

Here’s a complete example of how to use YoloDatasetDBManager:

import os
from pathlib import Path

from yolo_dataset_db_manager.db import PostgreSQLManager
from yolo_dataset_db_manager.processor import YoloDatasetProcessor
from yolo_dataset_db_manager.settings import ParamsConnection

# Define the base directory for the project
BASE_DIR = Path(__file__).parent.parent

# Specify the path to the dataset folder, where the YOLO data is stored
dataset_path = BASE_DIR / "data"

# Specify the output directory where the reconstructed dataset will be saved
output_path = BASE_DIR / "datasets_out"

# Configure the connection parameters for the PostgreSQL database
params = ParamsConnection(
    dbname=os.getenv("POSTGRES_DB"),
    user=os.getenv("POSTGRES_USER"),
    password=os.getenv("POSTGRES_PASSWORD"),
    host=os.getenv("POSTGRES_HOST"),
    port=os.getenv("POSTGRES_PORT"),
)

# Initialize the PostgreSQL manager and create the YOLO dataset table if it doesn't exist
with PostgreSQLManager(params, table_name="yolo_dataset", create_table=True) as db:
    process = YoloDatasetProcessor(
        db, dataset_path=dataset_path, output_path=output_path
    )

    # Save the dataset (images and annotations) from the local folder to the database
    process.save_dataset()
    db.commit()  # Commit the transaction to ensure data is stored in the database

    # Rebuild the dataset structure from the database into the output folder
    process.rebuild_dataset()

🛠️ Contribution

Contributions are welcome! Follow these steps to get involved:

  1. Fork the project on GitHub.
  2. Clone the repository:
    git clone https://github.com/Macktireh/YoloDatasetDBManager.git
    
  3. Install development dependencies with pdm:
    pdm install
    
  4. Create a branch for your changes:
    git checkout -b feature/my-feature
    
  5. Run tests:
    pdm run test
    
  6. Submit a pull request when your work is ready.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yolodatasetdbmanager-0.2.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yolodatasetdbmanager-0.2.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file yolodatasetdbmanager-0.2.1.tar.gz.

File metadata

  • Download URL: yolodatasetdbmanager-0.2.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.20.1 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for yolodatasetdbmanager-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e7d9f0b6efff994c1ff033fc43a3032ba0451078b5740edf64aee555c783d68b
MD5 d5952c59bc059146f9872dde22e7607d
BLAKE2b-256 ffa50e870afa3276a8ede9cfdbef9c8c5a31be61f843959939ceb7e8fba4c5a1

See more details on using hashes here.

File details

Details for the file yolodatasetdbmanager-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: yolodatasetdbmanager-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.20.1 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for yolodatasetdbmanager-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 922077db17d9e3baf6aa47cbb83ccbb0913e17eb81f5c6eba26451061218e7df
MD5 8e6418a44fd067c71762584a322c262e
BLAKE2b-256 15a039abc20c5a4408a1b4f4c3494371e9ffd090f3896bdeb92d534c089fd9be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page