Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
18695b7b
Commit
18695b7b
authored
Dec 23, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the default input layer automatically normalize unsigned char pixel values
to the range [0,1].
parent
09564840
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
input.h
dlib/dnn/input.h
+11
-2
input_abstract.h
dlib/dnn/input_abstract.h
+4
-0
No files found.
dlib/dnn/input.h
View file @
18695b7b
...
@@ -58,6 +58,8 @@ namespace dlib
...
@@ -58,6 +58,8 @@ namespace dlib
// initialize data to the right size to contain the stuff in the iterator range.
// initialize data to the right size to contain the stuff in the iterator range.
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
typedef
typename
pixel_traits
<
T
>::
basic_pixel_type
bptype
;
const
size_t
offset
=
nr
*
nc
;
const
size_t
offset
=
nr
*
nc
;
auto
ptr
=
data
.
host
();
auto
ptr
=
data
.
host
();
for
(
auto
i
=
ibegin
;
i
!=
iend
;
++
i
)
for
(
auto
i
=
ibegin
;
i
!=
iend
;
++
i
)
...
@@ -70,7 +72,10 @@ namespace dlib
...
@@ -70,7 +72,10 @@ namespace dlib
auto
p
=
ptr
++
;
auto
p
=
ptr
++
;
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
{
{
*
p
=
temp
(
j
);
if
(
is_same_type
<
bptype
,
unsigned
char
>::
value
)
*
p
=
temp
(
j
)
/
256
.
0
;
else
*
p
=
temp
(
j
);
p
+=
offset
;
p
+=
offset
;
}
}
}
}
...
@@ -130,6 +135,7 @@ namespace dlib
...
@@ -130,6 +135,7 @@ namespace dlib
// initialize data to the right size to contain the stuff in the iterator range.
// initialize data to the right size to contain the stuff in the iterator range.
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
typedef
typename
pixel_traits
<
T
>::
basic_pixel_type
bptype
;
const
size_t
offset
=
nr
*
nc
;
const
size_t
offset
=
nr
*
nc
;
auto
ptr
=
data
.
host
();
auto
ptr
=
data
.
host
();
...
@@ -143,7 +149,10 @@ namespace dlib
...
@@ -143,7 +149,10 @@ namespace dlib
auto
p
=
ptr
++
;
auto
p
=
ptr
++
;
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
{
{
*
p
=
temp
(
j
);
if
(
is_same_type
<
bptype
,
unsigned
char
>::
value
)
*
p
=
temp
(
j
)
/
256
.
0
;
else
*
p
=
temp
(
j
);
p
+=
offset
;
p
+=
offset
;
}
}
}
}
...
...
dlib/dnn/input_abstract.h
View file @
18695b7b
...
@@ -135,6 +135,10 @@ namespace dlib
...
@@ -135,6 +135,10 @@ namespace dlib
For example, a matrix<float,3,3> would turn into a tensor with 3 rows, 3
For example, a matrix<float,3,3> would turn into a tensor with 3 rows, 3
columns, and k()==1. Or a matrix<rgb_pixel,4,5> would turn into a tensor
columns, and k()==1. Or a matrix<rgb_pixel,4,5> would turn into a tensor
with 4 rows, 5 columns, and k()==3 (since rgb_pixels have 3 channels).
with 4 rows, 5 columns, and k()==3 (since rgb_pixels have 3 channels).
- If the input data contains pixels of type unsigned char, rgb_pixel, or
other pixel types with a basic_pixel_type of unsigned char then each
value written to the output tensor is first divided by 256.0 so that the
resulting outputs are all in the range [0,1].
!*/
!*/
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment