Skip to content

Commit

Permalink
fix some typos in docs/cards (#23)
Browse files Browse the repository at this point in the history
* improve model card

* increase version
  • Loading branch information
fcakyon authored Jan 17, 2023
1 parent 8fb9c9d commit 7179028
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ result = results[0]
boxes = result.boxes.xyxy # x1, y1, x2, y2
scores = result.boxes.conf
categories = result.boxes.cls
scores = result.probs # for classification models
masks = result.masks # for segmentation models

# show results on image
render = render_result(result)
Expand Down
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.11"
__version__ = "0.0.12"
26 changes: 14 additions & 12 deletions ultralyticsplus/hf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def generate_model_usage_markdown(

if hf_task == "image-segmentation":
import_str = "from ultralyticsplus import YOLO, render_result"
postprocess_str = """ print(result.boxes)
print(result.masks)
render = render_result(model=model, image=image, result=result)
render.show()"""
postprocess_str = """print(results[0].boxes)
print(results[0].masks)
render = render_result(model=model, image=image, result=results[0])
render.show()"""
model_params_str = """model.overrides['conf'] = 0.25 # NMS confidence threshold
model.overrides['iou'] = 0.45 # NMS IoU threshold
model.overrides['agnostic_nms'] = False # NMS class-agnostic
Expand All @@ -50,9 +50,9 @@ def generate_model_usage_markdown(

elif hf_task == "object-detection":
import_str = "from ultralyticsplus import YOLO, render_result"
postprocess_str = """ print(result.boxes)
render = render_result(model=model, image=image, result=result)
render.show()"""
postprocess_str = """print(results[0].boxes)
render = render_result(model=model, image=image, result=results[0])
render.show()"""
model_params_str = """model.overrides['conf'] = 0.25 # NMS confidence threshold
model.overrides['iou'] = 0.45 # NMS IoU threshold
model.overrides['agnostic_nms'] = False # NMS class-agnostic
Expand All @@ -63,9 +63,9 @@ def generate_model_usage_markdown(

elif hf_task == "image-classification":
import_str = "from ultralyticsplus import YOLO, postprocess_classify_output"
postprocess_str = """ print(result.probs) # [0.1, 0.2, 0.3, 0.4]
processed_result = postprocess_classify_output(model, result=result)
print(processed_result) # {"cat": 0.4, "dog": 0.6}"""
postprocess_str = """print(results[0].probs) # [0.1, 0.2, 0.3, 0.4]
processed_result = postprocess_classify_output(model, result=results[0])
print(processed_result) # {"cat": 0.4, "dog": 0.6}"""
model_params_str = """model.overrides['conf'] = 0.25 # model confidence threshold"""
metrics_str = f""" - type: accuracy
value: {score_top1_acc} # min: 0.0 - max: 1.0
Expand All @@ -74,8 +74,8 @@ def generate_model_usage_markdown(
value: {score_top5_acc} # min: 0.0 - max: 1.0
name: top5 accuracy"""

custom_tags_str = ''
if custom_tags:
custom_tags_str = ''
for ind, custom_tag in enumerate(custom_tags):
custom_tags_str += f"- {custom_tag}"
if ind != len(custom_tags) - 1:
Expand Down Expand Up @@ -152,7 +152,9 @@ def generate_model_usage_markdown(
image = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
# perform inference
for result in model.predict(image, return_outputs=True):
results = model.predict(image)
# observe results
{postprocess_str}
```
Expand Down

0 comments on commit 7179028

Please sign in to comment.