245 lines
758 KiB
Plaintext
245 lines
758 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import ultralytics\n",
|
||
|
"from ultralytics import YOLO\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 39,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from PIL import Image\n",
|
||
|
"from IPython.display import display\n",
|
||
|
"import cv2\n",
|
||
|
"import numpy as np"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Ultralytics YOLOv8.0.215 🚀 Python-3.9.18 torch-2.1.1+cpu CPU (11th Gen Intel Core(TM) i7-11800H 2.30GHz)\n",
|
||
|
"Setup complete ✅ (16 CPUs, 63.7 GB RAM, 14.9/1907.7 GB disk)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ultralytics.checks()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"model = YOLO(\"best.pt\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Rozwiązanie bazowe na fragmencie ze zbioru testowego"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"file_in = \"IMG_0983\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\n",
|
||
|
"image 1/1 e:\\gonito_tomato\\dev-0\\in\\IMG_0983.jpg: 640x480 4 b_greens, 539.1ms\n",
|
||
|
"Speed: 3.0ms preprocess, 539.1ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 480)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"img = \"dev-0/in/\" + file_in + \".jpg\"\n",
|
||
|
"pred_image = model.predict(conf=0.5, source=img)\n",
|
||
|
"result = pred_image[0]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"image = cv2.imread(img)\n",
|
||
|
"# Convert image to uint8 data type\n",
|
||
|
"image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
|
||
|
"image = np.array(image, dtype=np.uint8)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"for box in result.boxes:\n",
|
||
|
" cords =box.xyxy[0].tolist()\n",
|
||
|
" class_id =box.cls[0].item()\n",
|
||
|
" conf = box.conf[0].item()\n",
|
||
|
" start = (int(cords[0]),int(cords[1])) # x0, y0\n",
|
||
|
" end = (int(cords[2]),int(cords[3])) # x1, y1\n",
|
||
|
" text = result.names[class_id]\n",
|
||
|
" text_size = cv2.getTextSize(text, cv2.FONT_HERSHEY_DUPLEX, 1.9, 2)[0]\n",
|
||
|
" rectangle_position = (start[0], start[1] - text_size[1] - 10)\n",
|
||
|
" rectangle_size = (text_size[0] + 30, text_size[1] + 20)\n",
|
||
|
" cv2.rectangle(image, rectangle_position, (rectangle_position[0] + rectangle_size[0], rectangle_position[1] + rectangle_size[1]), (255, 255, 255), -1)\n",
|
||
|
"\n",
|
||
|
" # Draw the bounding box\n",
|
||
|
" cv2.rectangle(image, start, end, (0, 200, 0), thickness=2)\n",
|
||
|
"\n",
|
||
|
" # Put the text on top of the highlighted background\n",
|
||
|
" cv2.putText(image, text, (start[0] + 15, start[1] - 5), cv2.FONT_HERSHEY_DUPLEX, 1.9, (10, 0, 10), 2) # show detection objects on image# show detection objects on image"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"tensor([2., 2., 2., 2.])"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"result.boxes.cls"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQgJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAJYAcIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R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zRYAC9S4VirdYajYk42EDHWi0g/vnTUqHU6e7lctT+i97oeaVUSzScrZWPctmTsGTRDjPPosnnz3gi3II0uRyT3O4GAjE
|
||
|
"text/plain": [
|
||
|
"<PIL.Image.Image image mode=RGB size=450x600>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"picture = Image.fromarray(image)\n",
|
||
|
"desired_size = (700, 600)\n",
|
||
|
"picture.thumbnail(desired_size)\n",
|
||
|
"# Display the image\n",
|
||
|
"display(picture)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Metric for GONITO - mean average precision"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 40,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Ultralytics YOLOv8.0.215 🚀 Python-3.9.18 torch-2.1.1+cpu CPU (11th Gen Intel Core(TM) i7-11800H 2.30GHz)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\u001b[34m\u001b[1mval: \u001b[0mScanning E:\\tomAIto\\model\\datasets\\val\\labels.cache... 161 images, 0 backgrounds, 0 corrupt: 100%|██████████| 161/161 [00:00<?, ?it/s]\n",
|
||
|
" Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 11/11 [02:00<00:00, 10.93s/it]\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
" all 161 1996 0.814 0.835 0.88 0.786\n",
|
||
|
" b_fully_ripened 161 72 0.799 0.778 0.854 0.788\n",
|
||
|
" b_half_ripened 161 116 0.78 0.819 0.844 0.765\n",
|
||
|
" b_green 161 387 0.861 0.928 0.956 0.847\n",
|
||
|
" l_fully_ripened 161 269 0.803 0.835 0.878 0.79\n",
|
||
|
" l_half_ripened 161 223 0.758 0.776 0.819 0.735\n",
|
||
|
" l_green 161 929 0.881 0.873 0.928 0.791\n",
|
||
|
"Speed: 2.0ms preprocess, 629.8ms inference, 0.0ms loss, 0.4ms postprocess per image\n",
|
||
|
"Results saved to \u001b[1mruns\\detect\\val6\u001b[0m\n",
|
||
|
"0.786025264281105\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"metrics = model.val(data='dataset.yaml')\n",
|
||
|
"mAP = metrics.box.ap.mean()\n",
|
||
|
"print(mAP)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "base",
|
||
|
"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.18"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|