deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.07k stars 648 forks source link

Unknown builtin op: torchvision::nms #818

Closed anandvsr closed 3 years ago

anandvsr commented 3 years ago

build.gradle

    plugins {
        id 'java'
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        implementation group: 'ai.djl.pytorch', name: 'pytorch-engine', version: '0.10.0'
        implementation group: 'ai.djl.pytorch', name: 'pytorch-native-cpu', version: '1.7.1'

        implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
    }

Predict.java

    import ai.djl.MalformedModelException;
    import ai.djl.Model;

    import javax.imageio.ImageIO;
    import java.awt.image.BufferedImage;
    import java.io.IOException;

    public class Predict {
        public static void main(String[] args) {
            Path modelDir = Paths.get("src/main/resources/fasterrcnn_resnet50.pt");

            try (Model model = Model.newInstance("fasterrcnn_resnet50")) {
                model.load(modelDir);
            } catch (IOException | MalformedModelException e) {
                e.printStackTrace();
            }
        }
    }
stu1130 commented 3 years ago

@anandvsr nms is TorchVision operator that we don't support. It is still blocked by https://github.com/pytorch/vision/issues/2692.

anandvsr commented 3 years ago

Thank you!

smeet2804 commented 2 years ago

Hii @stu1130, Facing same issue while inferencing object detection using pytorch trained model. Is there any other way to do object detection inference using pytorch trained model?

frankfliu commented 2 years ago

@smeet2804

If you install torchvision with python, you can use DJL to run your model, what you need to do is set environment:

PYTORCH_EXTRA_LIBRARY_PATH=/PATH_TO_TORCHVISION/libtorchvsion.so

This is urgly, but it should work.

smeet2804 commented 2 years ago

Hii @frankfliu , I installed torchvision but libtorchvision.so file is not present in the folder.

image

frankfliu commented 2 years ago

@smeet2804 You need build from source: https://github.com/pytorch/vision

smeet2804 commented 2 years ago

@frankfliu I installed it from source using python setup.py install command but still can't locate the file.

stu1130 commented 2 years ago

@smeet2804 what you need is c++ torchvision not python torchvision. The instructions are

mkdir build
cd build
# Add -DWITH_CUDA=on support for the CUDA if needed
cmake ..
make
make install
smeet2804 commented 2 years ago

Thanks @stu1130 , I tried, but not able to run make command after cmake ... It gives **make * no targets specified and no makefile found. stop. Don't know where I'm going wrong. I tried it on Windows 10 through anaconda prompt.