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
chenpangpang
base-image-test
Commits
825c4b6a
Commit
825c4b6a
authored
Sep 19, 2024
by
chenpangpang
Browse files
feat: 新增生图模型
parent
f2c2cf9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
hf_down.py
hf_down.py
+2
-2
stable-diffusion-v1-4/infer.py
stable-diffusion-v1-4/infer.py
+14
-0
No files found.
hf_down.py
View file @
825c4b6a
...
@@ -5,7 +5,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
...
@@ -5,7 +5,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
model_list
=
[
model_list
=
[
"openai-community/gpt2"
,
"openai-community/gpt2"
,
# "stabilityai
/stable-diffusion-
xl-base-1.0
"
"CompVis
/stable-diffusion-
v1-4
"
]
]
os
.
system
(
"pip install -U huggingface-hub"
)
os
.
system
(
"pip install -U huggingface-hub"
)
...
@@ -14,4 +14,4 @@ for model_path in model_list:
...
@@ -14,4 +14,4 @@ for model_path in model_list:
root_dir
=
os
.
path
.
basename
(
model_path
)
root_dir
=
os
.
path
.
basename
(
model_path
)
os
.
system
(
os
.
system
(
f
"huggingface-cli download --resume-download
{
model_path
}
--local-dir ./
{
root_dir
}
/
{
model_path
}
\
f
"huggingface-cli download --resume-download
{
model_path
}
--local-dir ./
{
root_dir
}
/
{
model_path
}
\
--local-dir-use-symlinks False
--token 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
"
)
--local-dir-use-symlinks False"
)
stable-diffusion-v1-4/infer.py
0 → 100644
View file @
825c4b6a
import
torch
from
diffusers
import
StableDiffusionPipeline
model_id
=
"CompVis/stable-diffusion-v1-4"
device
=
"cuda"
pipe
=
StableDiffusionPipeline
.
from_pretrained
(
model_id
,
torch_dtype
=
torch
.
float16
)
pipe
=
pipe
.
to
(
device
)
prompt
=
"a photo of an astronaut riding a horse on mars"
image
=
pipe
(
prompt
).
images
[
0
]
image
.
save
(
"output.png"
)
print
(
"The output image has been saved as output.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