Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ultralytics #46

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
huggingface_hub>=0.12.0
fire
ultralytics>=8.0.20,<8.0.21
ultralytics>=8.0.21,<8.0.22
sahi>=0.11.11,<0.12.0
pandas
2 changes: 1 addition & 1 deletion ultralyticsplus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .hf_utils import download_from_hub, push_to_hfhub
from .ultralytics_utils import YOLO, postprocess_classify_output, render_result

__version__ = "0.0.22"
__version__ = "0.0.23"
15 changes: 15 additions & 0 deletions ultralyticsplus/hf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pandas as pd
from sahi.utils.cv import read_image_as_pil

from ultralyticsplus.other_utils import add_text_to_image

LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper()
Expand All @@ -24,6 +25,7 @@ def generate_model_usage_markdown(
custom_tags=None,
):
from ultralytics import __version__ as ultralytics_version

from ultralyticsplus import __version__ as ultralyticsplus_version

hf_task = "image-segmentation" if task == "instance-segmentation" else task
Expand Down Expand Up @@ -472,6 +474,7 @@ def push_to_hfhub(
hf_dataset_id=None,
thumbnail_text=None,
custom_tags=None,
return_dict=False,
):
"""
Pushes a ultralytics model to huggingface hub
Expand All @@ -484,6 +487,7 @@ def push_to_hfhub(
hf_dataset_id (str): huggingface dataset id to be used for model card
thumbnail_text (str): text to be used in thumbnail
custom_tags (list): list of custom tags to be used for model card
return_dict (bool): whether to return a dictionary of results or not
"""
from ultralytics import YOLO

Expand Down Expand Up @@ -534,6 +538,17 @@ def push_to_hfhub(
custom_tags=custom_tags
)

if return_dict:
return {
'score_map50': score_map50,
'score_map50_mask': score_map50_mask,
'score_top1_acc': score_top1_acc,
'score_top5_acc': score_top5_acc,
'task': task,
'model_type': model.type,
'thumbnail_url': f"https://huggingface.co/{hf_model_id}/resolve/main/thumbnail.jpg"
}


def download_from_hub(hf_model_id, hf_token=None):
"""
Expand Down