From cc5e9a5a853a2683fcc5ac8d7be09e3f28a71ea0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 12 Feb 2019 16:58:07 +0100 Subject: [PATCH] updates --- detect.py | 1 + models.py | 2 +- utils/datasets.py | 1 - utils/parse_config.py | 2 +- utils/torch_utils.py | 11 ++--------- 5 files changed, 5 insertions(+), 12 deletions(-) mode change 100755 => 100644 detect.py diff --git a/detect.py b/detect.py old mode 100755 new mode 100644 index bc735a7b..ede33bf4 --- a/detect.py +++ b/detect.py @@ -1,5 +1,6 @@ import argparse import time +from sys import platform from models import * from utils.datasets import * diff --git a/models.py b/models.py index 9e4ca010..e83cfdcd 100755 --- a/models.py +++ b/models.py @@ -243,7 +243,7 @@ class Darknet(nn.Module): def __init__(self, cfg_path, img_size=416): super(Darknet, self).__init__() - self.module_defs = parse_model_config(cfg_path) + self.module_defs = parse_model_cfg(cfg_path) self.module_defs[0]['cfg'] = cfg_path self.module_defs[0]['height'] = img_size self.hyperparams, self.module_list = create_modules(self.module_defs) diff --git a/utils/datasets.py b/utils/datasets.py index fdd30901..d934915c 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -2,7 +2,6 @@ import glob import math import os import random -from sys import platform import cv2 import numpy as np diff --git a/utils/parse_config.py b/utils/parse_config.py index 714bae7a..e72d5a79 100644 --- a/utils/parse_config.py +++ b/utils/parse_config.py @@ -1,4 +1,4 @@ -def parse_model_config(path): +def parse_model_cfg(path): """Parses the yolo-v3 layer configuration file and returns module definitions""" file = open(path, 'r') lines = file.read().split('\n') diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 19197eac..48274c8f 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -1,16 +1,9 @@ import torch -def check_cuda(): - return torch.cuda.is_available() - - -CUDA_AVAILABLE = check_cuda() - - def init_seeds(seed=0): torch.manual_seed(seed) - if CUDA_AVAILABLE: + if torch.cuda.is_available(): torch.cuda.manual_seed(seed) torch.cuda.manual_seed_all(seed) # torch.cuda.set_device(0) # OPTIONAL: Set your GPU if multiple available @@ -20,6 +13,6 @@ def select_device(force_cpu=False): if force_cpu: device = torch.device('cpu') else: - device = torch.device('cuda:0' if CUDA_AVAILABLE else 'cpu') + device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') print('Using ' + str(device) + '\n') return device