Skip to content

How to infer from saved model using custom image dataset? #1577

Answered by laggui
amiyatulu asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry I didn't see your question in time!

Your code looks good. I'll provide a snippet with all modules required for future reference.

use burn::{
    data::{
        dataloader::batcher::Batcher,
        dataset::vision::{Annotation, ImageDatasetItem},
    },
    module::Module,
    record::{CompactRecorder, Recorder},
    tensor::backend::Backend,
};

use crate::{data::ClassificationBatcher, model::Cnn};

// NUM_CLASSES const in training.rs is private right now
const NUM_CLASSES: u8 = 10;

pub fn infer<B: Backend>(artifact_dir: &str, device: B::Device, item: ImageDatasetItem) {
    let record = CompactRecorder::new()
        .load(format!("{artifact_dir}/model").into(), &device)
        .

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by laggui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants