xt-models
Description
This repo contains common models and utilities for working with ML tasks, developed by Xtract AI.
More to come.
Installation
From PyPi:
pip install xt-models
From source:
git clone https://github.com/XtractTech/xt-models.git
pip install ./xt-models
Usage
Grabbing a segmentation model
from xt_models.models import ModelBuilder, SegmentationModule
from torch import nn
deep_sup_scale = 0.4
fc_dim = 2048
n_class = 2
net_encoder = ModelBuilder.build_encoder(
arch="resnet50dilated",
fc_dim=fc_dim,
weights="/nasty/scratch/common/smart_objects/model/ade20k/encoder_epoch_20.pth"
)
net_decoder = ModelBuilder.build_decoder(
arch="ppm_deepsup",
fc_dim=fc_dim,
num_class=150,
weights="/nasty/scratch/common/smart_objects/model/ade20k/decoder_epoch_20.pth"
)
in_channels = net_decoder.conv_last[-1].in_channels
net_decoder.conv_last[-1] = nn.Conv2d(in_channels, n_class, kernel_size=(1, 1), stride=(1, 1))
net_decoder.conv_last_deepsup = nn.Conv2d(in_channels, n_class, 1, 1, 0)
model = SegmentationModule(net_encoder, net_decoder, deep_sup_scale)
Grabbing a detection model
from xt_models.models import Model
import torch
# Load a fine-tuned model for inference
model_name = "yolov5x"
model = Model(model_name,nc=15)
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
weights = "/nasty/scratch/common/smart_objects/model/veh_detection/yolov5_ft/best_state_dict.pt"
ckpt = torch.load(weights, map_location=device)
model.load_state_dict(ckpt['model_state_dict'])
# Load pre-trained COCO model for finetuning/inference
model_name = "yolov5x"
model = Model(model_name,nc=80)
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
weights = "/nasty/scratch/common/smart_objects/model/veh_detection/yolov5_pretrain/yolov5x_state_dict.pt"
ckpt = torch.load(weights, map_location=device)
model.load_state_dict(ckpt['model_state_dict'])
# Fine-tuning number of classes
n_class = 15
model.nc = n_class
Implementing a new model
If you are having to always copy and paste the same model code for different projects, simply add the model code to the models directory, and import it in the models/__init__.py file.
Data Sources
[descriptions and links to data]
Dependencies/Licensing
[list of dependencies and their licenses, including data]
References
[list of references]
Metadata
Release files for xt-models 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xt-models-0.4.1.tar.gz | 21.0 kB | Without provenance | Details for xt-models-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xt_models-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for xt_models-0.4.1-py3-none-any.whl |
Total release size: 50.8 kB
Release files / xt-models-0.4.1.tar.gz
| Download URL | xt-models-0.4.1.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30e76a446257749aa5151a3377f598bfba2836a2bc8b553e6be9d0c9867ec741
|
|
BLAKE2b-256 checksum How to use checksums |
38540db2c50e7c9e1922015d39cb852fc3a7e372393da50348894def2706909d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Release files / xt_models-0.4.1-py3-none-any.whl
| Download URL | xt_models-0.4.1-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be4db0d3c0204a1ec780bd6652c075b9ac1c0bf0adc40d76bbca1916865c5c9a
|
|
BLAKE2b-256 checksum How to use checksums |
26250674ecf35a869201890375c93d7a9f7971abe756617f31810b13d47f3624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for xt-models 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.