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
renzhc
diffusers_dcu
Commits
3bce0f3d
Unverified
Commit
3bce0f3d
authored
Mar 25, 2024
by
Dhruv Nair
Committed by
GitHub
Mar 25, 2024
Browse files
Fix for `str_to_bool` definition in testing utils (#7461)
update
parent
9a349538
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
src/diffusers/utils/testing_utils.py
src/diffusers/utils/testing_utils.py
+16
-16
No files found.
src/diffusers/utils/testing_utils.py
View file @
3bce0f3d
...
...
@@ -141,6 +141,22 @@ def get_tests_dir(append_path=None):
return
tests_dir
# Taken from the following PR:
# https://github.com/huggingface/accelerate/pull/1964
def
str_to_bool
(
value
)
->
int
:
"""
Converts a string representation of truth to `True` (1) or `False` (0).
True values are `y`, `yes`, `t`, `true`, `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
"""
value
=
value
.
lower
()
if
value
in
(
"y"
,
"yes"
,
"t"
,
"true"
,
"on"
,
"1"
):
return
1
elif
value
in
(
"n"
,
"no"
,
"f"
,
"false"
,
"off"
,
"0"
):
return
0
else
:
raise
ValueError
(
f
"invalid truth value
{
value
}
"
)
def
parse_flag_from_env
(
key
,
default
=
False
):
try
:
value
=
os
.
environ
[
key
]
...
...
@@ -920,22 +936,6 @@ def backend_supports_training(device: str):
return
BACKEND_SUPPORTS_TRAINING
[
device
]
# Taken from the following PR:
# https://github.com/huggingface/accelerate/pull/1964
def
str_to_bool
(
value
)
->
int
:
"""
Converts a string representation of truth to `True` (1) or `False` (0).
True values are `y`, `yes`, `t`, `true`, `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
"""
value
=
value
.
lower
()
if
value
in
(
"y"
,
"yes"
,
"t"
,
"true"
,
"on"
,
"1"
):
return
1
elif
value
in
(
"n"
,
"no"
,
"f"
,
"false"
,
"off"
,
"0"
):
return
0
else
:
raise
ValueError
(
f
"invalid truth value
{
value
}
"
)
# Guard for when Torch is not available
if
is_torch_available
():
# Update device function dict mapping
...
...
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