Instructions to use dl1wjd2/Logistics_AX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use dl1wjd2/Logistics_AX with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("dl1wjd2/Logistics_AX", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
File size: 10,374 Bytes
c12ef43 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | # Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains commands to manage webhooks on the Hugging Face Hub."""
import enum
from typing import Annotated, get_args, get_type_hints
import click
from huggingface_hub.constants import WEBHOOK_DOMAIN_T
from huggingface_hub.hf_api import WebhookWatchedItem
from ._cli_utils import (
SecretsFileOpt,
SecretsOpt,
TokenOpt,
get_hf_api,
parse_env_map,
typer_factory,
)
from ._framework import Argument, Option
from ._output import out
# Build enums dynamically from Literal types to avoid duplication
_WATCHED_TYPES = get_args(get_type_hints(WebhookWatchedItem)["type"])
WatchedItemType = enum.Enum("WatchedItemType", {t: t for t in _WATCHED_TYPES}, type=str) # type: ignore[misc]
_DOMAIN_TYPES = get_args(WEBHOOK_DOMAIN_T)
WebhookDomain = enum.Enum("WebhookDomain", {d: d for d in _DOMAIN_TYPES}, type=str) # type: ignore[misc]
def _parse_watch(values: list[str]) -> list[WebhookWatchedItem]:
"""Parse 'type:name' strings into WebhookWatchedItem objects.
Args:
values: List of strings in the format 'type:name'
(e.g., 'model:bert-base-uncased', 'org:HuggingFace').
Returns:
List of WebhookWatchedItem objects.
Raises:
click.BadParameter: If any value doesn't match the expected format.
"""
items = []
valid_types = tuple(_WATCHED_TYPES)
for v in values:
if ":" not in v:
raise click.BadParameter(
f"Expected format 'type:name' (e.g. 'model:bert-base-uncased'), got '{v}'."
f" Valid types: {', '.join(valid_types)}."
)
kind, name = v.split(":", 1)
if kind not in valid_types:
raise click.BadParameter(f"Invalid type '{kind}'. Valid types: {', '.join(valid_types)}.")
items.append(WebhookWatchedItem(type=kind, name=name)) # type: ignore
return items
def _parse_job_secrets(
secrets: list[str] | None, secrets_file: str | None, job_id: str | None
) -> dict[str, str] | None:
"""Parse `--secrets` / `--secrets-file` for the Job triggered by a webhook (requires `--job-id`)."""
secrets_map = parse_env_map(secrets, secrets_file)
if not secrets_map:
return None
if job_id is None:
raise click.BadParameter("--secrets and --secrets-file require --job-id.")
return {key: value or "" for key, value in secrets_map.items()}
webhooks_cli = typer_factory(help="Manage webhooks on the Hub.")
@webhooks_cli.command(
"list | ls",
examples=[
"hf webhooks ls",
"hf webhooks ls --format json",
"hf webhooks ls --format quiet",
],
)
def webhooks_ls(
token: TokenOpt = None,
) -> None:
"""List all webhooks for the current user."""
api = get_hf_api(token=token)
results = [
{
"id": w.id,
"url": w.url or "(job)",
"disabled": w.disabled,
"domains": w.domains or [],
"watched": [f"{wi.type}:{wi.name}" for wi in (w.watched or [])],
}
for w in api.list_webhooks()
]
out.table(results)
@webhooks_cli.command(
"info",
examples=[
"hf webhooks info abc123",
],
)
def webhooks_info(
webhook_id: Annotated[str, Argument(help="The ID of the webhook.")],
token: TokenOpt = None,
) -> None:
"""Show full details for a single webhook."""
api = get_hf_api(token=token)
webhook = api.get_webhook(webhook_id)
out.dict(webhook)
@webhooks_cli.command(
"create",
examples=[
"hf webhooks create --url https://example.com/hook --watch model:bert-base-uncased",
"hf webhooks create --url https://example.com/hook --watch org:HuggingFace --watch model:gpt2 --domain repo",
"hf webhooks create --job-id 687f911eaea852de79c4a50a --watch user:julien-c",
"hf webhooks create --job-id 687f911eaea852de79c4a50a --watch bucket:my-org/my-bucket --secrets HF_TOKEN",
],
)
def webhooks_create(
watch: Annotated[
list[str],
Option(
"--watch",
help="Item to watch, in 'type:name' format (e.g. 'model:bert-base-uncased'). Repeatable.",
),
],
url: Annotated[
str | None,
Option(help="URL to send webhook payloads to. Mutually exclusive with --job-id."),
] = None,
job_id: Annotated[
str | None,
Option(
"--job-id",
help="ID of a Job to trigger (from job.id) instead of pinging a URL. Mutually exclusive with --url.",
),
] = None,
domain: Annotated[
list[WebhookDomain] | None,
Option(
"--domain",
help="Domain to watch: 'repo' or 'discussions'. Repeatable. Defaults to all domains.",
),
] = None,
secret: Annotated[
str | None,
Option(help="Optional secret used to sign webhook payloads."),
] = None,
secrets: SecretsOpt = None,
secrets_file: SecretsFileOpt = None,
token: TokenOpt = None,
) -> None:
"""Create a new webhook.
Provide either --url (to ping a remote server) or --job-id (to trigger a Job), but not both.
The source Job's secrets are not copied to the webhook: pass them again with --secrets / --secrets-file.
"""
if url is not None and job_id is not None:
raise click.BadParameter("Provide either --url or --job-id, not both.")
if url is None and job_id is None:
raise click.BadParameter("Provide either --url or --job-id.")
job_secrets = _parse_job_secrets(secrets, secrets_file, job_id)
api = get_hf_api(token=token)
watched_items = _parse_watch(watch)
domains = [d.value for d in domain] if domain else None
webhook = api.create_webhook(
url=url,
job_id=job_id,
watched=watched_items, # type: ignore
domains=domains, # type: ignore
secret=secret,
secrets=job_secrets,
)
out.result("Webhook created", id=webhook.id)
@webhooks_cli.command(
"update",
examples=[
"hf webhooks update abc123 --url https://new-url.com/hook",
"hf webhooks update abc123 --watch model:gpt2 --domain repo",
"hf webhooks update abc123 --secret newsecret",
"hf webhooks update abc123 --job-id 687f911eaea852de79c4a50a --secrets HF_TOKEN",
],
)
def webhooks_update(
webhook_id: Annotated[str, Argument(help="The ID of the webhook to update.")],
url: Annotated[
str | None,
Option(help="New URL to send webhook payloads to."),
] = None,
job_id: Annotated[
str | None,
Option(
"--job-id",
help="ID of the source Job to trigger (can be the current one). Required with --secrets / --secrets-file.",
),
] = None,
watch: Annotated[
list[str] | None,
Option(
"--watch",
help=(
"New list of items to watch, in 'type:name' format. "
"Repeatable. Replaces the entire existing watched list."
),
),
] = None,
domain: Annotated[
list[WebhookDomain] | None,
Option(
"--domain",
help="New list of domains to watch: 'repo' or 'discussions'. Repeatable.",
),
] = None,
secret: Annotated[
str | None,
Option(help="New secret used to sign webhook payloads."),
] = None,
secrets: SecretsOpt = None,
secrets_file: SecretsFileOpt = None,
token: TokenOpt = None,
) -> None:
"""Update an existing webhook. Only provided options are changed.
Job secrets passed with --secrets replace stored values with the same name; others are kept.
"""
if url is not None and job_id is not None:
raise click.BadParameter("Provide either --url or --job-id, not both.")
job_secrets = _parse_job_secrets(secrets, secrets_file, job_id)
api = get_hf_api(token=token)
watched_items = _parse_watch(watch) if watch else None
domains = [d.value for d in domain] if domain else None
webhook = api.update_webhook(
webhook_id,
url=url,
job_id=job_id,
watched=watched_items, # type: ignore
domains=domains, # type: ignore
secret=secret,
secrets=job_secrets,
)
out.result("Webhook updated", id=webhook.id)
@webhooks_cli.command(
"enable",
examples=[
"hf webhooks enable abc123",
],
)
def webhooks_enable(
webhook_id: Annotated[str, Argument(help="The ID of the webhook to enable.")],
token: TokenOpt = None,
) -> None:
"""Enable a disabled webhook."""
api = get_hf_api(token=token)
webhook = api.enable_webhook(webhook_id)
out.result("Webhook enabled", id=webhook.id)
@webhooks_cli.command(
"disable",
examples=[
"hf webhooks disable abc123",
],
)
def webhooks_disable(
webhook_id: Annotated[str, Argument(help="The ID of the webhook to disable.")],
token: TokenOpt = None,
) -> None:
"""Disable an active webhook."""
api = get_hf_api(token=token)
webhook = api.disable_webhook(webhook_id)
out.result("Webhook disabled", id=webhook.id)
@webhooks_cli.command(
"delete",
examples=[
"hf webhooks delete abc123",
"hf webhooks delete abc123 --yes",
],
)
def webhooks_delete(
webhook_id: Annotated[str, Argument(help="The ID of the webhook to delete.")],
yes: Annotated[
bool,
Option(
"--yes",
"-y",
help="Skip confirmation prompt.",
),
] = False,
token: TokenOpt = None,
) -> None:
"""Delete a webhook permanently."""
out.confirm(f"Are you sure you want to delete webhook '{webhook_id}'?", yes=yes)
api = get_hf_api(token=token)
api.delete_webhook(webhook_id)
out.result("Webhook deleted", id=webhook_id)
|