Commit
·
24bad90
1
Parent(s):
a426098
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import timm
|
|
5 |
import gradio as gr
|
6 |
import numpy as np
|
7 |
|
8 |
-
device = torch.device('
|
9 |
|
10 |
labels = {0: 'bacterial_leaf_blight',
|
11 |
1: 'bacterial_leaf_streak',
|
@@ -47,7 +47,7 @@ def predict(image = None) :
|
|
47 |
image = np.transpose(image, (2, 0, 1))
|
48 |
image = torch.tensor(image, dtype=torch.float32)
|
49 |
model = timm.create_model('efficientnet_b0', pretrained=False, num_classes=10)
|
50 |
-
model.load_state_dict(torch.load("paddy_model.pth"))
|
51 |
model.to(device)
|
52 |
|
53 |
predicted = inference_fn(model, image)
|
|
|
5 |
import gradio as gr
|
6 |
import numpy as np
|
7 |
|
8 |
+
device = torch.device('cpu')
|
9 |
|
10 |
labels = {0: 'bacterial_leaf_blight',
|
11 |
1: 'bacterial_leaf_streak',
|
|
|
47 |
image = np.transpose(image, (2, 0, 1))
|
48 |
image = torch.tensor(image, dtype=torch.float32)
|
49 |
model = timm.create_model('efficientnet_b0', pretrained=False, num_classes=10)
|
50 |
+
model.load_state_dict(torch.load("paddy_model.pth", map_location=torch.device(device)))
|
51 |
model.to(device)
|
52 |
|
53 |
predicted = inference_fn(model, image)
|