Skip to main content

A collection of PyTorch utilities for image AI training

Project description

Kevin's Torch Utils

PyPI version License: MIT

這是一個用於圖像 AI 訓練的 PyTorch 工具組 (kevins_torch),旨在提供一系列實用的功能來簡化深度學習模型的開發、訓練和評估過程。

主要功能模組

  • models:
    • base.py: 提供模型的基本結構。
    • cnn.py: 包含通用的卷積神經網路實現。
    • lenet.py: LeNet 模型的實現。
    • pretrained.py: 處理和載入預訓練模型的工具。
    • utils/activation_function_parser.py: 解析活化函數配置。
  • utils:
    • load_parameters.py: 從設定檔載入模型和訓練參數。
    • lightning_models.py: 與 PyTorch Lightning 整合的相關工具。
    • logger_config.py: 設定日誌記錄器。
    • repeat_channels.py: 用於調整輸入圖像通道數的工具。
    • dataset/coffee_bean_dataset.py: 針對特定咖啡豆資料集的處理。
  • examples:
    • settings.yaml: 範例設定檔。
    • train_configs_generator.py: 產生訓練設定檔的腳本。
  • tests:
    • 包含對各個模組的單元測試。

安裝

您可以透過 pip 安裝此套件:

pip install kevins_torch

使用範例

import torch
from kevins_torch import models
from kevins_torch.utils import load_parameters

# 載入設定檔中的參數
config_path = 'examples/settings.yaml' # 假設您的設定檔路徑
params = load_parameters(config_path)

# 根據設定檔建立模型
# (假設您的設定檔中有模型定義)
# model = models.build_model(params['model_config']) # 實際函數可能不同

# 或者直接使用預定義的模型
model = models.LeNet(num_classes=10)

# 準備輸入數據 (範例)
dummy_input = torch.randn(1, 1, 28, 28) # LeNet 通常用於 MNIST (1x28x28)

# 進行預測
output = model(dummy_input)
print("模型輸出:", output.shape)

開發設定

如果您想為此專案貢獻,請先設定開發環境:

  1. 複製儲存庫:
    git clone https://github.com/yourusername/kevins_torch # 請替換成實際的儲存庫 URL
    cd kevins_torch
    
  2. 安裝開發依賴:
    pip install -r dev-requirements.txt
    
  3. 設定 pre-commit hooks (建議):
    pre-commit install
    

執行測試

使用 pytest 執行測試:

pytest tests/

貢獻

歡迎透過 Pull Requests 或 Issues 提出問題和改進建議!

授權

本專案採用 MIT License 授權。

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

kevins_torch-0.2.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

kevins_torch-0.2.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file kevins_torch-0.2.0.tar.gz.

File metadata

  • Download URL: kevins_torch-0.2.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for kevins_torch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 81c66419a0a5e30fdadda30094db154a9715bdf1ffad73e409a4cecdf59a0962
MD5 5c9bd462fdc20021d57a924e4f84767e
BLAKE2b-256 ac0428e9eb81095d0bc0eb652046bff646b047af6209648fe11a467ac100a6c1

See more details on using hashes here.

File details

Details for the file kevins_torch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kevins_torch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for kevins_torch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96b8663b7578131aba7c6c191095c565a905d3eeae82b56892d61e2094c22721
MD5 21076e8c4a7c38dd676628ae1d5e4c91
BLAKE2b-256 5adc52bbaa4eaab60f9ca910cb8d90d7ddafe0e9d082069074e9da75b982e7e6

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