Package: pylocron
Implementations of recent Deep Learning tricks in Computer Vision, easily paired up with your favorite framework and model zoo.Holocronswere information-storagedatacrondevices used by both theJedi Orderand theSiththat contained ancient lessons or valuable information inholographicform.Source: WookieepediaQuick TourThis 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:fromPILimportImagefromtorchvision.transformsimportCompose,ConvertImageDtype,Normalize,PILToTensor,Resizefromtorchvision.transforms.functionalimportInterpolationModefromholocron.models.classificationimportrepvgg_a0# Load your modelmodel=repvgg_a0(pretrained=True).eval()# Read your imageimg=Image.open(path_to_an_image).convert("RGB")# Preprocessingconfig=model.default_cfgtransform=Compose([Resize(config['input_shape'][1:],interpolation=InterpolationMode.BILINEAR),PILToTensor(),ConvertImageDtype(torch.float32),Normalize(config['mean'],config['std'])])input_tensor=transform(img).unsqueeze(0)# Inferencewithtorch.inference_mode():output=model(input_tensor)print(config['classes'][output.squeeze(0).argmax().item()],output.squeeze(0).softmax(dim=0).max())InstallationPrerequisitesPython 3.6 (or higher) andpip/condaare required to install Holocron.Latest stable releaseYou can install the last stable release of the package usingpypias follows:pipinstallpylocronor usingconda:condainstall-cfrgfmpylocronDeveloper modeAlternatively, 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(installGitfirst):gitclonehttps://github.com/frgfm/Holocron.git
pipinstall-eHolocron/.Paper referencesPyTorch layers for every needActivation:HardMish,NLReLU,FReLULoss:Focal Loss, MultiLabelCrossEntropy,MixupLoss,ClassBalancedWrapper,ComplementCrossEntropy,MutualChannelLoss,DiceLoss,PolyLossConvolutions:NormConv2d,Add2d,SlimConv2d,PyConv2d,InvolutionRegularization:DropBlockPooling:BlurPool2d,SPP,ZPoolAttention:SAM,LambdaLayer,TripletAttentionModels for vision tasksImage Classification:Res2Net(based on the greatimplementationfrom Ross Wightman),Darknet-24,Darknet-19,Darknet-53,CSPDarknet-53,ResNet,ResNeXt,TridentNet,PyConvResNet,ReXNet,SKNet,RepVGG.Object Detection:YOLOv1,YOLOv2,YOLOv4Semantic Segmentation:U-Net,UNet++,UNet3+Vision-related operationsboxes:Distance-IoU & Complete-IoU lossesTrying something else than AdamOptimizer:LARS,Lamb,TAdam,AdamP,AdaBelief, and customized versions (RaLars)Optimizer wrapper:Lookahead, Scout (experimental)More goodiesDocumentationThe full package documentation is availableherefor detailed specifications.Demo appThe project includes a minimal demo app usingGradioYou can check the live demo, hosted on :hugs:HuggingFace Spaces:hugs: over here :point_down:Reference scriptsReference scripts are provided to train your models using holocron on famous public datasets. Those scripts currently support the following vision tasks:Image classificationObject detectionSemantic segmentationLatency benchmarkYou 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:ArchGPU 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_0x6.01ms (0.26ms)13.66ms (0.21ms)rexnet1_3x6.43ms (0.10ms)19.13ms (2.05ms)rexnet1_5x6.46ms (0.28ms)21.06ms (0.24ms)rexnet2_0x6.75ms (0.21ms)31.77ms (3.28ms)rexnet2_2x6.92ms (0.51ms)33.61ms (0.60ms)sknet5011.40ms (0.38ms)54.03ms (3.35ms)sknet10123.55 ms (1.11ms)94.89ms (5.61ms)sknet15269.81ms (0.60ms)253.07ms (3.33ms)tridentnet5016.62ms (1.21ms)142.85ms (5.33ms)res2net50_26w_4s9.25ms (0.22ms)41.84ms (0.80ms)resnet50d36.97ms (3.58ms)36.97ms (3.58ms)pyconv_resnet5020.03ms (0.28ms)178.85ms (2.35ms)pyconvhg_resnet5038.41ms (0.33ms)301.03ms (12.39ms)darknet243.94ms (1.08ms)29.39ms (0.78ms)darknet193.17ms (0.59ms)26.36ms (2.80ms)darknet537.12ms (1.35ms)53.20ms (1.17ms)cspdarknet536.41ms (0.21ms)48.05ms (3.68ms)cspdarknet53_mish6.88ms (0.51ms)67.78ms (2.90ms)The reported latency for RepVGG models is the one of the reparametrized versionThis 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 anIntel(R) Core(TM) i7-10750Hfor the CPU, and aNVIDIA GeForce RTX 2070 with Max-Q Designfor the GPU.You can run this latency benchmark for any model on your hardware as follows:pythonscripts/eval_latency.pyrexnet1_0xAll script arguments can be checked usingpython scripts/eval_latency.py --helpDocker containerIf you wish to deploy containerized environments, you can use the provided Dockerfile to build a docker image:dockerbuild.-t<YOUR_IMAGE_TAG>Minimal API templateLooking for a boilerplate to deploy a model from Holocron with a REST API? Thanks to the wonderfulFastAPIframework, you can do this easily.Deploy your API locallyRun your API in a docker container as follows:cdapi/
makelock-api
makerun-apiIn order to stop the container, usemake stop-apiWhat you have deployedYour API is now running on port 8080, with its documentationhttp://localhost:8080/redocand requestable routes:importrequestswithopen('/path/to/your/img.jpeg','rb')asf:data=f.read()response=requests.post("http://localhost:8080/classification",files={'file':data}).json()CitationIf you wish to cite this project, feel free to use thisBibTeXreference:@software{Fernandez_Holocron_2020,author={Fernandez, François-Guillaume},month={5},title={{Holocron}},url={https://github.com/frgfm/Holocron},year={2020}}ContributingAny sort of contribution is greatly appreciated!You can find a short guide inCONTRIBUTINGto help grow this project!LicenseDistributed under the Apache 2.0 License. SeeLICENSEfor more information.