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
f2c2cf9b
".github/vscode:/vscode.git/clone" did not exist on "a9e38e747dedea92912edfad8a541b74dbda992e"
Commit
f2c2cf9b
authored
Sep 18, 2024
by
chenpangpang
Browse files
feat: 初始提交
parent
1d4e35d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
gpt2/infer.py
gpt2/infer.py
+5
-0
hf_down.py
hf_down.py
+17
-0
No files found.
gpt2/infer.py
0 → 100644
View file @
f2c2cf9b
from
transformers
import
pipeline
,
set_seed
generator
=
pipeline
(
'text-generation'
,
model
=
'openai-community/gpt2'
,
device
=
'cuda'
)
output
=
generator
(
"Hello, I'm a language model,"
,
truncation
=
True
,
max_length
=
30
,
num_return_sequences
=
1
)[
0
][
"generated_text"
]
print
(
output
)
hf_down.py
0 → 100644
View file @
f2c2cf9b
# pip install huggingface-cli
import
os
os
.
environ
[
'HF_ENDPOINT'
]
=
'https://hf-mirror.com'
model_list
=
[
"openai-community/gpt2"
,
# "stabilityai/stable-diffusion-xl-base-1.0"
]
os
.
system
(
"pip install -U huggingface-hub"
)
for
model_path
in
model_list
:
root_dir
=
os
.
path
.
basename
(
model_path
)
os
.
system
(
f
"huggingface-cli download --resume-download
{
model_path
}
--local-dir ./
{
root_dir
}
/
{
model_path
}
\
--local-dir-use-symlinks False --token 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"
)
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