-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathhubconf.py
More file actions
21 lines (16 loc) · 697 Bytes
/
Copy pathhubconf.py
File metadata and controls
21 lines (16 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import torch
from model import YOLOv4
dependencies = ['torch']
def yolov4(pretrained=False, n_classes=80):
"""
YOLOv4 model
pretrained (bool): kwargs, load pretrained weights into the model
n_classes(int): amount of classes
"""
m = YOLOv4(n_classes=n_classes)
if pretrained:
try: #If we change input or output layers amount, we will have an option to use pretrained weights
m.load_state_dict(torch.hub.load_state_dict_from_url("https://github.com/VCasecnikovs/Yet-Another-YOLOv4-Pytorch/releases/download/V1.0/yolov4.pth"), strict=False)
except RuntimeError as e:
print(f'[Warning] Ignoring {e}')
return m