custom object detetcion model training implementation-colab code

parent 491d914b
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Object_custom_detection.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Se6UIrjf53Bj",
"outputId": "89eb5ab2-4df1-4ff4-daa9-2e31810152e8"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/drive\n"
]
}
],
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
]
},
{
"cell_type": "code",
"source": [
"!ls '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "KsDPBQ0X6F_n",
"outputId": "8db6c9dd-32aa-43cc-988c-c1f5de18d820"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"backup\t\t Custom-Obj-Detection.zip\tdarknet\n",
"Custom-Obj-Detection custom_weight\t\tdata\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#!unzip '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection' -d '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "hEC8x5sJ7Syg",
"outputId": "2dabe77a-b7f4-4729-9a8e-98e0a5582c89"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Archive: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection.zip\n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/ball1.jpg \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/ball1.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/classes.txt \n",
" creating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/data/\n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/data/predefined_classes.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/labelImg.exe \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle1.jpg \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle1.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle2.webp \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle3.jpg \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle3.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle4.jpg \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/rattle4.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/toys.gif \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/toys.txt \n",
" inflating: /content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/Custom-Obj-Detection/traffic.gif \n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git clone 'https://github.com/pjreddie/darknet.git' '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Zzw5sAjT76Ah",
"outputId": "1e849eec-a4fb-4125-8457-4c617bfbee46"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"fatal: destination path '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet' already exists and is not an empty directory.\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"%cd '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "We118bis9Siq",
"outputId": "150e0a2d-e547-4b12-a2b3-2058d80ca7d9"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!ls"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3z7kIkF89aLR",
"outputId": "9ae60110-a91e-4087-990a-8809439e7c7a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"backup\t examples\tLICENSE LICENSE.meta obj scripts\n",
"cfg\t include\tLICENSE.fuck LICENSE.mit python src\n",
"darknet libdarknet.a\tLICENSE.gen LICENSE.v1 README.md\n",
"data\t libdarknet.so\tLICENSE.gpl Makefile\t results\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!make"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xy-2o-hs9tEh",
"outputId": "f28bd0dc-1f9f-4696-b669-2d1a771163d6"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"nvcc -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv` -DGPU -I/usr/local/cuda/include/ -DCUDNN --compiler-options \"-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN\" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o\n",
"nvcc fatal : Unsupported gpu architecture 'compute_30'\n",
"Makefile:92: recipe for target 'obj/convolutional_kernels.o' failed\n",
"make: *** [obj/convolutional_kernels.o] Error 1\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#Exitting from darknet folder to root folder\n",
"%cd '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "64umwmgtFtQw",
"outputId": "a53fe60c-6916-4171-a7bb-bb42a160e791"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Generating Labelled_data.data, train.txt, and test.txt files into the drive"
],
"metadata": {
"id": "Fco55JKMG-vA"
}
},
{
"cell_type": "code",
"source": [
"!python data/creating-files-data-and-name.py"
],
"metadata": {
"id": "IQZXsjaAGL1W"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"! python data/creating-train-and-test-txt-files.py"
],
"metadata": {
"id": "R6O_acp5GpHx"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"%cd '/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet'"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ZXntkLmNMdYm",
"outputId": "fadd9f00-16ce-4ff0-cb0b-122179bbc288"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/Research-Project/Yolo_Custom_Model_Training/darknet\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!darknet/darknet detector train data/labelled_data.data darknet/cfg/yolov3_custom.cfg data/darknet53.conv.74 -dont_show -map"
],
"metadata": {
"id": "1WJokn7fHVOQ",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "e181d309-2b25-4e69-a913-3dd46b490af9"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/bin/bash: darknet/darknet: Not a directory\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!darknet/darknet"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "d-NkCEIMIkL4",
"outputId": "80a032f6-cba7-4efd-de8d-dee7d4f3b484"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/bin/bash: darknet/darknet: No such file or directory\n"
]
}
]
}
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment