Skip to content

Commit

Permalink
update requirements (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadhah101 authored Dec 11, 2023
1 parent 089e160 commit 6444c18
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: |
Expand All @@ -66,4 +66,4 @@ jobs:
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
pytest -s
pytest -s
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion ultralyticsplus/hf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
17 changes: 10 additions & 7 deletions ultralyticsplus/ultralytics_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 6444c18

Please sign in to comment.