Skip to content

Commit

Permalink
feat: Updated src/api.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-nightly[bot] authored Oct 24, 2023
1 parent 44ea914 commit ba925fb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from PIL import Image
import torch
from torchvision import transforms
from main import Net # Importing Net class from main.py

# Load the model
model = Net()
model.load_state_dict(torch.load("mnist_model.pth"))
model.eval()
from main import MNISTTrainer # Importing MNISTTrainer class from main.py
trainer = MNISTTrainer()
trainloader = trainer.load_data()
model = trainer.define_model()
trainer.train_model(trainloader, model)
trainer.save_model(model)
model.eval() # Set the model to evaluation mode

# Transform used for preprocessing the image
transform = transforms.Compose([
Expand Down

0 comments on commit ba925fb

Please sign in to comment.