Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,17 @@ from PIL import Image
|
|
6 |
# Load your PyTorch model
|
7 |
model = torch.load("model.pth",map_location=torch.device('cpu'))
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Define the function for image classification
|
10 |
def classify_image(image):
|
11 |
-
image_tensor =
|
12 |
|
13 |
# Perform inference using your PyTorch model
|
14 |
with torch.no_grad():
|
|
|
6 |
# Load your PyTorch model
|
7 |
model = torch.load("model.pth",map_location=torch.device('cpu'))
|
8 |
|
9 |
+
classes = ['bom', 'ruim']
|
10 |
+
|
11 |
+
def preprocess(image):
|
12 |
+
image = image.resize((224, 224))
|
13 |
+
image_tensor = ToTensor()(image)
|
14 |
+
image_tensor = image_tensor.unsqueeze(0)
|
15 |
+
return image_tensor
|
16 |
+
|
17 |
# Define the function for image classification
|
18 |
def classify_image(image):
|
19 |
+
image_tensor = preprocess(image)
|
20 |
|
21 |
# Perform inference using your PyTorch model
|
22 |
with torch.no_grad():
|