Update README.md
Browse files
README.md
CHANGED
@@ -53,7 +53,7 @@ Video classification model
|
|
53 |
# Enable multi-GPU support
|
54 |
net = torch.nn.DataParallel(net)
|
55 |
torch.backends.cudnn.benchmark = True
|
56 |
-
state = torch.load(model_path, map_location=torch.device('
|
57 |
net.load_state_dict(state['net'])
|
58 |
net.eval()
|
59 |
|
@@ -63,7 +63,61 @@ Video classification model
|
|
63 |
img = img.resize((224, 224))
|
64 |
img_tensor = torch.tensor(np.array(img)).unsqueeze(0).to('cuda')
|
65 |
|
66 |
-
# Extract features from the image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
outputs = net(img_tensor)
|
68 |
```
|
69 |
|
|
|
53 |
# Enable multi-GPU support
|
54 |
net = torch.nn.DataParallel(net)
|
55 |
torch.backends.cudnn.benchmark = True
|
56 |
+
state = torch.load(model_path, map_location=torch.device('cpu'))
|
57 |
net.load_state_dict(state['net'])
|
58 |
net.eval()
|
59 |
|
|
|
63 |
img = img.resize((224, 224))
|
64 |
img_tensor = torch.tensor(np.array(img)).unsqueeze(0).to('cuda')
|
65 |
|
66 |
+
# Extract features from the image
|
67 |
+
outputs = net(img_tensor)
|
68 |
+
```
|
69 |
+
|
70 |
+
Frame classification model
|
71 |
+
|
72 |
+
```python
|
73 |
+
import torch
|
74 |
+
from PIL import Image
|
75 |
+
from model_loader import build_model
|
76 |
+
|
77 |
+
# Load the model
|
78 |
+
net = build_model(mode='classify')
|
79 |
+
model_path = 'Frame classification models'
|
80 |
+
|
81 |
+
# Enable multi-GPU support
|
82 |
+
net = torch.nn.DataParallel(net)
|
83 |
+
torch.backends.cudnn.benchmark = True
|
84 |
+
state = torch.load(model_path, map_location=torch.device('cpu'))
|
85 |
+
net.load_state_dict(state['net'])
|
86 |
+
net.eval()
|
87 |
+
|
88 |
+
img_path = 'path/to/your/image.jpg'
|
89 |
+
img = Image.open(img_path)
|
90 |
+
img = img.resize((224, 224))
|
91 |
+
img_tensor = torch.tensor(np.array(img)).unsqueeze(0).to('cuda')
|
92 |
+
|
93 |
+
# Extract features from the image
|
94 |
+
outputs = net(img_tensor)
|
95 |
+
```
|
96 |
+
|
97 |
+
Non-surgical object detection model
|
98 |
+
|
99 |
+
```python
|
100 |
+
import torch
|
101 |
+
from PIL import Image
|
102 |
+
from model_loader import build_model
|
103 |
+
|
104 |
+
# Load the model
|
105 |
+
net = build_model(mode='mask')
|
106 |
+
model_path = 'Frame classification models'
|
107 |
+
|
108 |
+
# Enable multi-GPU support
|
109 |
+
net = torch.nn.DataParallel(net)
|
110 |
+
torch.backends.cudnn.benchmark = True
|
111 |
+
state = torch.load(model_path, map_location=torch.device('cpu'))
|
112 |
+
net.load_state_dict(state['net'])
|
113 |
+
net.eval()
|
114 |
+
|
115 |
+
img_path = 'path/to/your/image.jpg'
|
116 |
+
img = Image.open(img_path)
|
117 |
+
img = img.resize((224, 224))
|
118 |
+
img_tensor = torch.tensor(np.array(img)).unsqueeze(0).to('cuda')
|
119 |
+
|
120 |
+
# Extract features from the image
|
121 |
outputs = net(img_tensor)
|
122 |
```
|
123 |
|