DevoLearn / devolearn

Accelerate data driven research on embryos with deep learning models :microscope:
MIT License
43 stars 31 forks source link

build a base InferenceEngine class #40

Closed Mayukhdeb closed 3 years ago

Mayukhdeb commented 3 years ago

the models in devolearn have different architectures, and different purposes. But it would be great if all of the models come under one single base class like:

class InferenceEngine():
    def __init__self(model, checkpoint, preprocess, deprocess, device = 'cuda'):
        self.model = model
        self.model.load_state_dict(torch.load(checkpoint))
        self.model.to(device)

    def inference(self, x):
        x = self.preprocess(x)
        pred = self.model(x)
        return self.deprocess(pred)

    ...other methods...

    def __repr__(self):
        return self.model
Mainakdeb commented 3 years ago

I'm interested to work on this, feel free to assign this to me.