Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
c6a03c76
Unverified
Commit
c6a03c76
authored
Sep 21, 2021
by
Prabhat Roy
Committed by
GitHub
Sep 21, 2021
Browse files
Replaced to_tensor() with pil_to_tensor() + convert_image_dtype() (#4452)
parent
c7120163
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
references/detection/transforms.py
references/detection/transforms.py
+4
-2
references/segmentation/transforms.py
references/segmentation/transforms.py
+2
-1
No files found.
references/detection/transforms.py
View file @
c6a03c76
...
...
@@ -47,7 +47,8 @@ class RandomHorizontalFlip(T.RandomHorizontalFlip):
class
ToTensor
(
nn
.
Module
):
def
forward
(
self
,
image
:
Tensor
,
target
:
Optional
[
Dict
[
str
,
Tensor
]]
=
None
)
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
image
=
F
.
to_tensor
(
image
)
image
=
F
.
pil_to_tensor
(
image
)
image
=
F
.
convert_image_dtype
(
image
)
return
image
,
target
...
...
@@ -231,7 +232,8 @@ class RandomPhotometricDistort(nn.Module):
is_pil
=
F
.
_is_pil_image
(
image
)
if
is_pil
:
image
=
F
.
to_tensor
(
image
)
image
=
F
.
pil_to_tensor
(
image
)
image
=
F
.
convert_image_dtype
(
image
)
image
=
image
[...,
permutation
,
:,
:]
if
is_pil
:
image
=
F
.
to_pil_image
(
image
)
...
...
references/segmentation/transforms.py
View file @
c6a03c76
...
...
@@ -77,7 +77,8 @@ class CenterCrop(object):
class
ToTensor
(
object
):
def
__call__
(
self
,
image
,
target
):
image
=
F
.
to_tensor
(
image
)
image
=
F
.
pil_to_tensor
(
image
)
image
=
F
.
convert_image_dtype
(
image
)
target
=
torch
.
as_tensor
(
np
.
array
(
target
),
dtype
=
torch
.
int64
)
return
image
,
target
...
...
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