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
wangkx1
torch_inference_resnet50
Commits
dcb5e4e4
Commit
dcb5e4e4
authored
Jul 20, 2024
by
wangkx1
Browse files
Update torch_verify.py
parent
32eb2157
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
torch_verify.py
torch_verify.py
+2
-2
No files found.
torch_verify.py
View file @
dcb5e4e4
...
@@ -7,7 +7,7 @@ from PIL import Image
...
@@ -7,7 +7,7 @@ from PIL import Image
# 加载预训练的ResNet50模型,并指定不使用GPU
# 加载预训练的ResNet50模型,并指定不使用GPU
model
=
models
.
resnet50
(
pretrained
=
True
)
model
=
models
.
resnet50
(
pretrained
=
True
)
model
.
eval
()
# 将模型设置为评估模式
model
.
eval
()
# 将模型设置为评估模式
device
=
torch
.
device
(
"c
p
u"
)
# 指定设备为CPU
device
=
torch
.
device
(
"cu
da:0
"
)
# 指定设备为CPU
model
.
to
(
device
)
# 将模型转移到CPU上
model
.
to
(
device
)
# 将模型转移到CPU上
# 图片预处理
# 图片预处理
...
...
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