1

I'm working on an image classification project using a custom-trained ResNet50 model with ImageAI, but I'm encountering a persistent loading error that prevents me from using my trained model for predictions. The error suggests there's a compatibility issue or a specific method I'm missing when trying to load a custom-trained PyTorch model into the ImageAI framework.

I attempted to load my custom-trained ResNet50 model using ImageAI's standard model loading procedure:

from imageai.Classification import ImageClassification

classifier = ImageClassification()
classifier.setModelPath("path/to/custom/model.pt")
classifier.setModelTypeAsResNet50()
classifier.loadModel()  # Expected to successfully load the model

What I expected was a straightforward model loading process similar to using pre-trained models. Instead, I received a frustrating error:

Classification failed: Model not yet loaded. You need to call '.loadModel()' 
before performing image classification

My environment details:

  • Python 3.12
  • ImageAI 3.0.3
  • PyTorch 2.5.1+cu118
  • Windows 11

I've confirmed:

  • The model path is correct
  • The model is saved as a valid .pt file
  • The model was trained on a custom dataset using ResNet50 architecture

Specific Questions:

  • Is there a specific method for loading custom-trained models in ImageAI?
  • Are there any special export or conversion requirements for custom models?
  • Do I need to modify my model's state dictionary or use a specific export format?
1
  • What line give the error? classifier.loadModel() itself or other line above? Commented Dec 9, 2024 at 9:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.