Skip to main content

Many utilities for ML

PyPI - Python Version PyPI version PyPI Status license pl onnx


NaMAZU

Installation

Version in pip server might be older than this repo.

pip install NaMAZU

1.Lightning API

PyTorch PL

1-1.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.

1-2.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!

1-3.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.

2.ONNX API

ONNX

We provide many readly to use ONNX models comes with preprocess and postprocess methods. They are packed as an class object and you can use it without any coding!

Weight files are automatically downloaded to the currently working directory if you don't have it or you can load existing model.

  1. MiDAS: Mono Depth Prediction (Light and Large models are available)
  2. U2Net: Saliency Segmnentation (Available with 4 task-specified weights)
  3. RealESR: Super Resolution (3 models. Predict method directly return upscaled image)
from NaMAZU.onnxapi import MiDASInference
model = MiDASInference(model="mono_depth_large.onnx")

prediction = model.predict("some_image.jpg") # Accept cv2 image as well
result = model.render(prediction, "some_image.jpg")

plt.imshow(result)

3.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

List of functions
  • npy_to_img
  • img_to_npy
  • split_image
  • compose_two_png
  • apply_mask_to
  • apply_to_all
  • change_frame_rates
  • save_all_frames
  • make_video_from_frames
  • collect_images (requires icrawler)

file_control

List of functions
  • rename_file
  • collect_file_pathes_by_ext
  • zip_files
  • randomly_choose_files
  • export_list_str_as

text_control

List of functions
  • search_word_from

data_science [Under redesign]

List of functions
  • train_linear_regressor
  • parse_tab_seperated_txt

Sampling Theory

  • calculate_sample_stats
  • error_bound_of_mean
  • calculate_sufficient_n_for_mean
  • estimated_total
  • error_bound_of_total
  • calculate_sufficient_n_for_population_total
  • calculate_sufficient_n_for_proportion
  • calculate_sufficient_n_for_proportion

Regression Analysis

  • sxy_of
  • sxx_of
  • least_square_estimate
  • estimate_variance_of_linear_regressor
  • t_statistic_of_beta1
  • calculate_CI_of_centred_model_at
  • get_prediction_interval
  • t_stats_for_correlation
  • get_p_value_of_tstat
  • fit_general_least_square_regression

Correlation Analysis

  • "get_prediction_interval"
  • "t_stats_for_correlation"
  • "get_p_value_of_tstat"
  • "_search_t_table"
  • "get_alt_sxx"
  • "get_alt_sxy"

coreml

List of functions
  • drop_negative

4.Visual Integration

Plotly Streamlit

st_utils

  • hide_default_header_and_footer
  • plot_plotly_supervised

5.Decorator [Under redesign]

Some utility decorators to speed up your development.

  • print_docstring
  • measure_runtime

🚀 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

Metadata

Release files for NaMAZU 0.0.73

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for NaMAZU 0.0.73
File Interpreter ABI Platform
NaMAZU-0.0.73-py3-none-any.whl Python 3 none any Details

Release files / NaMAZU-0.0.73-py3-none-any.whl

Download URL NaMAZU-0.0.73-py3-none-any.whl
Size 106.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
747120dc56a96002093e3b401145dfce24c859e7126a0ae16bdfb0bf311e8738
BLAKE2b-256 checksum
How to use checksums
296f1b0904dd7d0f50bf03c911b452dcfa8dd5c6f00e10f4a7bbd85435945bf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.73 This release

1 release file

0.0.72

1 release file

0.0.71

1 release file

0.0.70

1 release file

0.0.69

1 release file

0.0.68

1 release file

0.0.67

1 release file

0.0.66

1 release file

0.0.65

1 release file

0.0.64

1 release file

0.0.63

1 release file

0.0.62

1 release file

0.0.61

1 release file

0.0.60

1 release file

0.0.59

1 release file

0.0.58

1 release file

0.0.57

1 release file

0.0.56

1 release file

0.0.55

1 release file

0.0.54

1 release file

0.0.53

1 release file

0.0.52

1 release file

0.0.51

1 release file

0.0.50

1 release file

0.0.49

1 release file

0.0.48

1 release file

0.0.47

1 release file

0.0.46

1 release file

0.0.45

1 release file

0.0.44

1 release file

0.0.43

1 release file

0.0.42

1 release file

0.0.41

1 release file

0.0.40

1 release file

0.0.39

1 release file

0.0.38

1 release file

0.0.37

1 release file

0.0.36

1 release file

0.0.35

1 release file

0.0.33

1 release file

0.0.32

1 release file

0.0.31

1 release file

0.0.30

1 release file

0.0.29

1 release file

0.0.28

1 release file

0.0.27

1 release file

0.0.26

1 release file

0.0.25

1 release file

0.0.24

1 release file

0.0.23

1 release file

0.0.22

1 release file

0.0.21

1 release file

0.0.20

1 release file

0.0.19

1 release file

0.0.18

1 release file

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page