diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b140c87..7696c21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: [3.8, 3.9, "3.10", "3.11"] fail-fast: false steps: @@ -48,7 +48,7 @@ jobs: pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu fi pip install .[tests] - shell: bash # for Windows compatibility + shell: bash # for Windows compatibility - name: Check environment run: | @@ -66,4 +66,4 @@ jobs: env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | - pytest -s \ No newline at end of file + pytest -s diff --git a/requirements.txt b/requirements.txt index bd49516..64ceebc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ huggingface_hub>=0.12.0 fire -ultralytics>=8.0.43,<8.0.44 +ultralytics>=8.0.225,<8.1.0 sahi>=0.11.11,<0.12.0 pandas roboflow>= 0.2.32 +protobuf>=3.20,<3.21 \ No newline at end of file diff --git a/tests/test_cli.py b/tests/test_cli.py index 2aecac8..02e2363 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,7 +3,8 @@ import subprocess from pathlib import Path -from ultralytics.yolo.utils import SETTINGS +from ultralytics.utils import SETTINGS + MODEL = Path(SETTINGS['weights_dir']) / 'yolov8n' CFG = 'yolov8n' diff --git a/tests/test_hf.py b/tests/test_hf.py index 7c3cb77..c45949a 100644 --- a/tests/test_hf.py +++ b/tests/test_hf.py @@ -74,7 +74,7 @@ def test_detection_upload(): # run following lines if linux and python major == 3 and python minor == 10 (python micor can be anything) if platform.system() == 'Linux' and Version(platform.python_version()) >= Version("3.10"): print('training started') - run('yolo train detect model=yolov8n.pt data=coco8.yaml imgsz=32 epochs=1') + run(f'yolo train detect exist_ok=True model=yolov8n.pt data=coco8.yaml imgsz=32 epochs=1 --name={os.getcwd()}/runs/detect/train') print('training ended') hf_token = os.getenv('HF_TOKEN') if hf_token is None: diff --git a/tests/test_python.py b/tests/test_python.py index 25df244..2f46f1b 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -6,7 +6,7 @@ import torch from PIL import Image from ultralytics import YOLO -from ultralytics.yolo.utils import ROOT, SETTINGS +from ultralytics.utils import ROOT, SETTINGS from sahi.utils.cv import read_image_as_pil import numpy as np @@ -83,7 +83,7 @@ def test_export_torchscript(): 10 TensorFlow.js tfjs _web_model False False 11 PaddlePaddle paddle _paddle_model True True """ - from ultralytics.yolo.engine.exporter import export_formats + from ultralytics.engine.exporter import export_formats print(export_formats()) model = YOLO(MODEL) diff --git a/ultralyticsplus/hf_utils.py b/ultralyticsplus/hf_utils.py index db7550e..6d20942 100644 --- a/ultralyticsplus/hf_utils.py +++ b/ultralyticsplus/hf_utils.py @@ -534,7 +534,6 @@ def push_to_hfhub( score_top1_acc=score_top1_acc, score_top5_acc=score_top5_acc, task=task, - model_type=model.type, thumbnail_text=thumbnail_text, custom_tags=custom_tags, ) diff --git a/ultralyticsplus/ultralytics_utils.py b/ultralyticsplus/ultralytics_utils.py index 5b46c2a..fa3def5 100644 --- a/ultralyticsplus/ultralytics_utils.py +++ b/ultralyticsplus/ultralytics_utils.py @@ -12,7 +12,7 @@ ) from ultralytics import YOLO as YOLOBase from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task -from ultralytics.yolo.utils.downloads import GITHUB_ASSET_STEMS +from ultralytics.utils.downloads import GITHUB_ASSETS_STEMS from ultralyticsplus.hf_utils import download_from_hub LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper() @@ -43,10 +43,13 @@ def __init__(self, model="yolov8n.yaml", type="v8", hf_token=None) -> None: self.cfg = None # if loaded from *.yaml self.ckpt_path = None self.overrides = {} # overrides for trainer object + + # needed so torch can load models + super().__init__() # Load or create new YOLO model suffix = Path(model).suffix - if not suffix and Path(model).stem in GITHUB_ASSET_STEMS: + if not suffix and Path(model).stem in GITHUB_ASSETS_STEMS: model, suffix = ( Path(model).with_suffix(".pt"), ".pt", @@ -91,7 +94,7 @@ def _load_from_hf_hub(self, weights: str, hf_token=None): def render_result( image, model: YOLO, - result: "ultralytics.yolo.engine.result.Result", + result: "ultralytics.engine.result.Result", rect_th: int = 2, text_th: int = 2, ) -> Image.Image: @@ -101,7 +104,7 @@ def render_result( Args: image (str, URL, Image.Image): image to be rendered model (YOLO): YOLO model - result (ultralytics.yolo.engine.result.Result): output of the model. This is the output of the model.predict() method. + result (ultralytics.engine.result.Result): output of the model. This is the output of the model.predict() method. Returns: Image.Image: Image with predictions @@ -126,7 +129,7 @@ def render_result( if masks: img_height = np_image.shape[0] img_width = np_image.shape[1] - segments = masks.segments + segments = masks.xyn segments = segments[det_ind] # segments: np.array([[x1, y1], [x2, y2]]) # convert segments into full shape segments[:, 0] = segments[:, 0] * img_width @@ -166,7 +169,7 @@ def render_result( def postprocess_classify_output( - model: YOLO, result: "ultralytics.yolo.engine.result.Result" + model: YOLO, result: "ultralytics.engine.result.Result" ) -> dict: """ Postprocesses the output of classification models @@ -187,5 +190,5 @@ def postprocess_classify_output( raise ValueError("Model names must be either a list or a dict") for i, label in enumerate(names): - output[label] = result.probs[i].item() + output[label] = result.probs[i].top1 return output