Skip to content

Load PyTorch model

In this tutorial, you learn how to load an existing PyTorch model and use it to run a prediction task.

We will run the inference in DJL way with example on the pytorch official website.

Preparation

This tutorial requires the installation of Java Kernel. For more information on installing the Java Kernel, see the README.

// %mavenRepo snapshots https://oss.sonatype.org/content/repositories/snapshots/

%maven ai.djl:api:0.27.0
%maven ai.djl.pytorch:pytorch-engine:0.27.0
%maven org.slf4j:slf4j-simple:1.7.36
import java.nio.file.*;
import java.awt.image.*;
import ai.djl.*;
import ai.djl.inference.*;
import ai.djl.modality.*;
import ai.djl.modality.cv.*;
import ai.djl.modality.cv.util.*;
import ai.djl.modality.cv.transform.*;
import ai.djl.modality.cv.translator.*;
import ai.djl.repository.zoo.*;
import ai.djl.translate.*;
import ai.djl.training.util.*;

Step 1: Prepare your model

This tutorial assumes that you have a TorchScript model. DJL only supports the TorchScript format for loading models from PyTorch, so other models will need to be converted. A TorchScript model includes the model structure and all of the parameters.

We will be using a pre-trained resnet18 model. First, use the DownloadUtils to download the model files and save them in the build/pytorch_models folder

DownloadUtils.download("https://djl-ai.s3.amazonaws.com/mlrepo/model/cv/image_classification/ai/djl/pytorch/resnet/0.0.1/traced_resnet18.pt.gz", "build/pytorch_models/resnet18/resnet18.pt", new ProgressBar());

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   0% |█                                       | resnet18.pt

Downloading:   1% |█                                       | resnet18.pt

Downloading:   2% |█                                       | resnet18.pt

Downloading:   3% |██                                      | resnet18.pt

Downloading:   4% |██                                      | resnet18.pt

Downloading:   5% |███                                     | resnet18.pt

Downloading:   6% |███                                     | resnet18.pt

Downloading:   7% |███                                     | resnet18.pt

Downloading:   8% |████                                    | resnet18.pt

Downloading:   9% |████                                    | resnet18.pt

Downloading:  10% |█████                                   | resnet18.pt

Downloading:  11% |█████                                   | resnet18.pt

Downloading:  12% |█████                                   | resnet18.pt

Downloading:  13% |██████                                  | resnet18.pt

Downloading:  14% |██████                                  | resnet18.pt

Downloading:  15% |███████                                 | resnet18.pt

Downloading:  16% |███████                                 | resnet18.pt

Downloading:  17% |███████                                 | resnet18.pt

Downloading:  18% |████████                                | resnet18.pt

Downloading:  19% |████████                                | resnet18.pt

Downloading:  20% |█████████                               | resnet18.pt

Downloading:  21% |█████████                               | resnet18.pt

Downloading:  22% |█████████                               | resnet18.pt

Downloading:  23% |██████████                              | resnet18.pt

Downloading:  24% |██████████                              | resnet18.pt

Downloading:  25% |███████████                             | resnet18.pt

Downloading:  26% |███████████                             | resnet18.pt

Downloading:  27% |███████████                             | resnet18.pt

Downloading:  28% |████████████                            | resnet18.pt

Downloading:  29% |████████████                            | resnet18.pt

Downloading:  30% |█████████████                           | resnet18.pt

Downloading:  31% |█████████████                           | resnet18.pt

Downloading:  32% |█████████████                           | resnet18.pt

Downloading:  33% |██████████████                          | resnet18.pt

Downloading:  34% |██████████████                          | resnet18.pt

Downloading:  35% |███████████████                         | resnet18.pt

Downloading:  36% |███████████████                         | resnet18.pt

Downloading:  37% |███████████████                         | resnet18.pt

Downloading:  38% |████████████████                        | resnet18.pt

Downloading:  39% |████████████████                        | resnet18.pt

Downloading:  40% |█████████████████                       | resnet18.pt

Downloading:  41% |█████████████████                       | resnet18.pt

Downloading:  42% |█████████████████                       | resnet18.pt

Downloading:  43% |██████████████████                      | resnet18.pt

Downloading:  44% |██████████████████                      | resnet18.pt

Downloading:  45% |███████████████████                     | resnet18.pt

Downloading:  46% |███████████████████                     | resnet18.pt

Downloading:  47% |███████████████████                     | resnet18.pt

Downloading:  48% |████████████████████                    | resnet18.pt

Downloading:  49% |████████████████████                    | resnet18.pt

Downloading:  50% |█████████████████████                   | resnet18.pt

Downloading:  51% |█████████████████████                   | resnet18.pt

Downloading:  52% |█████████████████████                   | resnet18.pt

Downloading:  53% |██████████████████████                  | resnet18.pt

Downloading:  54% |██████████████████████                  | resnet18.pt

Downloading:  55% |███████████████████████                 | resnet18.pt

Downloading:  56% |███████████████████████                 | resnet18.pt

Downloading:  57% |███████████████████████                 | resnet18.pt

Downloading:  58% |████████████████████████                | resnet18.pt

Downloading:  59% |████████████████████████                | resnet18.pt

Downloading:  60% |█████████████████████████               | resnet18.pt

Downloading:  61% |█████████████████████████               | resnet18.pt

Downloading:  62% |█████████████████████████               | resnet18.pt

Downloading:  63% |██████████████████████████              | resnet18.pt

Downloading:  64% |██████████████████████████              | resnet18.pt

Downloading:  65% |███████████████████████████             | resnet18.pt

Downloading:  66% |███████████████████████████             | resnet18.pt

Downloading:  67% |███████████████████████████             | resnet18.pt

Downloading:  68% |████████████████████████████            | resnet18.pt

Downloading:  69% |████████████████████████████            | resnet18.pt

Downloading:  70% |█████████████████████████████           | resnet18.pt

Downloading:  71% |█████████████████████████████           | resnet18.pt

Downloading:  72% |█████████████████████████████           | resnet18.pt

Downloading:  73% |██████████████████████████████          | resnet18.pt

Downloading:  74% |██████████████████████████████          | resnet18.pt

Downloading:  75% |███████████████████████████████         | resnet18.pt

Downloading:  76% |███████████████████████████████         | resnet18.pt

Downloading:  77% |███████████████████████████████         | resnet18.pt

Downloading:  78% |████████████████████████████████        | resnet18.pt

Downloading:  79% |████████████████████████████████        | resnet18.pt

Downloading:  80% |█████████████████████████████████       | resnet18.pt

Downloading:  81% |█████████████████████████████████       | resnet18.pt

Downloading:  82% |█████████████████████████████████       | resnet18.pt

Downloading:  83% |██████████████████████████████████      | resnet18.pt

Downloading:  84% |██████████████████████████████████      | resnet18.pt

Downloading:  85% |███████████████████████████████████     | resnet18.pt

Downloading:  86% |███████████████████████████████████     | resnet18.pt

Downloading:  87% |███████████████████████████████████     | resnet18.pt

Downloading:  88% |████████████████████████████████████    | resnet18.pt

Downloading:  89% |████████████████████████████████████    | resnet18.pt

Downloading:  90% |█████████████████████████████████████   | resnet18.pt

Downloading:  91% |█████████████████████████████████████   | resnet18.pt

Downloading:  92% |█████████████████████████████████████   | resnet18.pt

Downloading:  93% |██████████████████████████████████████  | resnet18.pt

Downloading:  94% |██████████████████████████████████████  | resnet18.pt

Downloading:  95% |███████████████████████████████████████ | resnet18.pt

Downloading:  96% |███████████████████████████████████████ | resnet18.pt

Downloading:  97% |███████████████████████████████████████ | resnet18.pt

Downloading:  98% |████████████████████████████████████████| resnet18.pt

Downloading:  99% |████████████████████████████████████████| resnet18.pt

Downloading: 100% |████████████████████████████████████████| resnet18.pt

In order to do image classification, you will also need the synset.txt which stores the classification class labels. We will need the synset containing the Imagenet labels with which resnet18 was originally trained.

DownloadUtils.download("https://djl-ai.s3.amazonaws.com/mlrepo/model/cv/image_classification/ai/djl/pytorch/synset.txt", "build/pytorch_models/resnet18/synset.txt", new ProgressBar());

Downloading:  25% |███████████                             | synset.txt

Downloading:  51% |█████████████████████                   | synset.txt

Downloading:  53% |██████████████████████                  | synset.txt

Downloading:  55% |███████████████████████                 | synset.txt

Downloading:  81% |█████████████████████████████████       | synset.txt

Downloading: 100% |████████████████████████████████████████| synset.txt

Step 2: Create a Translator

We will create a transformation pipeline which maps the transforms shown in the PyTorch example.

...
preprocess = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
...

Then, we will use this pipeline to create the Translator

Translator<image, classifications=""> translator = ImageClassificationTranslator.builder()
        .addTransform(new Resize(256))
        .addTransform(new CenterCrop(224, 224))
        .addTransform(new ToTensor())
        .addTransform(new Normalize(
            new float[] {0.485f, 0.456f, 0.406f},
            new float[] {0.229f, 0.224f, 0.225f}))
        .optApplySoftmax(true)
        .build();

Step 3: Load your model

Next, we add some search criteria to find the resnet18 model and load it. In this case, we need to tell Criteria where to locate the model by calling .optModelPath() API.

Criteria<image, classifications=""> criteria = Criteria.builder()
        .setTypes(Image.class, Classifications.class)
        .optModelPath(Paths.get("build/pytorch_models/resnet18"))
        .optOption("mapLocation", "true") // this model requires mapLocation for GPU
        .optTranslator(translator)
        .optProgress(new ProgressBar()).build();

ZooModel model = criteria.loadModel();

Loading:     100% |████████████████████████████████████████|

[IJava-executor-0] INFO ai.djl.pytorch.engine.PtEngine - PyTorch graph executor optimizer is enabled, this may impact your inference latency and throughput. See: https://docs.djl.ai/docs/development/inference_performance_optimization.html#graph-executor-optimization

[IJava-executor-0] INFO ai.djl.pytorch.engine.PtEngine - Number of inter-op threads is 2

[IJava-executor-0] INFO ai.djl.pytorch.engine.PtEngine - Number of intra-op threads is 2

Step 4: Load image for classification

We will use a sample dog image to run our prediction on.

var img = ImageFactory.getInstance().fromUrl("https://raw.githubusercontent.com/pytorch/hub/master/images/dog.jpg");
img.getWrappedImage()