Add notebook_init() to utils/__init__.py (#5488)
* Update __init__.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * notebook_init * notebook_init * notebook_init * notebook_init * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * notebook_init * Created using Colaboratory * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
7207fe95e5
commit
7ebb5e5da6
3 files changed
+35
-17
No files matched your search
@@ -53,7 +53,7 @@ def git_describe(path=Path(__file__).parent): # path must be a directory
|
||||
return '' # not a git repository
|
||||
|
||||
|
||||
def select_device(device='', batch_size=None):
|
||||
def select_device(device='', batch_size=None, newline=True):
|
||||
# device = 'cpu' or '0' or '0,1,2,3'
|
||||
s = f'YOLOv5 🚀 {git_describe() or date_modified()} torch {torch.__version__} ' # string
|
||||
device = str(device).strip().lower().replace('cuda:', '') # to string, 'cuda:0' to '0'
|
||||
@@ -77,6 +77,8 @@ def select_device(device='', batch_size=None):
|
||||
else:
|
||||
s += 'CPU\n'
|
||||
|
||||
if not newline:
|
||||
s = s.rstrip()
|
||||
LOGGER.info(s.encode().decode('ascii', 'ignore') if platform.system() == 'Windows' else s) # emoji-safe
|
||||
return torch.device('cuda:0' if cuda else 'cpu')
|
||||
|
||||
|
||||
Reference in new issue
Block a user