Spaces:
Sleeping
Sleeping
Fix: Use GPU
Browse files- inference.py +2 -0
inference.py
CHANGED
|
@@ -8,6 +8,7 @@ import torch
|
|
| 8 |
from collections import OrderedDict
|
| 9 |
|
| 10 |
# Third Party Imports
|
|
|
|
| 11 |
from torchvision import transforms
|
| 12 |
from torch.nn import functional as F
|
| 13 |
from torchvision.models import resnet50
|
|
@@ -16,6 +17,7 @@ from pytorch_grad_cam.utils.image import show_cam_on_image
|
|
| 16 |
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
|
| 17 |
|
| 18 |
|
|
|
|
| 19 |
def inference(image, alpha, top_k, target_layer, model=None, classes=None):
|
| 20 |
"""
|
| 21 |
Function to run inference on the input image
|
|
|
|
| 8 |
from collections import OrderedDict
|
| 9 |
|
| 10 |
# Third Party Imports
|
| 11 |
+
import spaces
|
| 12 |
from torchvision import transforms
|
| 13 |
from torch.nn import functional as F
|
| 14 |
from torchvision.models import resnet50
|
|
|
|
| 17 |
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
|
| 18 |
|
| 19 |
|
| 20 |
+
@spaces.GPU
|
| 21 |
def inference(image, alpha, top_k, target_layer, model=None, classes=None):
|
| 22 |
"""
|
| 23 |
Function to run inference on the input image
|