Yolo Ensemble Distribution Distillation
This repository contains code for running a model trained by distilling the distribution of an ensemble of Yolo teacher models into a single student models. This method improves the models performance and uncertainty estimation by leveraging the combined knowledge of multiple teacher models to distill a student model to predict a similar output distribution. The distilled model is fast with inference speed suitable for real-time apllications.
Example Usage
import torch
import cv2
import numpy as np
from yolo_ens_dist.utilz.utils import plot_boxes_cv2, plot_boxes_cv2_uncertainty, load_class_names
from yolo_ens_dist.utilz.torch_utils import do_detect
from yolo_ens_dist.model.models import Yolo_Ensemble_Distillation
conf_thresh = 0.4
nms_thresh = 0.4
height = 416
width = 416
num_classes = 10
imgfile = 'data/images/kitti/kitti_example_2.png'
weightsfile = 'weights/clean/bdd/dist/Yolo_bdd_teachers_only_1.pth'
class_names_path = 'data/bdd.names'
box_uncertainties = True
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
class_names = load_class_names(class_names_path)
model = Yolo_Ensemble_Distillation(yolov3conv137weight=None, n_classes=num_classes, inference=True, temp=1, vis=True)
pretrained_dict = torch.load(weightsfile, map_location=device)
model.load_state_dict(pretrained_dict)
if device.type == 'cuda':
model.cuda()
img = cv2.imread(imgfile)
sized = cv2.resize(img, (width, height))
sized = cv2.cvtColor(sized, cv2.COLOR_BGR2RGB)
boxes = do_detect(model, sized, conf_thresh, nms_thresh, uncertainties=True)
if box_uncertainties:
output_image = plot_boxes_cv2_uncertainty(img, boxes[0][0], class_names=class_names)
else:
output_image = plot_boxes_cv2(img, boxes[0][0], class_names=class_names)
cv2.imshow("frame", output_image)
cv2.waitKey(0)
Metadata
Release files for Yolo-Distribution-Distillation-Demo 1.0.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 |
|---|---|---|---|---|
| Yolo Distribution Distillation Demo-1.0.1.tar.gz | 13.4 kB | Without provenance | Details for Yolo Distribution Distillation Demo-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Yolo_Distribution_Distillation_Demo-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for Yolo_Distribution_Distillation_Demo-1.0.1-py3-none-any.whl |
Total release size: 28.3 kB
Release files / Yolo Distribution Distillation Demo-1.0.1.tar.gz
| Download URL | Yolo Distribution Distillation Demo-1.0.1.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68c64d9e4b95ce043b91b30781512f53adaae56da1cd76c3bfd631d3d93a3b5d
|
|
BLAKE2b-256 checksum How to use checksums |
ad327f2910a003c835b366a9570d5b0a2ce2e1e68062fcf28d260a6249a730ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13
|
Release files / Yolo_Distribution_Distillation_Demo-1.0.1-py3-none-any.whl
| Download URL | Yolo_Distribution_Distillation_Demo-1.0.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
640fc8e764e33342124c32f2fb8000e71195c2d98e80384ed42127f9bcff341c
|
|
BLAKE2b-256 checksum How to use checksums |
da17c3ff977957a08be79419f031f224a1e3f6f5dbda447eb9415aa0cdb38ffa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13
|
Security for Yolo-Distribution-Distillation-Demo 1.0.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.