You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 line
1.1KB

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