-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmegadetectorv6.py
More file actions
53 lines (44 loc) · 2.22 KB
/
megadetectorv6.py
File metadata and controls
53 lines (44 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from .yolov8_base import YOLOV8Base
__all__ = [
'MegaDetectorV6'
]
class MegaDetectorV6(YOLOV8Base):
"""
MegaDetectorV6 is a specialized class derived from the YOLOV8Base class
that is specifically designed for detecting animals, persons, and vehicles.
Attributes:
CLASS_NAMES (dict): Mapping of class IDs to their respective names.
"""
CLASS_NAMES = {
0: "animal",
1: "person",
2: "vehicle"
}
def __init__(self, weights=None, device="cpu", pretrained=True, version='MDV6-yolov9-c'):
"""
Initializes the MegaDetectorV5 model with the option to load pretrained weights.
Args:
weights (str, optional): Path to the weights file.
device (str, optional): Device to load the model on (e.g., "cpu" or "cuda"). Default is "cpu".
pretrained (bool, optional): Whether to load the pretrained model. Default is True.
version (str, optional): Version of the model to load. Default is 'MDV6-yolov9-c'.
"""
self.IMAGE_SIZE = 1280
if version == 'MDV6-yolov9-c':
url = "https://zenodo.org/records/15398270/files/MDV6-yolov9-c.pt?download=1"
self.MODEL_NAME = "MDV6b-yolov9-c.pt"
elif version == 'MDV6-yolov9-e':
url = "https://zenodo.org/records/15398270/files/MDV6-yolov9-e-1280.pt?download=1"
self.MODEL_NAME = "MDV6-yolov9-e-1280.pt"
elif version == 'MDV6-yolov10-c':
url = "https://zenodo.org/records/15398270/files/MDV6-yolov10-c.pt?download=1"
self.MODEL_NAME = "MDV6-yolov10-c.pt"
elif version == 'MDV6-yolov10-e':
url = "https://zenodo.org/records/15398270/files/MDV6-yolov10-e-1280.pt?download=1"
self.MODEL_NAME = "MDV6-yolov10-e-1280.pt"
elif version == 'MDV6-rtdetr-c':
url = "https://zenodo.org/records/15398270/files/MDV6-rtdetr-c.pt?download=1"
self.MODEL_NAME = "MDV6b-rtdetr-c.pt"
else:
raise ValueError('Select a valid model version: MDV6-yolov9-c, MDV6-yolov9-e, MDV6-yolov10-c, MDV6-yolov10-e, MDV6-rtdetr-c')
super(MegaDetectorV6, self).__init__(weights=weights, device=device, url=url)