Skip to content

Commit

Permalink
Create ResNet.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 5, 2024
1 parent e6a854d commit 2990657
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .ai/computer_vision/ResNet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import torch
import torch.nn as nn
import torchvision.models as models

class ResNet:
def __init__(self, model_path):
self.model = models.resnet50(pretrained=True)
self.model.load_state_dict(torch.load(model_path))

def predict(self, image):
image = image.unsqueeze(0)
outputs = self.model(image)
_, predicted = torch.max(outputs, 1)
return predicted.item()

0 comments on commit 2990657

Please sign in to comment.