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
019139f7
"vscode:/vscode.git/clone" did not exist on "005355bd6fdc3a45f4d54f8d8dfd035b7968ce64"
Unverified
Commit
019139f7
authored
Oct 10, 2022
by
Philip Meier
Committed by
GitHub
Oct 10, 2022
Browse files
make _setup_fill_arg serializable (#6730)
parent
af54e564
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
torchvision/prototype/transforms/_utils.py
torchvision/prototype/transforms/_utils.py
+8
-2
No files found.
torchvision/prototype/transforms/_utils.py
View file @
019139f7
import
functools
import
numbers
from
collections
import
defaultdict
from
typing
import
Any
,
Callable
,
Dict
,
Sequence
,
Tuple
,
Type
,
Union
import
PIL.Image
...
...
@@ -43,13 +43,19 @@ def _check_fill_arg(fill: Union[FillType, Dict[Type, FillType]]) -> None:
raise
TypeError
(
"Got inappropriate fill arg"
)
def
_default_fill
(
fill
:
FillType
)
->
FillType
:
return
fill
def
_setup_fill_arg
(
fill
:
Union
[
FillType
,
Dict
[
Type
,
FillType
]])
->
Dict
[
Type
,
FillType
]:
_check_fill_arg
(
fill
)
if
isinstance
(
fill
,
dict
):
return
fill
return
defaultdict
(
lambda
:
fill
)
# type: ignore[return-value, arg-type]
# This weird looking construct only exists, since `lambda`'s cannot be serialized by pickle.
# If it were possible, we could replace this with `defaultdict(lambda: fill)`
return
defaultdict
(
functools
.
partial
(
_default_fill
,
fill
))
def
_check_padding_arg
(
padding
:
Union
[
int
,
Sequence
[
int
]])
->
None
:
...
...
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