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
ModelZoo
LinFusion_pytorch
Commits
fca222ce
Commit
fca222ce
authored
Oct 30, 2024
by
luopl
Browse files
Upload New File
parent
d4c20bdc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
examples/inference/basic_usage_sd2_example.py
examples/inference/basic_usage_sd2_example.py
+17
-0
No files found.
examples/inference/basic_usage_sd2_example.py
0 → 100644
View file @
fca222ce
from
diffusers
import
AutoPipelineForText2Image
import
torch
from
src.linfusion
import
LinFusion
from
src.tools
import
seed_everything
sd_repo
=
"stabilityai/stable-diffusion-2-1"
pipeline
=
AutoPipelineForText2Image
.
from_pretrained
(
sd_repo
,
torch_dtype
=
torch
.
bfloat16
,
variant
=
"fp16"
).
to
(
torch
.
device
(
"cuda"
))
linfusion
=
LinFusion
.
construct_for
(
pipeline
,
pretrained_model_name_or_path
=
"Yuanshi/LinFusion-2-1"
)
seed_everything
(
123
)
image
=
pipeline
(
"An astronaut floating in space. Beautiful view of the stars and the universe in the background."
).
images
[
0
]
# 保存图像
image
.
save
(
"astronaut_space-2-1.png"
)
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