Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU export options #2297

Merged
merged 7 commits into from
Mar 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added parameter device
  • Loading branch information
Jan Hajek committed Mar 2, 2021
commit 93b41d7d8c1cdf8f29ef74619a4b3da0ba0a7308
5 changes: 4 additions & 1 deletion models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import sys
import time

from utils.torch_utils import select_device

sys.path.append('./') # to run '$ python *.py' files in subdirectories

import torch
Expand All @@ -25,14 +27,15 @@
parser.add_argument('--dynamic', action='store_true', help='dynamic ONNX axes')
parser.add_argument('--batch-size', type=int, default=1, help='batch size')
parser.add_argument('--skip-last-layer', action='store_true', help='skip export of last (detect) layer')
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
opt = parser.parse_args()
opt.img_size *= 2 if len(opt.img_size) == 1 else 1 # expand
print(opt)
set_logging()
t = time.time()

# Load PyTorch model
device = torch.device("cuda:0") if torch.cuda.is_available() else "cpu"
device = select_device(opt.device)
model = attempt_load(opt.weights, map_location=device) # load FP32 model
labels = model.names

Expand Down