JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Tweet
Loading...
Searching...
No Matches
recognition.py
Go to the documentation of this file.
1
import
os
2
3
import
numpy
as
np
4
import
cv2
as
cv
5
6
from
.base_dataloader
import
_BaseImageLoader
7
from
..factory
import
DATALOADERS
8
9
@DATALOADERS.register
10
class
RecognitionImageLoader
(
_BaseImageLoader
):
11
def
__init__
(self, **kwargs):
12
super().
__init__
(**kwargs)
13
14
self.
_labels
= self.
_load_label
()
15
16
def
_load_label
(self):
17
labels = dict.fromkeys(self.
_files
,
None
)
18
for
filename
in
self.
_files
:
19
labels[filename] = np.loadtxt(os.path.join(self.
_path
,
'{}.txt'
.format(filename[:-4])), ndmin=2)
20
return
labels
21
22
def
__iter__
(self):
23
for
filename
in
self.
_files
:
24
image = cv.imread(os.path.join(self.
_path
, filename))
25
if
[0, 0]
in
self.
_sizes
:
26
yield
filename, image, self.
_labels
[filename]
27
else
:
28
for
size
in
self.
_sizes
:
29
image_r = cv.resize(image, size)
30
yield
filename, image_r, self.
_labels
[filename]
utils.dataloaders.base_dataloader._BaseImageLoader
Definition
base_dataloader.py:5
utils.dataloaders.base_dataloader._BaseImageLoader._path
_path
Definition
base_dataloader.py:7
utils.dataloaders.base_dataloader._BaseImageLoader._sizes
_sizes
Definition
base_dataloader.py:14
utils.dataloaders.base_dataloader._BaseImageLoader._files
_files
Definition
base_dataloader.py:10
utils.dataloaders.recognition.RecognitionImageLoader
Definition
recognition.py:10
utils.dataloaders.recognition.RecognitionImageLoader.__iter__
__iter__(self)
Definition
recognition.py:22
utils.dataloaders.recognition.RecognitionImageLoader._labels
_labels
Definition
recognition.py:14
utils.dataloaders.recognition.RecognitionImageLoader.__init__
__init__(self, **kwargs)
Definition
recognition.py:11
utils.dataloaders.recognition.RecognitionImageLoader._load_label
_load_label(self)
Definition
recognition.py:16
opencv_zoo
benchmark
utils
dataloaders
recognition.py
Please help us improve this page: Edit it on
GitHub
or
email us your edits and suggestions.
Generated by
1.9.8