From 23c7cd4c9fd118936e3858730fe7ee7669a6d975 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Fri, 7 Jul 2023 17:16:42 -0500 Subject: [PATCH] Avoid Python 3.9 with_stem (#3589) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- .github/workflows/ci.yaml | 1 - ultralytics/nn/tasks.py | 2 +- ultralytics/yolo/engine/exporter.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6312d29..4fd397f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,6 @@ jobs: matrix: os: [ubuntu-latest] python-version: ['3.11'] - model: [yolov5n] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/ultralytics/nn/tasks.py b/ultralytics/nn/tasks.py index e98a5fc..e05c53f 100644 --- a/ultralytics/nn/tasks.py +++ b/ultralytics/nn/tasks.py @@ -684,7 +684,7 @@ def yaml_model_load(path): if path.stem in (f'yolov{d}{x}6' for x in 'nsmlx' for d in (5, 8)): new_stem = re.sub(r'(\d+)([nslmx])6(.+)?$', r'\1\2-p6\3', path.stem) LOGGER.warning(f'WARNING ⚠️ Ultralytics YOLO P6 models now use -p6 suffix. Renaming {path.stem} to {new_stem}.') - path = path.with_stem(new_stem) + path = path.with_name(new_stem + path.suffix) unified_path = re.sub(r'(\d+)([nslmx])(.+)?$', r'\1\3', str(path)) # i.e. yolov8x.yaml -> yolov8.yaml yaml_file = check_yaml(unified_path, hard=False) or check_yaml(path) diff --git a/ultralytics/yolo/engine/exporter.py b/ultralytics/yolo/engine/exporter.py index 0a70ff4..bb5b8e2 100644 --- a/ultralytics/yolo/engine/exporter.py +++ b/ultralytics/yolo/engine/exporter.py @@ -591,7 +591,7 @@ class Exporter: # Remove/rename TFLite models if self.args.int8: for file in f.rglob('*_dynamic_range_quant.tflite'): - file.rename(file.with_stem(file.stem.replace('_dynamic_range_quant', '_int8'))) + file.rename(file.with_name(file.stem.replace('_dynamic_range_quant', '_int8') + file.suffix)) for file in f.rglob('*_integer_quant_with_int16_act.tflite'): file.unlink() # delete extra fp16 activation TFLite files