Skip to content

Commit

Permalink
Add HUB-SDK docs (#7775)
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Muhammad Rizwan Munawar <chr043416@gmail.com>
  • Loading branch information
3 people committed Jan 23, 2024
1 parent 67ae86f commit 1152a06
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 41 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
INDEXNOW_KEY: ${{ secrets.INDEXNOW_KEY_DOCS }}
WEGLOT_KEY: ${{ secrets.WEGLOT_KEY_DOCS }}
run: |
python docs/build_docs.py
git config --global user.name "Glenn Jocher"
Expand Down
35 changes: 17 additions & 18 deletions docs/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,36 @@

DOCS = Path(__file__).parent.resolve()
SITE = DOCS.parent / "site"
LANGUAGES = False


def build_docs():
def build_docs(use_languages=False, clone_repos=True):
"""Build docs using mkdocs."""
if SITE.exists():
print(f"Removing existing {SITE}")
shutil.rmtree(SITE)

# Get hub-sdk repo
if clone_repos:
repo = "https://github.com/ultralytics/hub-sdk"
local_dir = DOCS.parent / Path(repo).name
if not local_dir.exists():
os.system(f"git clone {repo} {local_dir}")
os.system(f"git -C {local_dir} pull") # update repo
shutil.rmtree(DOCS / "en/hub/sdk")
shutil.copytree(local_dir / "docs", DOCS / "en/hub/sdk")
shutil.rmtree(DOCS / "en/hub/sdk/reference") # temporarily delete reference until we find a solution for this
print(f"Cloned/Updated {repo} in {local_dir}")

# Build the main documentation
print(f"Building docs from {DOCS}")
subprocess.run(f"mkdocs build -f {DOCS}/mkdocs.yml", check=True, shell=True)

# Build other localized documentations
if LANGUAGES:
if use_languages:
for file in DOCS.glob("mkdocs_*.yml"):
print(f"Building MkDocs site with configuration file: {file}")
subprocess.run(f"mkdocs build -f {file}", check=True, shell=True)
update_html_links() # update .md in href links
print(f"Site built at {SITE}")


Expand Down Expand Up @@ -104,21 +116,13 @@ def update_page_title(file_path: Path, new_title: str):
file.write(updated_content)


def update_html_head(key=""):
def update_html_head(script=""):
"""Update the HTML head section of each file."""
html_files = Path(SITE).rglob("*.html")
for html_file in tqdm(html_files, desc="Processing HTML files"):
with html_file.open("r", encoding="utf-8") as file:
html_content = file.read()

script = f"""
<script type="text/javascript" src="https://cdn.weglot.com/weglot.min.js"></script>
<script>
Weglot.initialize({{
api_key: '{key}'
}});
</script>
"""
if script in html_content: # script already in HTML file
return

Expand All @@ -137,13 +141,8 @@ def main():
# Update titles
update_page_title(SITE / "404.html", new_title="Ultralytics Docs - Not Found")

# Update .md in href links
if LANGUAGES:
update_html_links()

# Update HTML file head section
if not LANGUAGES and False:
update_html_head(key=os.environ.get("WEGLOT_KEY"))
# update_html_head("")

# Show command to serve built website
print('Serve site at http://localhost:8000 with "python -m http.server --directory site"')
Expand Down
34 changes: 34 additions & 0 deletions docs/coming_soon_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: Discover what's next for Ultralytics with our under-construction page, previewing new, groundbreaking AI and ML features coming soon.
keywords: Ultralytics, coming soon, under construction, new features, AI updates, ML advancements, YOLO, technology preview
---

# Under Construction 🏗️🌟

Welcome to the Ultralytics "Under Construction" page! Here, we're hard at work developing the next generation of AI and ML innovations. This page serves as a teaser for the exciting updates and new features we're eager to share with you!

## Exciting New Features on the Way 🎉

- **Innovative Breakthroughs:** Get ready for advanced features and services that will transform your AI and ML experience.
- **New Horizons:** Anticipate novel products that redefine AI and ML capabilities.
- **Enhanced Services:** We're upgrading our services for greater efficiency and user-friendliness.

## Stay Updated 🚧

This placeholder page is your first stop for upcoming developments. Keep an eye out for:

- **Newsletter:** Subscribe [here](https://ultralytics.com/#newsletter) for the latest news.
- **Social Media:** Follow us [here](https://www.linkedin.com/company/ultralytics) for updates and teasers.
- **Blog:** Visit our [blog](https://ultralytics.com/blog) for detailed insights.

## We Value Your Input 🗣️

Your feedback shapes our future releases. Share your thoughts and suggestions [here](https://ultralytics.com/contact).

## Thank You, Community! 🌍

Your [contributions](https://docs.ultralytics.com/help/contributing) inspire our continuous [innovation](https://github.com/ultralytics/ultralytics). Stay tuned for the big reveal of what's next in AI and ML at Ultralytics!

---

Excited for what's coming? Bookmark this page and get ready for a transformative AI and ML journey with Ultralytics! 🛠️🤖
34 changes: 34 additions & 0 deletions docs/en/hub/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: Discover what's next for Ultralytics with our under-construction page, previewing new, groundbreaking AI and ML features coming soon.
keywords: Ultralytics, coming soon, under construction, new features, AI updates, ML advancements, YOLO, technology preview
---

# Under Construction 🏗️🌟

Welcome to the Ultralytics "Under Construction" page! Here, we're hard at work developing the next generation of AI and ML innovations. This page serves as a teaser for the exciting updates and new features we're eager to share with you!

## Exciting New Features on the Way 🎉

- **Innovative Breakthroughs:** Get ready for advanced features and services that will transform your AI and ML experience.
- **New Horizons:** Anticipate novel products that redefine AI and ML capabilities.
- **Enhanced Services:** We're upgrading our services for greater efficiency and user-friendliness.

## Stay Updated 🚧

This placeholder page is your first stop for upcoming developments. Keep an eye out for:

- **Newsletter:** Subscribe [here](https://ultralytics.com/#newsletter) for the latest news.
- **Social Media:** Follow us [here](https://www.linkedin.com/company/ultralytics) for updates and teasers.
- **Blog:** Visit our [blog](https://ultralytics.com/blog) for detailed insights.

## We Value Your Input 🗣️

Your feedback shapes our future releases. Share your thoughts and suggestions [here](https://ultralytics.com/contact).

## Thank You, Community! 🌍

Your [contributions](https://docs.ultralytics.com/help/contributing) inspire our continuous [innovation](https://github.com/ultralytics/ultralytics). Stay tuned for the big reveal of what's next in AI and ML at Ultralytics!

---

Excited for what's coming? Bookmark this page and get ready for a transformative AI and ML journey with Ultralytics! 🛠️🤖
2 changes: 1 addition & 1 deletion docs/en/hub/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ We hope that the resources here will help you get the most out of HUB. Please br
- [**Ultralytics HUB App**](app/index.md). Learn about the Ultralytics App for iOS and Android, which allows you to run models directly on your mobile device.
- [**iOS**](app/ios.md). Learn about YOLO CoreML models accelerated on Apple's Neural Engine on iPhones and iPads.
- [**Android**](app/android.md). Explore TFLite acceleration on mobile devices.
- [**Inference API**](inference_api.md). Understand how to use the Inference API for running your trained models in the cloud to generate predictions.
- [**Inference API**](inference-api.md). Understand how to use the Inference API for running your trained models in the cloud to generate predictions.
18 changes: 9 additions & 9 deletions docs/en/hub/inference_api.md → docs/en/hub/inference-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The JSON list contains information about the detected objects, their coordinates

### Detect Model Format

YOLO detection models, such as `yolov8n.pt`, can return JSON responses from local inference, CLI API inference, and Python API inference. All of these methods produce the same JSON response format.
YOLO detection models, such as `yolov8n.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format.

!!! Example "Detect Model JSON Response"

Expand All @@ -122,7 +122,7 @@ YOLO detection models, such as `yolov8n.pt`, can return JSON responses from loca
print(results[0].tojson())
```

=== "CLI API"
=== "CLI"

```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
Expand All @@ -133,7 +133,7 @@ YOLO detection models, such as `yolov8n.pt`, can return JSON responses from loca
-F "iou=0.45"
```

=== "Python API"
=== "Python"

```python
import requests
Expand Down Expand Up @@ -201,7 +201,7 @@ YOLO detection models, such as `yolov8n.pt`, can return JSON responses from loca

### Segment Model Format

YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses from local inference, CLI API inference, and Python API inference. All of these methods produce the same JSON response format.
YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format.

!!! Example "Segment Model JSON Response"

Expand All @@ -220,7 +220,7 @@ YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses fr
print(results[0].tojson())
```

=== "CLI API"
=== "CLI"

```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
Expand All @@ -231,7 +231,7 @@ YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses fr
-F "iou=0.45"
```

=== "Python API"
=== "Python"

```python
import requests
Expand Down Expand Up @@ -342,7 +342,7 @@ YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses fr

### Pose Model Format

YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from local inference, CLI API inference, and Python API inference. All of these methods produce the same JSON response format.
YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format.

!!! Example "Pose Model JSON Response"

Expand All @@ -361,7 +361,7 @@ YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from loca
print(results[0].tojson())
```

=== "CLI API"
=== "CLI"

```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
Expand All @@ -372,7 +372,7 @@ YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from loca
-F "iou=0.45"
```

=== "Python API"
=== "Python"

```python
import requests
Expand Down
2 changes: 1 addition & 1 deletion docs/en/hub/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ You can preview your model if you click on the **Preview** tab and upload an ima

![Ultralytics HUB screenshot of the Preview tab (Test card) inside the Model page](https://raw.githubusercontent.com/ultralytics/assets/main/docs/hub/models/hub_preview_model_1.jpg)

You can also use our Ultralytics Cloud API to effortlessly [run inference](https://docs.ultralytics.com/hub/inference_api) with your custom model.
You can also use our Ultralytics Cloud API to effortlessly [run inference](inference-api.md) with your custom model.

![Ultralytics HUB screenshot of the Preview tab (Ultralytics Cloud API card) inside the Model page](https://raw.githubusercontent.com/ultralytics/assets/main/docs/hub/models/hub_preview_model_2.jpg)

Expand Down
34 changes: 34 additions & 0 deletions docs/en/hub/on-premise/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: Discover what's next for Ultralytics with our under-construction page, previewing new, groundbreaking AI and ML features coming soon.
keywords: Ultralytics, coming soon, under construction, new features, AI updates, ML advancements, YOLO, technology preview
---

# Under Construction 🏗️🌟

Welcome to the Ultralytics "Under Construction" page! Here, we're hard at work developing the next generation of AI and ML innovations. This page serves as a teaser for the exciting updates and new features we're eager to share with you!

## Exciting New Features on the Way 🎉

- **Innovative Breakthroughs:** Get ready for advanced features and services that will transform your AI and ML experience.
- **New Horizons:** Anticipate novel products that redefine AI and ML capabilities.
- **Enhanced Services:** We're upgrading our services for greater efficiency and user-friendliness.

## Stay Updated 🚧

This placeholder page is your first stop for upcoming developments. Keep an eye out for:

- **Newsletter:** Subscribe [here](https://ultralytics.com/#newsletter) for the latest news.
- **Social Media:** Follow us [here](https://www.linkedin.com/company/ultralytics) for updates and teasers.
- **Blog:** Visit our [blog](https://ultralytics.com/blog) for detailed insights.

## We Value Your Input 🗣️

Your feedback shapes our future releases. Share your thoughts and suggestions [here](https://ultralytics.com/contact).

## Thank You, Community! 🌍

Your [contributions](https://docs.ultralytics.com/help/contributing) inspire our continuous [innovation](https://github.com/ultralytics/ultralytics). Stay tuned for the big reveal of what's next in AI and ML at Ultralytics!

---

Excited for what's coming? Bookmark this page and get ready for a transformative AI and ML journey with Ultralytics! 🛠️🤖
2 changes: 1 addition & 1 deletion docs/en/usage/cli.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
comments: true
description: Learn how to use Ultralytics YOLO through Command Line: train models, run predictions and exports models to different formats easily using terminal commands.
description: Learn how to use Ultralytics YOLO through Command Line, train models, run predictions and exports models to different formats easily using terminal commands.
keywords: Ultralytics, YOLO, CLI, train, validation, prediction, command line interface, YOLO CLI, YOLO terminal, model training, prediction, exporting
---

Expand Down
28 changes: 20 additions & 8 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,28 @@ nav:
- TensorBoard: integrations/tensorboard.md
- Amazon SageMaker: integrations/amazon-sagemaker.md
- HUB:
- hub/index.md
- Quickstart: hub/quickstart.md
- Datasets: hub/datasets.md
- Projects: hub/projects.md
- Models: hub/models.md
- Integrations: hub/integrations.md
- Ultralytics HUB App:
- Cloud:
- hub/index.md
- Quickstart: hub/quickstart.md
- Datasets: hub/datasets.md
- Projects: hub/projects.md
- Models: hub/models.md
- Integrations: hub/integrations.md
- Inference API: hub/inference-api.md
- On Premise:
- hub/on-premise/index.md
- App:
- hub/app/index.md
- iOS: hub/app/ios.md
- Android: hub/app/android.md
- Inference API: hub/inference_api.md
- Python SDK:
- hub/sdk/index.md
- Quickstart: hub/sdk/quickstart.md
- Model: hub/sdk/model.md
- Dataset: hub/sdk/dataset.md
- Project: hub/sdk/project.md
- REST API:
- hub/api/index.md

- Reference:
- cfg:
Expand Down Expand Up @@ -542,6 +553,7 @@ plugins:
quick-start.md: quickstart.md
app.md: hub/app/index.md
sdk.md: index.md
hub/inference_api.md: hub/inference-api.md
usage/hyperparameter_tuning.md: integrations/ray-tune.md
reference/base_pred.md: reference/engine/predictor.md
reference/base_trainer.md: reference/engine/trainer.md
Expand Down
4 changes: 2 additions & 2 deletions ultralytics/engine/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def predict(self, source=None, stream=False, predictor=None, **kwargs):
x in sys.argv for x in ("predict", "track", "mode=predict", "mode=track")
)

custom = {"conf": 0.25, "save": is_cli} # method defaults
args = {**self.overrides, **custom, **kwargs, "mode": "predict"} # highest priority args on the right
custom = {"conf": 0.25, "save": is_cli, "mode": "predict"} # method defaults
args = {**self.overrides, **custom, **kwargs} # highest priority args on the right
prompts = args.pop("prompts", None) # for SAM-type models

if not self.predictor:
Expand Down

0 comments on commit 1152a06

Please sign in to comment.