Skip to content

Instantly share code, notes, and snippets.

@mayrajeo
Created February 28, 2023 08:49
Show Gist options
  • Select an option

  • Save mayrajeo/033e842b7593e58135c7694944905937 to your computer and use it in GitHub Desktop.

Select an option

Save mayrajeo/033e842b7593e58135c7694944905937 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "04632e4e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/mayrajeo/miniconda3/envs/ml-env/lib/python3.9/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from sahi import AutoDetectionModel\n",
"from sahi.utils.cv import read_image\n",
"from sahi.utils.file import download_from_url\n",
"from sahi.predict import get_prediction, get_sliced_prediction, predict\n",
"from IPython.display import Image\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3dc9a647",
"metadata": {},
"outputs": [],
"source": [
"yolov8_model_path = '../yolo_models/yolov8s.pt'\n",
"\n",
"download_from_url('https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/small-vehicles1.jpeg', 'demo_data/small-vehicles1.jpeg')\n",
"download_from_url('https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/terrain2.png', 'demo_data/terrain2.png')"
]
},
{
"cell_type": "markdown",
"id": "fc839155",
"metadata": {},
"source": [
"# How the predictions should look like"
]
},
{
"cell_type": "markdown",
"id": "e954153d",
"metadata": {},
"source": [
"Raw predictions"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "2eed4440",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Ultralytics YOLOv8.0.43 🚀 Python-3.9.0 torch-1.13.1.post200 CUDA:0 (NVIDIA RTX A2000 8GB Laptop GPU, 8192MiB)\n",
"YOLOv8s summary (fused): 168 layers, 11156544 parameters, 0 gradients, 28.6 GFLOPs\n",
"\n",
"image 1/1 /mnt/d/Users/E1005164/articles/ship-detection/nbs/demo_data/apple_tree.jpg: 640x640 45 apples, 41.0ms\n",
"Speed: 3.7ms preprocess, 41.0ms inference, 2.1ms postprocess per image at shape (1, 3, 640, 640)\n"
]
},
{
"data": {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment