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
diffusers
Commits
7fe47596
Unverified
Commit
7fe47596
authored
Dec 22, 2023
by
Pedro Cuenca
Committed by
GitHub
Dec 22, 2023
Browse files
Allow diffusers to load with Flax, w/o PyTorch (#6272)
parent
59d1caa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/diffusers/utils/torch_utils.py
src/diffusers/utils/torch_utils.py
+3
-3
No files found.
src/diffusers/utils/torch_utils.py
View file @
7fe47596
...
@@ -89,7 +89,7 @@ def is_compiled_module(module) -> bool:
...
@@ -89,7 +89,7 @@ def is_compiled_module(module) -> bool:
return
isinstance
(
module
,
torch
.
_dynamo
.
eval_frame
.
OptimizedModule
)
return
isinstance
(
module
,
torch
.
_dynamo
.
eval_frame
.
OptimizedModule
)
def
fourier_filter
(
x_in
:
torch
.
Tensor
,
threshold
:
int
,
scale
:
int
)
->
torch
.
Tensor
:
def
fourier_filter
(
x_in
:
"
torch.Tensor
"
,
threshold
:
int
,
scale
:
int
)
->
"
torch.Tensor
"
:
"""Fourier filter as introduced in FreeU (https://arxiv.org/abs/2309.11497).
"""Fourier filter as introduced in FreeU (https://arxiv.org/abs/2309.11497).
This version of the method comes from here:
This version of the method comes from here:
...
@@ -121,8 +121,8 @@ def fourier_filter(x_in: torch.Tensor, threshold: int, scale: int) -> torch.Tens
...
@@ -121,8 +121,8 @@ def fourier_filter(x_in: torch.Tensor, threshold: int, scale: int) -> torch.Tens
def
apply_freeu
(
def
apply_freeu
(
resolution_idx
:
int
,
hidden_states
:
torch
.
Tensor
,
res_hidden_states
:
torch
.
Tensor
,
**
freeu_kwargs
resolution_idx
:
int
,
hidden_states
:
"
torch.Tensor
"
,
res_hidden_states
:
"
torch.Tensor
"
,
**
freeu_kwargs
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]:
)
->
Tuple
[
"
torch.Tensor
"
,
"
torch.Tensor
"
]:
"""Applies the FreeU mechanism as introduced in https:
"""Applies the FreeU mechanism as introduced in https:
//arxiv.org/abs/2309.11497. Adapted from the official code repository: https://github.com/ChenyangSi/FreeU.
//arxiv.org/abs/2309.11497. Adapted from the official code repository: https://github.com/ChenyangSi/FreeU.
...
...
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