{ "cells": [ { "cell_type": "code", "execution_count": 140, "metadata": {}, "outputs": [], "source": [ "from ultralyticsplus import YOLO, render_result" ] }, { "cell_type": "code", "execution_count": 141, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading https://dl.ndl.go.jp/api/iiif/1879314/R0000039/full/640,640/0/default.jpg to 'default.jpg'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 152k/152k [00:00<00:00, 6.69MB/s]\n" ] } ], "source": [ "# load model\n", "model = YOLO('best.pt')\n", "# model = YOLO(\"nakamura196/yolov8s-layout-detection\")\n", "\n", "# set image\n", "image = \"https://dl.ndl.go.jp/api/iiif/1879314/R0000039/full/640,640/0/default.jpg\"\n", "\n", "filename = image.split(\"/\")[-1]\n", "\n", "import os\n", "\n", "if image.startswith(\"http\"):\n", "\n", " os.remove(filename)\n", "\n", "# perform inference\n", "results = model.predict(image, conf=0.25, verbose=False)\n", "\n", "# observe results\n", "render = render_result(model=model, image=image, result=results[0])\n", "render.show()" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.11" } }, "nbformat": 4, "nbformat_minor": 2 }