Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ai.djl.repository.zoo.ModelNotFoundException #484

Closed
Jzow opened this issue Jan 4, 2021 · 0 comments
Closed

ai.djl.repository.zoo.ModelNotFoundException #484

Jzow opened this issue Jan 4, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Jzow
Copy link
Contributor

Jzow commented Jan 4, 2021

Description

The value of optModelUrls is “ftp://47.114.1.215”,Failed to load model

Expected Behavior

Use FTP to load model successfully

Error Message

Exception in thread "main" ai.djl.repository.zoo.ModelNotFoundException: No matching model with specified Input/Output type found.

How to Reproduce?

url:https://github.com/aws-samples/djl-demo/blob/master/pneumonia-detection/README.md

package com.tensorflow.common.staticvoidmainTest;

import ai.djl.Application;
import ai.djl.ModelException;
import ai.djl.inference.Predictor;
import ai.djl.modality.Classifications;
import ai.djl.modality.cv.Image;
import ai.djl.modality.cv.ImageFactory;
import ai.djl.modality.cv.translator.ImageClassificationTranslator;
import ai.djl.modality.cv.util.NDImageUtils;
import ai.djl.repository.zoo.Criteria;
import ai.djl.repository.zoo.ModelZoo;
import ai.djl.repository.zoo.ZooModel;
import ai.djl.training.util.ProgressBar;
import ai.djl.translate.TranslateException;
import ai.djl.translate.Translator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

public class PneumoniaDetection {

    private static final Logger logger = LoggerFactory.getLogger(PneumoniaDetection.class);

    private static final List<String> CLASSES = Arrays.asList("正常", "肺炎");

    public static void main(String[] args) throws IOException, TranslateException, ModelException {
        Path imagePath = Paths.get("tensorflow/src/test/resources/test.jpg");
        Image image = ImageFactory.getInstance().fromFile(imagePath);

        Translator<Image, Classifications> translator =
                ImageClassificationTranslator.builder()
                        .addTransform(a -> NDImageUtils.resize(a, 224).div(255.0f))
                        .optSynset(CLASSES)
                        .build();
        Criteria<Image, Classifications> criteria =
                Criteria.builder()
                        .optApplication(Application.CV.IMAGE_CLASSIFICATION)
                        .setTypes(Image.class, Classifications.class)
                        .optModelUrls("ftp://test:zw123456@47.114.1.215")
                        .optTranslator(translator)
                        .optProgress(new ProgressBar())
                        .build();

        try (ZooModel<Image, Classifications> model = ModelZoo.loadModel(criteria);
             Predictor<Image, Classifications> predictor = model.newPredictor()) {
            Classifications result = predictor.predict(image);
            logger.info("预测结果: {}", result);
        }
    }
}

What have you tried to solve it?

  1. Use FTP path to set the modelURL

Environment Info

windows10 x64
engine:tensorflow-native-cpu-2.3.0

@Jzow Jzow added the bug Something isn't working label Jan 4, 2021
frankfliu added a commit to frankfliu/djl that referenced this issue Jan 5, 2021
Change-Id: Idffb89945aef3eb191c3e005e84f1b7a9820ea1b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants