Metadata-Version: 2.4
Name: klygo
Version: 0.1.0
Summary: Add your description here
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: build>=1.5.1
Requires-Dist: numpy>=2.5.1
Requires-Dist: opencv-python>=5.0.0.93
Requires-Dist: pillow>=12.3.0
Requires-Dist: pydantic>=2.13.4
Requires-Dist: python-box>=7.4.1
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: ruamel-yaml>=0.19.1
Requires-Dist: tomlkit>=0.15.0
Requires-Dist: torch>=2.13.0
Requires-Dist: tqdm>=4.68.4
Requires-Dist: transformers>=5.13.0
Requires-Dist: twine>=6.2.0

# klygo

Thư viện Python hỗ trợ nén/giải nén file, xử lý bộ dữ liệu YOLO, đọc/ghi file cấu hình và nhận diện vật thể zero-shot.

---

## Tính năng chính

- klygo.archive: Các thao tác với file nén ZIP (nén, giải nén, tìm kiếm, gộp, chia, thêm, xóa file) hỗ trợ hiển thị thanh tiến trình.
- klygo.datasets: Các công cụ quản lý và xử lý bộ dữ liệu YOLO (phân chia train/val/test, chia lại tỷ lệ tại chỗ, gộp nhiều dataset có ánh xạ lại class ID, và tách dataset theo class/tỷ lệ con).
- klygo.io: Đọc và ghi các file cấu hình YAML, JSON, TOML, tự động tạo thư mục, tự động phân giải đường dẫn tương đối và truy cập dạng thuộc tính qua Box.
- klygo.models: Lớp hỗ trợ nhận diện vật thể zero-shot (dựa trên Grounding DINO) trên ảnh và video, tự động xuất dữ liệu theo định dạng YOLO.

---

## Cấu trúc thư mục

```
klygo/
├── archive/        # Các tiện ích nén và giải nén
├── datasets/       # Công cụ quản lý và phân chia bộ dữ liệu YOLO
├── io/             # Bộ đọc/ghi cấu hình YAML, JSON, TOML
├── models/         # Lớp nhận diện vật thể (Kernel)
└── validators/     # Bộ xác thực dữ liệu đầu vào
```

---

## Hướng dẫn sử dụng nhanh

### 1. Nén và giải nén (klygo.archive as ar)

```python
import klygo.archive as ar

# Nén thư mục và giải nén
ar.compress("src_directory/", "archive.zip")
ar.extract("archive.zip", output="destination_dir/", overwrite=True)

# Tìm kiếm file trong archive
files = ar.search("archive.zip", "images/*.jpg")
```

Xem tài liệu đầy đủ tại docs/archive/README.md.

---

### 2. Quản lý bộ dữ liệu YOLO (klygo.datasets)

```python
from klygo.datasets import partition, repartition, merge, split, remap_classes, get_dataset_info

# 1. Phân chia tập dữ liệu thô thành train/val/test
partition(source="raw_data.zip", output="dataset/", ratios=(0.8,), overwrite=True)

# 2. Hợp nhất hai bộ dữ liệu khác class tự động đổi class ID
merge(sources=["data1/", "data2.zip"], output="merged.zip", overwrite=True)

# 3. Tách nhỏ bộ dữ liệu theo từng class đối tượng riêng biệt
split(source="merged.zip", output_dir="split_classes/", by_class=True, overwrite=True)

# 4. Ánh xạ và đổi tên lớp dữ liệu
remap_classes(source="merged.zip", output="remapped.zip", class_map={0: 1, "apple": "red_apple"}, overwrite=True)

# 5. Lấy thông tin chi tiết của bộ dữ liệu YOLO
info = get_dataset_info("merged.zip")
print(info)


```

Xem tài liệu đầy đủ tại docs/datasets/README.md.

---

### 3. File cấu hình (klygo.io as io)

```python
import klygo.io as io

# Ghi file cấu hình
config_data = {"learning_rate": 0.01, "epochs": 50}
io.write_file("configs/train_params.toml", config_data, overwrite=True)

# Đọc file cấu hình và truy cập bằng thuộc tính
cfg = io.Config("configs/train_params.toml").imread()
print(cfg.learning_rate)  # 0.01
```

Xem tài liệu đầy đủ tại docs/io/README.md.

---

### 4. Mô hình nhận diện (klygo.models.Kernel)

```python
from klygo.models import Kernel

# Khởi tạo mô hình Grounding DINO
kernel = Kernel()

# Chạy nhận diện trên video và xuất ra bộ dữ liệu YOLO
kernel.detect(
    input_path="input_video.mp4",
    prompt="car. traffic light.",
    save_yolo_dir="dataset/"
)
```

Xem tài liệu đầy đủ tại docs/models/README.md.

---

## Cài đặt

```bash
git clone https://github.com/your-username/klygo.git
cd klygo
uv sync
```

---

## Tài liệu chi tiết

Tất cả hướng dẫn đầy đủ đều được lưu tại thư mục docs:
* Hướng dẫn nén & giải nén: docs/archive/README.md
* Hướng dẫn xử lý bộ dữ liệu YOLO: docs/datasets/README.md
* Hướng dẫn cấu hình & IO: docs/io/README.md
* Hướng dẫn nhận diện vật thể: docs/models/README.md
#   k l y g o
