Giter Club home page Giter Club logo

holocron's Introduction

CI Status ruff ruff Test coverage percentage

PyPi Status Conda Version pyversions License

Huggingface Spaces Open in Colab

Documentation Status

Implementations of recent Deep Learning tricks in Computer Vision, easily paired up with your favorite framework and model zoo.

Holocrons were information-storage datacron devices used by both the Jedi Order and the Sith that contained ancient lessons or valuable information in holographic form.

Source: Wookieepedia

Quick Tour

Open In Colab

This project was created for quality implementations, increased developer flexibility and maximum compatibility with the PyTorch ecosystem. For instance, here is a short snippet to showcase how Holocron models are meant to be used:

from PIL import Image
from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
from torchvision.transforms.functional import InterpolationMode
from holocron.models.classification import repvgg_a0

# Load your model
model = repvgg_a0(pretrained=True).eval()

# Read your image
img = Image.open(path_to_an_image).convert("RGB")

# Preprocessing
config = model.default_cfg
transform = Compose([
    Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
    PILToTensor(),
    ConvertImageDtype(torch.float32),
    Normalize(config['mean'], config['std'])
])

input_tensor = transform(img).unsqueeze(0)

# Inference
with torch.inference_mode():
    output = model(input_tensor)
print(config['classes'][output.squeeze(0).argmax().item()], output.squeeze(0).softmax(dim=0).max())

Installation

Prerequisites

Python 3.8 (or higher) and pip/conda are required to install Holocron.

Latest stable release

You can install the last stable release of the package using pypi as follows:

pip install pylocron

or using conda:

conda install -c frgfm pylocron

Developer mode

Alternatively, if you wish to use the latest features of the project that haven't made their way to a release yet, you can install the package from source (install Git first):

git clone https://github.com/frgfm/Holocron.git
pip install -e Holocron/.

Paper references

PyTorch layers for every need

Models for vision tasks

Vision-related operations

Trying something else than Adam

More goodies

Documentation

The full package documentation is available here for detailed specifications.

Demo app

The project includes a minimal demo app using Gradio

demo_app

You can check the live demo, hosted on 🤗 HuggingFace Spaces 🤗 over here 👇 Hugging Face Spaces

Reference scripts

Reference scripts are provided to train your models using holocron on famous public datasets. Those scripts currently support the following vision tasks:

Latency benchmark

You crave for SOTA performances, but you don't know whether it fits your needs in terms of latency?

In the table below, you will find a latency benchmark for all supported models:

Arch GPU mean (std) CPU mean (std)
repvgg_a0* 3.14ms (0.87ms) 23.28ms (1.21ms)
repvgg_a1* 4.13ms (1.00ms) 29.61ms (0.46ms)
repvgg_a2* 7.35ms (1.11ms) 46.87ms (1.27ms)
repvgg_b0* 4.23ms (1.04ms) 33.16ms (0.58ms)
repvgg_b1* 12.48ms (0.96ms) 100.66ms (1.46ms)
repvgg_b2* 20.12ms (0.31ms) 155.90ms (1.59ms)
repvgg_b3* 24.94ms (1.70ms) 224.68ms (14.27ms)
rexnet1_0x 6.01ms (0.26ms) 13.66ms (0.21ms)
rexnet1_3x 6.43ms (0.10ms) 19.13ms (2.05ms)
rexnet1_5x 6.46ms (0.28ms) 21.06ms (0.24ms)
rexnet2_0x 6.75ms (0.21ms) 31.77ms (3.28ms)
rexnet2_2x 6.92ms (0.51ms) 33.61ms (0.60ms)
sknet50 11.40ms (0.38ms) 54.03ms (3.35ms)
sknet101 23.55 ms (1.11ms) 94.89ms (5.61ms)
sknet152 69.81ms (0.60ms) 253.07ms (3.33ms)
tridentnet50 16.62ms (1.21ms) 142.85ms (5.33ms)
res2net50_26w_4s 9.25ms (0.22ms) 41.84ms (0.80ms)
resnet50d 36.97ms (3.58ms) 36.97ms (3.58ms)
pyconv_resnet50 20.03ms (0.28ms) 178.85ms (2.35ms)
pyconvhg_resnet50 38.41ms (0.33ms) 301.03ms (12.39ms)
darknet24 3.94ms (1.08ms) 29.39ms (0.78ms)
darknet19 3.17ms (0.59ms) 26.36ms (2.80ms)
darknet53 7.12ms (1.35ms) 53.20ms (1.17ms)
cspdarknet53 6.41ms (0.21ms) 48.05ms (3.68ms)
cspdarknet53_mish 6.88ms (0.51ms) 67.78ms (2.90ms)

The reported latency for RepVGG models is the one of the reparametrized version

This benchmark was performed over 100 iterations on (224, 224) inputs, on a laptop to better reflect performances that can be expected by common users. The hardware setup includes an Intel(R) Core(TM) i7-10750H for the CPU, and a NVIDIA GeForce RTX 2070 with Max-Q Design for the GPU.

You can run this latency benchmark for any model on your hardware as follows:

python scripts/eval_latency.py rexnet1_0x

All script arguments can be checked using python scripts/eval_latency.py --help

Docker container

If you wish to deploy containerized environments, you can use the provided Dockerfile to build a docker image:

docker build . -t <YOUR_IMAGE_TAG>

Minimal API template

Looking for a boilerplate to deploy a model from Holocron with a REST API? Thanks to the wonderful FastAPI framework, you can do this easily.

Deploy your API locally

Run your API in a docker container as follows:

cd api/
make lock-api
make run-api

In order to stop the container, use make stop-api

What you have deployed

Your API is now running on port 8080, with its documentation http://localhost:8080/redoc and requestable routes:

import requests
with open('/path/to/your/img.jpeg', 'rb') as f:
    data = f.read()
response = requests.post("http://localhost:8080/classification", files={'file': data}).json()

Citation

If you wish to cite this project, feel free to use this BibTeX reference:

@software{Fernandez_Holocron_2020,
author = {Fernandez, François-Guillaume},
month = {5},
title = {{Holocron}},
url = {https://github.com/frgfm/Holocron},
year = {2020}
}

Contributing

Any sort of contribution is greatly appreciated!

You can find a short guide in CONTRIBUTING to help grow this project!

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

holocron's People

Contributors

dependabot[bot] avatar frgfm avatar imgbot[bot] avatar mateolostanlen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

holocron's Issues

PolyLoss doesn't support soft targets

Bug description

Hello, @frgfm
When calling the PolyLoss() function, I got the following runtime error, but didn't know how to solve it.
Please help~

Code snippet to reproduce the bug

directly invoke PolyLoss() in my framework

Error traceback

File "/path/to/poly_loss.py", in forward
    return poly_loss(x, target, self.eps, self.weight, self.ignore_index, self.reduction)
File "/path/to/poly_loss.py", in poly_loss
    logpt = logpt.transpose(1, 0).flatten(1).gather(0, target.view(1, -1)).squeeze()
RuntimeError: gather(): Expected dtype int64 for index

Environment

python 3.10

Release tracker - v0.2.1

This issue is to be used to track the roadmap of Holocron for release v0.2.1, and collect feedback from users & contributors.

Error Resnet pretrained

🐛 Bug

Hi, I want to use a pretrained 50 resnet but I have this error which I am having trouble resolving.
It spawns for resnet 18 and resnet 101.
I have not tested with the others.

To Reproduce

Steps to reproduce the behavior:

pretrained = True
backbone= "resnet50"
model = holocron.models.__dict__[backbone](
       pretrained, num_classes=1)

File "/.../.../Holocron/holocron/models/resnet.py", line 327, in resnet50
return _resnet('resnet50', pretrained, progress, **kwargs)
File "/.../.../Holocron/holocron/models/resnet.py", line 280, in _resnet
load_pretrained_params(model, default_cfgs[arch]['url'], progress)
File "/.../.../Holocron/holocron/models/utils.py", line 68, in load_pretrained_params
model.load_state_dict(state_dict)
File "/.../.../mainvenv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:

Missing key(s) in state_dict: "features.0.weight", "features.1.weight", "features.1.bias", "features.1.running_mean", "features.1.running_var", "features.4.0.conv.0.weight", "features.4.0.conv.1.weight", "features.4.0.conv.1.bias", "features.4.0.conv.1.running_mean", "features.4.0.conv.1.running_var", "features.4.0.conv.3.weight", "features.4.0.conv.4.weight", "features.4.0.conv.4.bias", "features.4.0.conv.4.running_mean", "features.4.0.conv.4.running_var", "features.4.0.conv.6.weight", "features.4.0.conv.7.weight", "features.4.0.conv.7.bias", "features.4.0.conv.7.running_mean", "features.4.0.conv.7.running_var", "features.4.0.downsample.0.weight", "features.4.0.downsample.1.weight", "features.4.0.downsample.1.bias", "features.4.0.downsample.1.running_mean", "features.4.0.downsample.1.running_var", "features.4.1.conv.0.weight", "features.4.1.conv.1.weight", "features.4.1.conv.1.bias", "features.4.1.conv.1.running_mean", "features.4.1.conv.1.running_var", "features.4.1.conv.3.weight", "features.4.1.conv.4.weight", "features.4.1.conv.4.bias", "features.4.1.conv.4.running_mean", "features.4.1.conv.4.running_var", "features.4.1.conv.6.weight", "features.4.1.conv.7.weight", "features.4.1.conv.7.bias", "features.4.1.conv.7.running_mean", "features.4.1.conv.7.running_var", "features.4.2.conv.0.weight", "features.4.2.conv.1.weight", "features.4.2.conv.1.bias", "features.4.2.conv.1.running_mean", "features.4.2.conv.1.running_var", "features.4.2.conv.3.weight", "features.4.2.conv.4.weight", "features.4.2.conv.4.bias", "features.4.2.conv.4.running_mean", "features.4.2.conv.4.running_var", "features.4.2.conv.6.weight", "features.4.2.conv.7.weight", "features.4.2.conv.7.bias", "features.4.2.conv.7.running_mean", "features.4.2.conv.7.running_var", "features.5.0.conv.0.weight", "features.5.0.conv.1.weight", "features.5.0.conv.1.bias", "features.5.0.conv.1.running_mean", "features.5.0.conv.1.running_var", "features.5.0.conv.3.weight", "features.5.0.conv.4.weight", "features.5.0.conv.4.bias", "features.5.0.conv.4.running_mean", "features.5.0.conv.4.running_var", "features.5.0.conv.6.weight", "features.5.0.conv.7.weight", "features.5.0.conv.7.bias", "features.5.0.conv.7.running_mean", "features.5.0.conv.7.running_var", "features.5.0.downsample.0.weight", "features.5.0.downsample.1.weight", "features.5.0.downsample.1.bias", "features.5.0.downsample.1.running_mean", "features.5.0.downsample.1.running_var", "features.5.1.conv.0.weight", "features.5.1.conv.1.weight", "features.5.1.conv.1.bias", "features.5.1.conv.1.running_mean", "features.5.1.conv.1.running_var", "features.5.1.conv.3.weight", "features.5.1.conv.4.weight", "features.5.1.conv.4.bias", "features.5.1.conv.4.running_mean", "features.5.1.conv.4.running_var", "features.5.1.conv.6.weight", "features.5.1.conv.7.weight", "features.5.1.conv.7.bias", "features.5.1.conv.7.running_mean", "features.5.1.conv.7.running_var", "features.5.2.conv.0.weight", "features.5.2.conv.1.weight", "features.5.2.conv.1.bias", "features.5.2.conv.1.running_mean", "features.5.2.conv.1.running_var", "features.5.2.conv.3.weight", "features.5.2.conv.4.weight", "features.5.2.conv.4.bias", "features.5.2.conv.4.running_mean", "features.5.2.conv.4.running_var", "features.5.2.conv.6.weight", "features.5.2.conv.7.weight", "features.5.2.conv.7.bias", "features.5.2.conv.7.running_mean", "features.5.2.conv.7.running_var", "features.5.3.conv.0.weight", "features.5.3.conv.1.weight", "features.5.3.conv.1.bias", "features.5.3.conv.1.running_mean", "features.5.3.conv.1.running_var", "features.5.3.conv.3.weight", "features.5.3.conv.4.weight", "features.5.3.conv.4.bias", "features.5.3.conv.4.running_mean", "features.5.3.conv.4.running_var", "features.5.3.conv.6.weight", "features.5.3.conv.7.weight", "features.5.3.conv.7.bias", "features.5.3.conv.7.running_mean", "features.5.3.conv.7.running_var", "features.6.0.conv.0.weight", "features.6.0.conv.1.weight", "features.6.0.conv.1.bias", "features.6.0.conv.1.running_mean", "features.6.0.conv.1.running_var", "features.6.0.conv.3.weight", "features.6.0.conv.4.weight", "features.6.0.conv.4.bias", "features.6.0.conv.4.running_mean", "features.6.0.conv.4.running_var", "features.6.0.conv.6.weight", "features.6.0.conv.7.weight", "features.6.0.conv.7.bias", "features.6.0.conv.7.running_mean", "features.6.0.conv.7.running_var", "features.6.0.downsample.0.weight", "features.6.0.downsample.1.weight", "features.6.0.downsample.1.bias", "features.6.0.downsample.1.running_mean", "features.6.0.downsample.1.running_var", "features.6.1.conv.0.weight", "features.6.1.conv.1.weight", "features.6.1.conv.1.bias", "features.6.1.conv.1.running_mean", "features.6.1.conv.1.running_var", "features.6.1.conv.3.weight", "features.6.1.conv.4.weight", "features.6.1.conv.4.bias", "features.6.1.conv.4.running_mean", "features.6.1.conv.4.running_var", "features.6.1.conv.6.weight", "features.6.1.conv.7.weight", "features.6.1.conv.7.bias", "features.6.1.conv.7.running_mean", "features.6.1.conv.7.running_var", "features.6.2.conv.0.weight", "features.6.2.conv.1.weight", "features.6.2.conv.1.bias", "features.6.2.conv.1.running_mean", "features.6.2.conv.1.running_var", "features.6.2.conv.3.weight", "features.6.2.conv.4.weight", "features.6.2.conv.4.bias", "features.6.2.conv.4.running_mean", "features.6.2.conv.4.running_var", "features.6.2.conv.6.weight", "features.6.2.conv.7.weight", "features.6.2.conv.7.bias", "features.6.2.conv.7.running_mean", "features.6.2.conv.7.running_var", "features.6.3.conv.0.weight", "features.6.3.conv.1.weight", "features.6.3.conv.1.bias", "features.6.3.conv.1.running_mean", "features.6.3.conv.1.running_var", "features.6.3.conv.3.weight", "features.6.3.conv.4.weight", "features.6.3.conv.4.bias", "features.6.3.conv.4.running_mean", "features.6.3.conv.4.running_var", "features.6.3.conv.6.weight", "features.6.3.conv.7.weight", "features.6.3.conv.7.bias", "features.6.3.conv.7.running_mean", "features.6.3.conv.7.running_var", "features.6.4.conv.0.weight", "features.6.4.conv.1.weight", "features.6.4.conv.1.bias", "features.6.4.conv.1.running_mean", "features.6.4.conv.1.running_var", "features.6.4.conv.3.weight", "features.6.4.conv.4.weight", "features.6.4.conv.4.bias", "features.6.4.conv.4.running_mean", "features.6.4.conv.4.running_var", "features.6.4.conv.6.weight", "features.6.4.conv.7.weight", "features.6.4.conv.7.bias", "features.6.4.conv.7.running_mean", "features.6.4.conv.7.running_var", "features.6.5.conv.0.weight", "features.6.5.conv.1.weight", "features.6.5.conv.1.bias", "features.6.5.conv.1.running_mean", "features.6.5.conv.1.running_var", "features.6.5.conv.3.weight", "features.6.5.conv.4.weight", "features.6.5.conv.4.bias", "features.6.5.conv.4.running_mean", "features.6.5.conv.4.running_var", "features.6.5.conv.6.weight", "features.6.5.conv.7.weight", "features.6.5.conv.7.bias", "features.6.5.conv.7.running_mean", "features.6.5.conv.7.running_var", "features.7.0.conv.0.weight", "features.7.0.conv.1.weight", "features.7.0.conv.1.bias", "features.7.0.conv.1.running_mean", "features.7.0.conv.1.running_var", "features.7.0.conv.3.weight", "features.7.0.conv.4.weight", "features.7.0.conv.4.bias", "features.7.0.conv.4.running_mean", "features.7.0.conv.4.running_var", "features.7.0.conv.6.weight", "features.7.0.conv.7.weight", "features.7.0.conv.7.bias", "features.7.0.conv.7.running_mean", "features.7.0.conv.7.running_var", "features.7.0.downsample.0.weight", "features.7.0.downsample.1.weight", "features.7.0.downsample.1.bias", "features.7.0.downsample.1.running_mean", "features.7.0.downsample.1.running_var", "features.7.1.conv.0.weight", "features.7.1.conv.1.weight", "features.7.1.conv.1.bias", "features.7.1.conv.1.running_mean", "features.7.1.conv.1.running_var", "features.7.1.conv.3.weight", "features.7.1.conv.4.weight", "features.7.1.conv.4.bias", "features.7.1.conv.4.running_mean", "features.7.1.conv.4.running_var", "features.7.1.conv.6.weight", "features.7.1.conv.7.weight", "features.7.1.conv.7.bias", "features.7.1.conv.7.running_mean", "features.7.1.conv.7.running_var", "features.7.2.conv.0.weight", "features.7.2.conv.1.weight", "features.7.2.conv.1.bias", "features.7.2.conv.1.running_mean", "features.7.2.conv.1.running_var", "features.7.2.conv.3.weight", "features.7.2.conv.4.weight", "features.7.2.conv.4.bias", "features.7.2.conv.4.running_mean", "features.7.2.conv.4.running_var", "features.7.2.conv.6.weight", "features.7.2.conv.7.weight", "features.7.2.conv.7.bias", "features.7.2.conv.7.running_mean", "features.7.2.conv.7.running_var", "head.weight", "head.bias". 
        
Unexpected key(s) in state_dict: "conv1.weight", "bn1.running_mean", "bn1.running_var", "bn1.weight", "bn1.bias", "layer1.0.conv1.weight", "layer1.0.bn1.running_mean", "layer1.0.bn1.running_var", "layer1.0.bn1.weight", "layer1.0.bn1.bias", "layer1.0.conv2.weight", "layer1.0.bn2.running_mean", "layer1.0.bn2.running_var", "layer1.0.bn2.weight", "layer1.0.bn2.bias", "layer1.0.conv3.weight", "layer1.0.bn3.running_mean", "layer1.0.bn3.running_var", "layer1.0.bn3.weight", "layer1.0.bn3.bias", "layer1.0.downsample.0.weight", "layer1.0.downsample.1.running_mean", "layer1.0.downsample.1.running_var", "layer1.0.downsample.1.weight", "layer1.0.downsample.1.bias", "layer1.1.conv1.weight", "layer1.1.bn1.running_mean", "layer1.1.bn1.running_var", "layer1.1.bn1.weight", "layer1.1.bn1.bias", "layer1.1.conv2.weight", "layer1.1.bn2.running_mean", "layer1.1.bn2.running_var", "layer1.1.bn2.weight", "layer1.1.bn2.bias", "layer1.1.conv3.weight", "layer1.1.bn3.running_mean", "layer1.1.bn3.running_var", "layer1.1.bn3.weight", "layer1.1.bn3.bias", "layer1.2.conv1.weight", "layer1.2.bn1.running_mean", "layer1.2.bn1.running_var", "layer1.2.bn1.weight", "layer1.2.bn1.bias", "layer1.2.conv2.weight", "layer1.2.bn2.running_mean", "layer1.2.bn2.running_var", "layer1.2.bn2.weight", "layer1.2.bn2.bias", "layer1.2.conv3.weight", "layer1.2.bn3.running_mean", "layer1.2.bn3.running_var", "layer1.2.bn3.weight", "layer1.2.bn3.bias", "layer2.0.conv1.weight", "layer2.0.bn1.running_mean", "layer2.0.bn1.running_var", "layer2.0.bn1.weight", "layer2.0.bn1.bias", "layer2.0.conv2.weight", "layer2.0.bn2.running_mean", "layer2.0.bn2.running_var", "layer2.0.bn2.weight", "layer2.0.bn2.bias", "layer2.0.conv3.weight", "layer2.0.bn3.running_mean", "layer2.0.bn3.running_var", "layer2.0.bn3.weight", "layer2.0.bn3.bias", "layer2.0.downsample.0.weight", "layer2.0.downsample.1.running_mean", "layer2.0.downsample.1.running_var", "layer2.0.downsample.1.weight", "layer2.0.downsample.1.bias", "layer2.1.conv1.weight", "layer2.1.bn1.running_mean", "layer2.1.bn1.running_var", "layer2.1.bn1.weight", "layer2.1.bn1.bias", "layer2.1.conv2.weight", "layer2.1.bn2.running_mean", "layer2.1.bn2.running_var", "layer2.1.bn2.weight", "layer2.1.bn2.bias", "layer2.1.conv3.weight", "layer2.1.bn3.running_mean", "layer2.1.bn3.running_var", "layer2.1.bn3.weight", "layer2.1.bn3.bias", "layer2.2.conv1.weight", "layer2.2.bn1.running_mean", "layer2.2.bn1.running_var", "layer2.2.bn1.weight", "layer2.2.bn1.bias", "layer2.2.conv2.weight", "layer2.2.bn2.running_mean", "layer2.2.bn2.running_var", "layer2.2.bn2.weight", "layer2.2.bn2.bias", "layer2.2.conv3.weight", "layer2.2.bn3.running_mean", "layer2.2.bn3.running_var", "layer2.2.bn3.weight", "layer2.2.bn3.bias", "layer2.3.conv1.weight", "layer2.3.bn1.running_mean", "layer2.3.bn1.running_var", "layer2.3.bn1.weight", "layer2.3.bn1.bias", "layer2.3.conv2.weight", "layer2.3.bn2.running_mean", "layer2.3.bn2.running_var", "layer2.3.bn2.weight", "layer2.3.bn2.bias", "layer2.3.conv3.weight", "layer2.3.bn3.running_mean", "layer2.3.bn3.running_var", "layer2.3.bn3.weight", "layer2.3.bn3.bias", "layer3.0.conv1.weight", "layer3.0.bn1.running_mean", "layer3.0.bn1.running_var", "layer3.0.bn1.weight", "layer3.0.bn1.bias", "layer3.0.conv2.weight", "layer3.0.bn2.running_mean", "layer3.0.bn2.running_var", "layer3.0.bn2.weight", "layer3.0.bn2.bias", "layer3.0.conv3.weight", "layer3.0.bn3.running_mean", "layer3.0.bn3.running_var", "layer3.0.bn3.weight", "layer3.0.bn3.bias", "layer3.0.downsample.0.weight", "layer3.0.downsample.1.running_mean", "layer3.0.downsample.1.running_var", "layer3.0.downsample.1.weight", "layer3.0.downsample.1.bias", "layer3.1.conv1.weight", "layer3.1.bn1.running_mean", "layer3.1.bn1.running_var", "layer3.1.bn1.weight", "layer3.1.bn1.bias", "layer3.1.conv2.weight", "layer3.1.bn2.running_mean", "layer3.1.bn2.running_var", "layer3.1.bn2.weight", "layer3.1.bn2.bias", "layer3.1.conv3.weight", "layer3.1.bn3.running_mean", "layer3.1.bn3.running_var", "layer3.1.bn3.weight", "layer3.1.bn3.bias", "layer3.2.conv1.weight", "layer3.2.bn1.running_mean", "layer3.2.bn1.running_var", "layer3.2.bn1.weight", "layer3.2.bn1.bias", "layer3.2.conv2.weight", "layer3.2.bn2.running_mean", "layer3.2.bn2.running_var", "layer3.2.bn2.weight", "layer3.2.bn2.bias", "layer3.2.conv3.weight", "layer3.2.bn3.running_mean", "layer3.2.bn3.running_var", "layer3.2.bn3.weight", "layer3.2.bn3.bias", "layer3.3.conv1.weight", "layer3.3.bn1.running_mean", "layer3.3.bn1.running_var", "layer3.3.bn1.weight", "layer3.3.bn1.bias", "layer3.3.conv2.weight", "layer3.3.bn2.running_mean", "layer3.3.bn2.running_var", "layer3.3.bn2.weight", "layer3.3.bn2.bias", "layer3.3.conv3.weight", "layer3.3.bn3.running_mean", "layer3.3.bn3.running_var", "layer3.3.bn3.weight", "layer3.3.bn3.bias", "layer3.4.conv1.weight", "layer3.4.bn1.running_mean", "layer3.4.bn1.running_var", "layer3.4.bn1.weight", "layer3.4.bn1.bias", "layer3.4.conv2.weight", "layer3.4.bn2.running_mean", "layer3.4.bn2.running_var", "layer3.4.bn2.weight", "layer3.4.bn2.bias", "layer3.4.conv3.weight", "layer3.4.bn3.running_mean", "layer3.4.bn3.running_var", "layer3.4.bn3.weight", "layer3.4.bn3.bias", "layer3.5.conv1.weight", "layer3.5.bn1.running_mean", "layer3.5.bn1.running_var", "layer3.5.bn1.weight", "layer3.5.bn1.bias", "layer3.5.conv2.weight", "layer3.5.bn2.running_mean", "layer3.5.bn2.running_var", "layer3.5.bn2.weight", "layer3.5.bn2.bias", "layer3.5.conv3.weight", "layer3.5.bn3.running_mean", "layer3.5.bn3.running_var", "layer3.5.bn3.weight", "layer3.5.bn3.bias", "layer4.0.conv1.weight", "layer4.0.bn1.running_mean", "layer4.0.bn1.running_var", "layer4.0.bn1.weight", "layer4.0.bn1.bias", "layer4.0.conv2.weight", "layer4.0.bn2.running_mean", "layer4.0.bn2.running_var", "layer4.0.bn2.weight", "layer4.0.bn2.bias", "layer4.0.conv3.weight", "layer4.0.bn3.running_mean", "layer4.0.bn3.running_var", "layer4.0.bn3.weight", "layer4.0.bn3.bias", "layer4.0.downsample.0.weight", "layer4.0.downsample.1.running_mean", "layer4.0.downsample.1.running_var", "layer4.0.downsample.1.weight", "layer4.0.downsample.1.bias", "layer4.1.conv1.weight", "layer4.1.bn1.running_mean", "layer4.1.bn1.running_var", "layer4.1.bn1.weight", "layer4.1.bn1.bias", "layer4.1.conv2.weight", "layer4.1.bn2.running_mean", "layer4.1.bn2.running_var", "layer4.1.bn2.weight", "layer4.1.bn2.bias", "layer4.1.conv3.weight", "layer4.1.bn3.running_mean", "layer4.1.bn3.running_var", "layer4.1.bn3.weight", "layer4.1.bn3.bias", "layer4.2.conv1.weight", "layer4.2.bn1.running_mean", "layer4.2.bn1.running_var", "layer4.2.bn1.weight", "layer4.2.bn1.bias", "layer4.2.conv2.weight", "layer4.2.bn2.running_mean", "layer4.2.bn2.running_var", "layer4.2.bn2.weight", "layer4.2.bn2.bias", "layer4.2.conv3.weight", "layer4.2.bn3.running_mean", "layer4.2.bn3.running_var", "layer4.2.bn3.weight", "layer4.2.bn3.bias", "fc.weight", "fc.bias". 

Expected behavior

Environment

  • PyTorch Version (e.g., 1.7): torch==1.8.1+cu111 torchvision==0.9.1+cu111

  • OS (e.g., Linux): Ubuntu 18.04

  • Python version: 3.7.9

  • CUDA/cuDNN version: 11

  • GPU models and configuration: RTX 2080TI

  • Any other relevant information:

[trainer] Add an image target size suggestion

Similarly to the LR finder, Holocron should integrate a suggestion for image target sizes. The goal is to limit oversampling / downsampling side effects while respecting aspect ratios.

Here is how this could be done:

  • a shape_recorder go through all images to produce the list of heights and widths
  • then we produce two arrays: aratio (height divided by width), and side (square root of height multiplied by width)
  • now, we want a range of values for each of those that fit a high percentage of the distribution
  • then we set the aspect ratio, and take the resolved side. The target size will be : side * sqrt(aratio), side / sqrt(aratio)

Inplace bias correction

exp_avg.div_(bias_correction1)

Here bias correction is made inplace so it affects exp_avg in the next steps (bias correction accumulates). I wonder if that was intentional?
Original Adam doesn't accomulate bias correction, it is applied on each step to calculate momentums with hat.
image

[trainer] Add a loss recorder option

Once a model has been trained, it would be nice to analyze its main failures. For that, one could:

  • go through the training set computing the loss (unreduced on the batch dimension)
  • keep the N samples with the highest loss
  • plot the image, the loss, the prediction and the target

A later option would be to display the CAM to better understand the model behaviour.

cIoU loss calculation question

Thank you for design this great tool!
I found the implementation of CIoU calculation is slightly different from the original paper(Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression)

The ciou_loss() function calculate the final loss with code:
ciou_loss[_filter].addcdiv_(v[_filter] ** 2, 1 - iou[_filter] + v[_filter])

The alpha in the paper is formulated as: V/(1-IoU)+V
whereas the code loos like calculating (v^2)/((1-IoU)+v)
I'd like to ask if this is the better design comparing to the original CIoU loss.
Anyway, thank you for the implementation, it really saves me a lot of time!

Collaboration

Hello there,

I am the author of glasses what if we join forces?

May the force be with you!

Francesco

polyloss not working when target contains `ignore_index`

Bug description

polyloss not working when target contains ignore_index

Code snippet to reproduce the bug

labels = [-100,2,1]
logits = [[-2.0605, -1.0522,  1.0922],[1.0303, -2.0048,  1.0727],[-1.1031,  1.0414, -2.0464]]
labels_pt = torch.tensor(labels,dtype=torch.int64)
logits_pt = torch.tensor(logits,dtype=torch.float32)

loss = poly_loss(logits_pt,labels_pt,reduction='none')

print('loss',loss)

Error traceback

index -100 is out of bounds for dimension 0 with size 3

Environment

Pretrained object detection

is there a pretrained model available for object detection. I tried using yolov4 but getting error in loading pretrained weight as there is no url in the script.

LAMB: Differences from the paper author's official implementation

The LAMB implementation of the PyTorch version you released is different from the official version of TensorFlow released by the paper author. According to the official implementation published in the paper, the author's code implementation skips some parameters according to their names() when calculating. But in your implementation, it seems that all parameters are directly involved in the calculation.
For example, exclude_from_weight_decay=["batch_normalization", "LayerNorm", "layer_norm"]
Their implementation:
https://github.com/tensorflow/addons/blob/master/tensorflow_addons/optimizers/lamb.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.