ultralytics 8.2.23 New YouTube Shorts inference (#13150)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Erfan Zekri Esfahani <40582518+eze1376@users.noreply.github.com>
This commit is contained in:
parent
c371c953d5
commit
22de23ec8d
7 changed files with 34 additions and 22 deletions
|
|
@ -62,8 +62,9 @@ The Triton Model Repository is a storage location where Triton can access and lo
|
|||
from pathlib import Path
|
||||
|
||||
# Define paths
|
||||
model_name = "yolo"
|
||||
triton_repo_path = Path("tmp") / "triton_repo"
|
||||
triton_model_path = triton_repo_path / "yolo"
|
||||
triton_model_path = triton_repo_path / model_name
|
||||
|
||||
# Create directories
|
||||
(triton_model_path / "1").mkdir(parents=True, exist_ok=True)
|
||||
|
|
@ -86,6 +87,7 @@ The Triton Model Repository is a storage location where Triton can access and lo
|
|||
Run the Triton Inference Server using Docker:
|
||||
|
||||
```python
|
||||
import contextlib
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ The arguments provided when using [export](../modes/export.md) for an Ultralytic
|
|||
|
||||
- `workspace` : Controls the size (in GiB) of the device memory allocation while converting the model weights.
|
||||
|
||||
- Aim to use the <u>minimum</u> `workspace` value required as this prevents testing algorithms that require more `workspace` from being considered by the TensorRT builder. Setting a higher value for `workspace` may take **considerably longer** to calibrate and export.
|
||||
- Adjust the `workspace` value according to your calibration needs and resource availability. While a larger `workspace` may increase calibration time, it allows TensorRT to explore a wider range of optimization tactics, potentially enhancing model performance and accuracy. Conversely, a smaller `workspace` can reduce calibration time but may limit the optimization strategies, affecting the quality of the quantized model.
|
||||
|
||||
- Default is `workspace=4` (GiB), this value may need to be increased if calibration crashes (exits without warning).
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# Material theme, define the navigation structure, and enable various plugins.
|
||||
|
||||
# Site metadata
|
||||
site_name: Ultralytics YOLOv8 Docs
|
||||
site_description: Explore Ultralytics YOLOv8, a cutting-edge real-time object detection and image segmentation model for various applications and hardware platforms.
|
||||
site_name: Ultralytics YOLO Docs
|
||||
site_description: Explore Ultralytics YOLO, a cutting-edge real-time object detection and image segmentation model for various applications and hardware platforms.
|
||||
site_url: https://docs.ultralytics.com
|
||||
site_author: Ultralytics
|
||||
repo_url: https://github.com/ultralytics/ultralytics
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from pathlib import Path
|
|||
import cv2
|
||||
import numpy as np
|
||||
import pytest
|
||||
import requests
|
||||
import torch
|
||||
import yaml
|
||||
from PIL import Image
|
||||
|
|
@ -20,7 +19,6 @@ from ultralytics.utils import (
|
|||
ASSETS,
|
||||
DEFAULT_CFG,
|
||||
DEFAULT_CFG_PATH,
|
||||
LOGGER,
|
||||
ONLINE,
|
||||
ROOT,
|
||||
WEIGHTS_DIR,
|
||||
|
|
@ -135,15 +133,10 @@ def test_youtube():
|
|||
"""
|
||||
Test YouTube inference.
|
||||
|
||||
Note: YouTube connection errors frequently occur during this test due to
|
||||
the nature of network instability or YouTube server availability issues.
|
||||
These errors are caught and logged to avoid test failures caused by external factors.
|
||||
Note: ConnectionError may occur during this test due to network instability or YouTube server availability.
|
||||
"""
|
||||
model = YOLO(MODEL)
|
||||
try:
|
||||
model.predict("https://youtu.be/G17sBkb38XQ", imgsz=96, save=True)
|
||||
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as e:
|
||||
LOGGER.warning(f"YouTube connection error: {e}")
|
||||
model.predict("https://youtu.be/G17sBkb38XQ", imgsz=96, save=True)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not ONLINE, reason="environment is offline")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.2.22"
|
||||
__version__ = "8.2.23"
|
||||
|
||||
from ultralytics.data.explorer.explorer import Explorer
|
||||
from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ class LoadImagesAndVideos:
|
|||
paths, imgs, info = [], [], []
|
||||
while len(imgs) < self.bs:
|
||||
if self.count >= self.nf: # end of file list
|
||||
if len(imgs) > 0:
|
||||
if imgs:
|
||||
return paths, imgs, info # return last partial batch
|
||||
else:
|
||||
raise StopIteration
|
||||
|
|
@ -522,26 +522,43 @@ def autocast_list(source):
|
|||
return files
|
||||
|
||||
|
||||
def get_best_youtube_url(url, use_pafy=True):
|
||||
def get_best_youtube_url(url, method="pytube"):
|
||||
"""
|
||||
Retrieves the URL of the best quality MP4 video stream from a given YouTube video.
|
||||
|
||||
This function uses the pafy or yt_dlp library to extract the video info from YouTube. It then finds the highest
|
||||
quality MP4 format that has video codec but no audio codec, and returns the URL of this video stream.
|
||||
This function uses the specified method to extract the video info from YouTube. It supports the following methods:
|
||||
- "pytube": Uses the pytube library to fetch the video streams.
|
||||
- "pafy": Uses the pafy library to fetch the video streams.
|
||||
- "yt-dlp": Uses the yt-dlp library to fetch the video streams.
|
||||
|
||||
The function then finds the highest quality MP4 format that has a video codec but no audio codec, and returns the
|
||||
URL of this video stream.
|
||||
|
||||
Args:
|
||||
url (str): The URL of the YouTube video.
|
||||
use_pafy (bool): Use the pafy package, default=True, otherwise use yt_dlp package.
|
||||
method (str): The method to use for extracting video info. Default is "pytube". Other options are "pafy" and
|
||||
"yt-dlp".
|
||||
|
||||
Returns:
|
||||
(str): The URL of the best quality MP4 video stream, or None if no suitable stream is found.
|
||||
"""
|
||||
if use_pafy:
|
||||
if method == "pytube":
|
||||
check_requirements("pytube")
|
||||
from pytube import YouTube
|
||||
|
||||
streams = YouTube(url).streams.filter(file_extension="mp4", only_video=True)
|
||||
streams = sorted(streams, key=lambda s: s.resolution, reverse=True) # sort streams by resolution
|
||||
for stream in streams:
|
||||
if stream.resolution and int(stream.resolution[:-1]) >= 1080: # check if resolution is at least 1080p
|
||||
return stream.url
|
||||
|
||||
elif method == "pafy":
|
||||
check_requirements(("pafy", "youtube_dl==2020.12.2"))
|
||||
import pafy # noqa
|
||||
|
||||
return pafy.new(url).getbestvideo(preftype="mp4").url
|
||||
else:
|
||||
|
||||
elif method == "yt-dlp":
|
||||
check_requirements("yt-dlp")
|
||||
import yt_dlp
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from ultralytics.utils.checks import check_file, check_font, is_ascii
|
|||
from ultralytics.utils.downloads import download, safe_download, unzip_file
|
||||
from ultralytics.utils.ops import segments2boxes
|
||||
|
||||
HELP_URL = "See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance."
|
||||
HELP_URL = "See https://docs.ultralytics.com/datasets for dataset formatting guidance."
|
||||
IMG_FORMATS = {"bmp", "dng", "jpeg", "jpg", "mpo", "png", "tif", "tiff", "webp", "pfm"} # image suffixes
|
||||
VID_FORMATS = {"asf", "avi", "gif", "m4v", "mkv", "mov", "mp4", "mpeg", "mpg", "ts", "wmv", "webm"} # video suffixes
|
||||
PIN_MEMORY = str(os.getenv("PIN_MEMORY", True)).lower() == "true" # global pin_memory for dataloaders
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue