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

Detection.py tries to work with CUDA in CPU mode #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
7 changes: 6 additions & 1 deletion detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def detect(save_img=False):
half = device.type != 'cpu' # half precision only supported on CUDA

# Load model
model = Darknet(cfg, imgsz).cuda()
# Arguman 'cpu' should be controlled, if 'cpu' is set model should be initialized with .cpu() method
# Older version of code cannot run without nvidia driver because of this reason
if device.type != 'cpu'
hanoglu marked this conversation as resolved.
Show resolved Hide resolved
model = Darknet(cfg, imgsz).cuda()
else
hanoglu marked this conversation as resolved.
Show resolved Hide resolved
model = Darknet(cfg, imgsz).cpu()
model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
#model = attempt_load(weights, map_location=device) # load FP32 model
#imgsz = check_img_size(imgsz, s=model.stride.max()) # check img_size
Expand Down