Python utilities for archive, config and zero-shot detection
Project description
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)
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)
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)
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)
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
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
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 klygo-1.0.2.tar.gz.
File metadata
- Download URL: klygo-1.0.2.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17383cb77384b6e33298145b6036b35c0ae431edf4ee7151bcfce7adbb42ef05
|
|
| MD5 |
197290bba0c5dec0350b8a43f661d0a6
|
|
| BLAKE2b-256 |
333136135b40f809867079e93fa82448fe00b46f56c1ac375d1929b76de5f628
|
File details
Details for the file klygo-1.0.2-py3-none-any.whl.
File metadata
- Download URL: klygo-1.0.2-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
550eb7eb898df4b46874bbdcb13fe89cf9a4e826e74662e9dcf42faadd375359
|
|
| MD5 |
fb4c32aaac0278a3c74b4581459b08f8
|
|
| BLAKE2b-256 |
590c04e162e2aa337ffa3e15c226edba537da619731e1d7a62fceb8fac166912
|