CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hukaixuan19970627

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: hukaixuan19970627/yolov5_obb
Path: blob/master/utils/__init__.py
Views: 475
1
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
2
"""
3
utils/initialization
4
"""
5
6
7
def notebook_init(verbose=True):
8
# Check system software and hardware
9
print('Checking setup...')
10
11
import os
12
import shutil
13
14
from utils.general import check_requirements, emojis, is_colab
15
from utils.torch_utils import select_device # imports
16
17
check_requirements(('psutil', 'IPython'))
18
import psutil
19
from IPython import display # to display images and clear console output
20
21
if is_colab():
22
shutil.rmtree('/content/sample_data', ignore_errors=True) # remove colab /sample_data directory
23
24
if verbose:
25
# System info
26
# gb = 1 / 1000 ** 3 # bytes to GB
27
gib = 1 / 1024 ** 3 # bytes to GiB
28
ram = psutil.virtual_memory().total
29
total, used, free = shutil.disk_usage("/")
30
display.clear_output()
31
s = f'({os.cpu_count()} CPUs, {ram * gib:.1f} GB RAM, {(total - free) * gib:.1f}/{total * gib:.1f} GB disk)'
32
else:
33
s = ''
34
35
select_device(newline=False)
36
print(emojis(f'Setup complete ✅ {s}'))
37
return display
38
39