Update Comet integration
diff --git a/segment/tutorial.ipynb b/segment/tutorial.ipynb
index f2aee9e26b3..0ece0f60e4d 100644
--- a/segment/tutorial.ipynb
+++ b/segment/tutorial.ipynb
@@ -63,7 +63,7 @@
       "source": [
         "!git clone https://github.com/ultralytics/yolov5  # clone\n",
         "%cd yolov5\n",
-        "%pip install -qr requirements.txt  # install\n",
+        "%pip install -qr requirements.txt comet_ml  # install\n",
         "\n",
         "import torch\n",
         "import utils\n",
diff --git a/train.py b/train.py
index 48eeb09468f..b5044deb9b5 100644
--- a/train.py
+++ b/train.py
@@ -26,6 +26,11 @@
 from datetime import datetime
 from pathlib import Path
 
+try:
+    import comet_ml  # must be imported before torch (if installed)
+except ImportError:
+    comet_ml = None
+
 import numpy as np
 import torch
 import torch.distributed as dist
diff --git a/tutorial.ipynb b/tutorial.ipynb
index be87068822a..42c6bc632ae 100644
--- a/tutorial.ipynb
+++ b/tutorial.ipynb
@@ -59,7 +59,7 @@
       "source": [
         "!git clone https://github.com/ultralytics/yolov5  # clone\n",
         "%cd yolov5\n",
-        "%pip install -qr requirements.txt  # install\n",
+        "%pip install -qr requirements.txt comet_ml  # install\n",
         "\n",
         "import torch\n",
         "import utils\n",
diff --git a/utils/__init__.py b/utils/__init__.py
index 6c10857df07..bccac42711e 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -54,7 +54,7 @@ def notebook_init(verbose=True):
     import os
     import shutil
 
-    from utils.general import check_font, check_requirements, is_colab
+    from utils.general import check_font, is_colab
     from utils.torch_utils import select_device  # imports
 
     check_font()
diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py
index c7c283b728a..ba7d2790e61 100644
--- a/utils/loggers/__init__.py
+++ b/utils/loggers/__init__.py
@@ -46,15 +46,15 @@
     clearml = None
 
 try:
-    if RANK not in [0, -1]:
-        comet_ml = None
-    else:
+    if RANK in {0, -1}:
         import comet_ml
 
         assert hasattr(comet_ml, '__version__')  # verify package import not local dir
         from utils.loggers.comet import CometLogger
 
-except (ModuleNotFoundError, ImportError, AssertionError):
+    else:
+        comet_ml = None
+except (ImportError, AssertionError):
     comet_ml = None
 
 
@@ -88,10 +88,6 @@ def __init__(self, save_dir=None, weights=None, opt=None, hyp=None, logger=None,
         self.csv = True  # always log to csv
 
         # Messages
-        if not clearml:
-            prefix = colorstr('ClearML: ')
-            s = f"{prefix}run 'pip install clearml' to automatically track, visualize and remotely train YOLOv5 🚀 in ClearML"
-            self.logger.info(s)
         if not comet_ml:
             prefix = colorstr('Comet: ')
             s = f"{prefix}run 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet"
diff --git a/utils/loggers/comet/__init__.py b/utils/loggers/comet/__init__.py
index d4599841c9f..aac06b11c8c 100644
--- a/utils/loggers/comet/__init__.py
+++ b/utils/loggers/comet/__init__.py
@@ -18,7 +18,7 @@
     # Project Configuration
     config = comet_ml.config.get_config()
     COMET_PROJECT_NAME = config.get_string(os.getenv('COMET_PROJECT_NAME'), 'comet.project_name', default='yolov5')
-except (ModuleNotFoundError, ImportError):
+except ImportError:
     comet_ml = None
     COMET_PROJECT_NAME = None
 
@@ -82,7 +82,7 @@ def __init__(self, opt, hyp, run_id=None, job_type='Training', **experiment_kwar
         self.comet_log_batch_interval = COMET_BATCH_LOGGING_INTERVAL
 
         # Dataset Artifact Settings
-        self.upload_dataset = self.opt.upload_dataset if self.opt.upload_dataset else COMET_UPLOAD_DATASET
+        self.upload_dataset = self.opt.upload_dataset or COMET_UPLOAD_DATASET
         self.resume = self.opt.resume
 
         # Default parameters to pass to Experiment objects
@@ -93,6 +93,7 @@ def __init__(self, opt, hyp, run_id=None, job_type='Training', **experiment_kwar
             'project_name': COMET_PROJECT_NAME,}
         self.default_experiment_kwargs.update(experiment_kwargs)
         self.experiment = self._get_experiment(self.comet_mode, run_id)
+        self.experiment.set_name(self.opt.name)
 
         self.data_dict = self.check_dataset(self.opt.data)
         self.class_names = self.data_dict['names']

<!--
Thank you for submitting a YOLOv5 🚀 Pull Request! We want to make contributing to YOLOv5 as easy and transparent as possible. A few tips to get you started:

- Search existing YOLOv5 [PRs](https://github.com/ultralytics/yolov5/pull) to see if a similar PR already exists.
- Link this PR to a YOLOv5 [issue](https://github.com/ultralytics/yolov5/issues) to help us understand what bug fix or feature is being implemented.
- Provide before and after profiling/inference/training results to help us quantify the improvement your PR provides (if applicable).

Please see our ✅ [Contributing Guide](https://docs.ultralytics.com/help/contributing) for more details.

Note that Copilot will summarize this PR below, do not modify the 'copilot:all' line.
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 17ea9a1</samp>

### Summary
🚀🧹🌟

<!--
1.  🚀 for adding a feature that allows optional use of comet_ml
2.  🧹 for cleaning up unused or unnecessary code
3.  🌟 for improving the code quality and readability of the CometLogger class
-->
This pull request improves the code quality and functionality of the logging modules in `./utils/loggers/`. It also makes comet_ml an optional dependency for `train.py` and removes an unused import in `utils/__init__.py`.

> _We don't need no comet_ml to track our destiny_
> _We simplify and clean up the code of our `CometLogger`_
> _We remove the useless imports and the clearml noise_
> _We set the experiment name to match our run of choice_

### Walkthrough
*  Add optional support for comet_ml logging and tracking ([link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-ed183d67207df065a11e1289f19d34cc2abbc5448dea952683cfe9728c342b95R29-R33), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-33c598c680edd3d5bb6a80177861c1a89a6c4f17bea580adb0212e772b268c9dL49-R49), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-33c598c680edd3d5bb6a80177861c1a89a6c4f17bea580adb0212e772b268c9dL57-R57), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L21-R21), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L85-R85), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L93-R96), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L155-R156), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L172-R173), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L216-R217), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L272-R273), [link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-34e9c736220c721191e55be28d097da70bdf1bb5b74de365c1fe4f35fad51e46L281-R282))
* Remove unused import of check_requirements in `utils/__init__.py` ([link](https://github.com/ultralytics/yolov5/pull/11648/files?diff=unified&w=0#diff-6e982446d45d5ffa23213eb0cb66991fb02283df19b49da3bc8057ce1ab5094aL57-R57))




## 🛠️ PR Summary

<sub>Made with ❤️ by [Ultralytics Actions](https://github.com/ultralytics/actions)<sub>

### 🌟 Summary
Integration of Comet ML for enhanced training experiment tracking in the YOLOv5 repository.

### 📊 Key Changes
- Added `comet_ml` as a dependency to the YOLOv5 tutorials, ensuring it's installed alongside other requirements.
- Modified import logic in `train.py` to conditionally import `comet_ml` if available.
- Adjusted logger initialization in the YOLOv5 utilities to handle Comet ML integration and removed unnecessary warning messages when `clearml` is not available.
- In the Comet logger utility, streamlined dataset artifact upload logic and ensured naming for experiments is set through the Comet experiment object.

### 🎯 Purpose & Impact
- 🚀 **Enhanced Experiment Tracking**: Incorporating `comet_ml` allows users to track, compare, and monitor their YOLOv5 training experiments more efficiently.
- ✨ **Streamlined Setup**: With `comet_ml` now part of the tutorial requirements, new users will have an easier time setting up their environment for optimal experiment management.
- 🧹 **Cleaner Codebase**: Cleaning up logger initialization code contributes to a more maintainable and less error-prone codebase.
- 📈 **User Impact**: Users who leverage experiment tracking will benefit from improved insights and greater control over their model training processes. The integration also potentially attracts a wider user base comfortable with Comet ML.