Skip to main content

NaMAZU: Pretty Usefull Library

Project description

Many utilities for ML

PyPI - Python Version PyPI version PyPI Status license pl


NaMAZU

Installation

Version in pip server might be older than this repo.

pip install NaMAZU

Lightning API

PyTorch PL

Deep Learning Models

Collection of SOTA or robust baseline models for multiple tasks fully written in pytorch lightning! They are all ready-to-train models with MNIST, ImageNet, UCF101 etc... using LightingDataModule.

Some models come with their pretrained-weight available by auto-downloading.

import pytorch_lightning as pl
from NaMAZU.lightningwingman import LitVideoClf

config = {"num_classes": 10, "cnn": "resnet152d", "latent_dim":512}
model = LitVideoClf(use_lstm=False, model_config=config)

... 
# use bolts to get datamodule and pass model and datamodule to pl.trainer!
  • LitU2Net: LightningModule U2Net. Trainable and ready for prediction.
  • AniNet: LightningModule image classifier pretrained for japanese animations.
  • LitVideoClf: LightningModule video classfier using either single frame CNN or CNNLSTM.
  • MultiModalNet: LightningModule for multi-modal learning which can learn any modality with high robustness. Can be combined with any backbone.

Feature Learning Interface

Before starting your fine-tuning training, try this trianign API that produces better initial weight by running a self-supervised learning to your training dataset. Only images are used and no annotation nor data cleaning is required.

Other training schemes are coming soon!

from NaMAZU.lightingwingman import self_supervised_learning

# images may be stored in single or multiple directories. Stratified sampling is supported!
dir_images = "dataset/something"
dir_images2 = "dataset/something2"

self_supervised_training("resnet50", [dir_images, dir_images2], batch_size=64, save_dir="pretrained_models/")
  • self_supervised_training: Simple interface that you can obtain self-supervised CNN with just one line of code!

Statistical Models

They are all written in PyTorch following best practice to be used with pytorch lightning. They are all GPU enabled controlled by Lightning API. You will never need to call to("cuda") to use the model on any device even with multi-GPU training!

import pytorch_lightning as pl
from NaMAZU.lightningwingman import KNN, GMM

class YourLitModule(pl.LightningModule):
    def __init__(self,*args, **kwargs):
        ...
        self.encoder = SomeEncoder()
        self.head_classifier = KNN(
            n_neighbors=5, 
            distance_measure="cosine", 
            training_data=some_known_data
        )
        self.estimator = GMM(5, 10)

    def training_step(self, batch):
        x, t = batch
        y = self.encoder(x)
        y_hat = self.head_classifier(y)
        probability = self.estimator.predict_proba(y)
  • KNN: Available with euqlidean, manhattan, cosine and mahalanobis distance.
  • NBC: GPU enabled naive bayes classifier.
  • GMM: Gaussian Mixture probabability estimator. Of course GPU enabled.

Functional API

NumPy SKlearn FFmpeg OpenCV

You can use below functions via

import NaMAZU.functional as F

F.change_frame_rates("./test_data.mp4",fps=5)

image_control

  • npy_to_img
  • img_to_npy
  • split_image
  • compose_two_png
  • apply_mask_to
  • apply_to_all
  • change_frame_rates
  • save_all_frames
  • collect_images (requires icrawler)

file_control

  • rename_file
  • collect_file_pathes_by_ext
  • zip_files
  • randomly_choose_files
  • export_list_str_as

text_control

  • search_word_from

data_science

  • train_linear_regressor
  • calculate_sample_stats
  • estimated_total
  • error_bound_of_total
  • calculate_succifient_n_for_total

coreml

  • drop_negative

Visual Integration

Plotly Streamlit

st_utils

  • hide_default_header_and_footer
  • plot_plotly_supervised

Decorator

Some utility decorators to speed up your development.

  • print_docstring
  • measure_runtime

:rocket: Coming

  • 2. PredictionAssistant
  • 2. Video Recognition Model
  • 3. Feature Learning
  • 4. Few-shot Learning
  • 5. Audio-Visual Multimodal fusion (finish docstrings)
  • 6. BBox template finding
  • 7. CACNet

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

NaMAZU-0.0.62-py3-none-any.whl (97.1 kB view hashes)

Uploaded Python 3

Supported by

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