diff --git a/Simple Object Detection/Images/single_object_detection_using_tensorflow_keras.ipynb b/Simple Object Detection/Images/single_object_detection_using_tensorflow_keras.ipynb
deleted file mode 100644
index 819da3f6b..000000000
--- a/Simple Object Detection/Images/single_object_detection_using_tensorflow_keras.ipynb
+++ /dev/null
@@ -1,2366 +0,0 @@
-{
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "name": "python3"
- },
- "language_info": {
- "pygments_lexer": "ipython3",
- "nbconvert_exporter": "python",
- "version": "3.6.4",
- "file_extension": ".py",
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "name": "python",
- "mimetype": "text/x-python"
- },
- "kaggle": {
- "accelerator": "gpu",
- "dataSources": [
- {
- "sourceId": 1547420,
- "sourceType": "datasetVersion",
- "datasetId": 913037
- }
- ],
- "dockerImageVersionId": 30121,
- "isInternetEnabled": true,
- "language": "python",
- "sourceType": "notebook",
- "isGpuEnabled": true
- },
- "colab": {
- "provenance": [],
- "toc_visible": true,
- "gpuType": "T4"
- },
- "accelerator": "GPU"
- },
- "nbformat_minor": 0,
- "nbformat": 4,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- "# Importing Libraries"
- ],
- "metadata": {
- "id": "Z51WBHI2J6DI"
- }
- },
- {
- "cell_type": "code",
- "source": [
- "import os\n",
- "import pandas as pd\n",
- "import numpy as np\n",
- "import seaborn as sns\n",
- "from bs4 import BeautifulSoup\n",
- "import matplotlib.pyplot as plt\n",
- "import tensorflow as tf\n",
- "import matplotlib.patches as mpatches"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2021-08-07T05:02:48.685095Z",
- "iopub.execute_input": "2021-08-07T05:02:48.685435Z",
- "iopub.status.idle": "2021-08-07T05:02:53.491802Z",
- "shell.execute_reply.started": "2021-08-07T05:02:48.685357Z",
- "shell.execute_reply": "2021-08-07T05:02:53.491014Z"
- },
- "trusted": true,
- "id": "9HVuTFYpJs86"
- },
- "execution_count": 1,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Loading Dataset"
- ],
- "metadata": {
- "id": "UfvlqFc3J_Uj"
- }
- },
- {
- "cell_type": "code",
- "source": [
- "!unzip /content/archive.zip"
- ],
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "collapsed": true,
- "id": "Tw_nd-mWJ0I2",
- "outputId": "921a8801-9629-45e8-ef5d-e5aaa4582658"
- },
- "execution_count": 2,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Archive: /content/archive.zip\n",
- " inflating: datasets/annotations/a (1).xml \n",
- " inflating: datasets/annotations/a (10).xml \n",
- " inflating: datasets/annotations/a (100).xml \n",
- " inflating: datasets/annotations/a (101).xml \n",
- " inflating: datasets/annotations/a (102).xml \n",
- " inflating: datasets/annotations/a (103).xml \n",
- " inflating: datasets/annotations/a (104).xml \n",
- " inflating: datasets/annotations/a (105).xml \n",
- " inflating: datasets/annotations/a (106).xml \n",
- " inflating: datasets/annotations/a (107).xml \n",
- " inflating: datasets/annotations/a (108).xml \n",
- " inflating: datasets/annotations/a (109).xml \n",
- " inflating: datasets/annotations/a (11).xml \n",
- " inflating: datasets/annotations/a (110).xml \n",
- " inflating: datasets/annotations/a (111).xml \n",
- " inflating: datasets/annotations/a (112).xml \n",
- " inflating: datasets/annotations/a (12).xml \n",
- " inflating: datasets/annotations/a (13).xml \n",
- " inflating: datasets/annotations/a (14).xml \n",
- " inflating: datasets/annotations/a (15).xml \n",
- " inflating: datasets/annotations/a (16).xml \n",
- " inflating: datasets/annotations/a (17).xml \n",
- " inflating: datasets/annotations/a (18).xml \n",
- " inflating: datasets/annotations/a (19).xml \n",
- " inflating: datasets/annotations/a (2).xml \n",
- " inflating: datasets/annotations/a (20).xml \n",
- " inflating: datasets/annotations/a (21).xml \n",
- " inflating: datasets/annotations/a (22).xml \n",
- " inflating: datasets/annotations/a (23).xml \n",
- " inflating: datasets/annotations/a (24).xml \n",
- " inflating: datasets/annotations/a (25).xml \n",
- " inflating: datasets/annotations/a (26).xml \n",
- " inflating: datasets/annotations/a (27).xml \n",
- " inflating: datasets/annotations/a (28).xml \n",
- " inflating: datasets/annotations/a (29).xml \n",
- " inflating: datasets/annotations/a (3).xml \n",
- " inflating: datasets/annotations/a (30).xml \n",
- " inflating: datasets/annotations/a (31).xml \n",
- " inflating: datasets/annotations/a (32).xml \n",
- " inflating: datasets/annotations/a (33).xml \n",
- " inflating: datasets/annotations/a (34).xml \n",
- " inflating: datasets/annotations/a (35).xml \n",
- " inflating: datasets/annotations/a (36).xml \n",
- " inflating: datasets/annotations/a (37).xml \n",
- " inflating: datasets/annotations/a (38).xml \n",
- " inflating: datasets/annotations/a (39).xml \n",
- " inflating: datasets/annotations/a (4).xml \n",
- " inflating: datasets/annotations/a (40).xml \n",
- " inflating: datasets/annotations/a (41).xml \n",
- " inflating: datasets/annotations/a (42).xml \n",
- " inflating: datasets/annotations/a (43).xml \n",
- " inflating: datasets/annotations/a (44).xml \n",
- " inflating: datasets/annotations/a (45).xml \n",
- " inflating: datasets/annotations/a (46).xml \n",
- " inflating: datasets/annotations/a (47).xml \n",
- " inflating: datasets/annotations/a (48).xml \n",
- " inflating: datasets/annotations/a (49).xml \n",
- " inflating: datasets/annotations/a (5).xml \n",
- " inflating: datasets/annotations/a (50).xml \n",
- " inflating: datasets/annotations/a (51).xml \n",
- " inflating: datasets/annotations/a (52).xml \n",
- " inflating: datasets/annotations/a (53).xml \n",
- " inflating: datasets/annotations/a (54).xml \n",
- " inflating: datasets/annotations/a (55).xml \n",
- " inflating: datasets/annotations/a (56).xml \n",
- " inflating: datasets/annotations/a (57).xml \n",
- " inflating: datasets/annotations/a (58).xml \n",
- " inflating: datasets/annotations/a (59).xml \n",
- " inflating: datasets/annotations/a (6).xml \n",
- " inflating: datasets/annotations/a (60).xml \n",
- " inflating: datasets/annotations/a (61).xml \n",
- " inflating: datasets/annotations/a (62).xml \n",
- " inflating: datasets/annotations/a (63).xml \n",
- " inflating: datasets/annotations/a (64).xml \n",
- " inflating: datasets/annotations/a (65).xml \n",
- " inflating: datasets/annotations/a (66).xml \n",
- " inflating: datasets/annotations/a (67).xml \n",
- " inflating: datasets/annotations/a (68).xml \n",
- " inflating: datasets/annotations/a (69).xml \n",
- " inflating: datasets/annotations/a (7).xml \n",
- " inflating: datasets/annotations/a (70).xml \n",
- " inflating: datasets/annotations/a (71).xml \n",
- " inflating: datasets/annotations/a (72).xml \n",
- " inflating: datasets/annotations/a (73).xml \n",
- " inflating: datasets/annotations/a (74).xml \n",
- " inflating: datasets/annotations/a (75).xml \n",
- " inflating: datasets/annotations/a (76).xml \n",
- " inflating: datasets/annotations/a (77).xml \n",
- " inflating: datasets/annotations/a (78).xml \n",
- " inflating: datasets/annotations/a (79).xml \n",
- " inflating: datasets/annotations/a (8).xml \n",
- " inflating: datasets/annotations/a (80).xml \n",
- " inflating: datasets/annotations/a (81).xml \n",
- " inflating: datasets/annotations/a (82).xml \n",
- " inflating: datasets/annotations/a (83).xml \n",
- " inflating: datasets/annotations/a (84).xml \n",
- " inflating: datasets/annotations/a (85).xml \n",
- " inflating: datasets/annotations/a (86).xml \n",
- " inflating: datasets/annotations/a (87).xml \n",
- " inflating: datasets/annotations/a (88).xml \n",
- " inflating: datasets/annotations/a (89).xml \n",
- " inflating: datasets/annotations/a (9).xml \n",
- " inflating: datasets/annotations/a (90).xml \n",
- " inflating: datasets/annotations/a (91).xml \n",
- " inflating: datasets/annotations/a (92).xml \n",
- " inflating: datasets/annotations/a (93).xml \n",
- " inflating: datasets/annotations/a (94).xml \n",
- " inflating: datasets/annotations/a (95).xml \n",
- " inflating: datasets/annotations/a (96).xml \n",
- " inflating: datasets/annotations/a (97).xml \n",
- " inflating: datasets/annotations/a (98).xml \n",
- " inflating: datasets/annotations/a (99).xml \n",
- " inflating: datasets/images/a (1).jpg \n",
- " inflating: datasets/images/a (10).jpg \n",
- " inflating: datasets/images/a (100).jpg \n",
- " inflating: datasets/images/a (101).jpg \n",
- " inflating: datasets/images/a (102).jpg \n",
- " inflating: datasets/images/a (103).jpg \n",
- " inflating: datasets/images/a (104).jpg \n",
- " inflating: datasets/images/a (105).jpg \n",
- " inflating: datasets/images/a (106).jpg \n",
- " inflating: datasets/images/a (107).jpg \n",
- " inflating: datasets/images/a (108).jpg \n",
- " inflating: datasets/images/a (109).jpg \n",
- " inflating: datasets/images/a (11).jpg \n",
- " inflating: datasets/images/a (110).jpg \n",
- " inflating: datasets/images/a (111).jpg \n",
- " inflating: datasets/images/a (112).jpg \n",
- " inflating: datasets/images/a (12).jpg \n",
- " inflating: datasets/images/a (13).jpg \n",
- " inflating: datasets/images/a (14).jpg \n",
- " inflating: datasets/images/a (15).jpg \n",
- " inflating: datasets/images/a (16).jpg \n",
- " inflating: datasets/images/a (17).jpg \n",
- " inflating: datasets/images/a (18).jpg \n",
- " inflating: datasets/images/a (19).jpg \n",
- " inflating: datasets/images/a (2).jpg \n",
- " inflating: datasets/images/a (20).jpg \n",
- " inflating: datasets/images/a (21).jpg \n",
- " inflating: datasets/images/a (22).jpg \n",
- " inflating: datasets/images/a (23).jpg \n",
- " inflating: datasets/images/a (24).jpg \n",
- " inflating: datasets/images/a (25).jpg \n",
- " inflating: datasets/images/a (26).jpg \n",
- " inflating: datasets/images/a (27).jpg \n",
- " inflating: datasets/images/a (28).jpg \n",
- " inflating: datasets/images/a (29).jpg \n",
- " inflating: datasets/images/a (3).jpg \n",
- " inflating: datasets/images/a (30).jpg \n",
- " inflating: datasets/images/a (31).jpg \n",
- " inflating: datasets/images/a (32).jpg \n",
- " inflating: datasets/images/a (33).jpg \n",
- " inflating: datasets/images/a (34).jpg \n",
- " inflating: datasets/images/a (35).jpg \n",
- " inflating: datasets/images/a (36).jpg \n",
- " inflating: datasets/images/a (37).jpg \n",
- " inflating: datasets/images/a (38).jpg \n",
- " inflating: datasets/images/a (39).jpg \n",
- " inflating: datasets/images/a (4).jpg \n",
- " inflating: datasets/images/a (40).jpg \n",
- " inflating: datasets/images/a (41).jpg \n",
- " inflating: datasets/images/a (42).jpg \n",
- " inflating: datasets/images/a (43).jpg \n",
- " inflating: datasets/images/a (44).jpg \n",
- " inflating: datasets/images/a (45).jpg \n",
- " inflating: datasets/images/a (46).jpg \n",
- " inflating: datasets/images/a (47).jpg \n",
- " inflating: datasets/images/a (48).jpg \n",
- " inflating: datasets/images/a (49).jpg \n",
- " inflating: datasets/images/a (5).jpg \n",
- " inflating: datasets/images/a (50).jpg \n",
- " inflating: datasets/images/a (51).jpg \n",
- " inflating: datasets/images/a (52).jpg \n",
- " inflating: datasets/images/a (53).jpg \n",
- " inflating: datasets/images/a (54).jpg \n",
- " inflating: datasets/images/a (55).jpg \n",
- " inflating: datasets/images/a (56).jpg \n",
- " inflating: datasets/images/a (57).jpg \n",
- " inflating: datasets/images/a (58).jpg \n",
- " inflating: datasets/images/a (59).jpg \n",
- " inflating: datasets/images/a (6).jpg \n",
- " inflating: datasets/images/a (60).jpg \n",
- " inflating: datasets/images/a (61).jpg \n",
- " inflating: datasets/images/a (62).jpg \n",
- " inflating: datasets/images/a (63).jpg \n",
- " inflating: datasets/images/a (64).jpg \n",
- " inflating: datasets/images/a (65).jpg \n",
- " inflating: datasets/images/a (66).jpg \n",
- " inflating: datasets/images/a (67).jpg \n",
- " inflating: datasets/images/a (68).jpg \n",
- " inflating: datasets/images/a (69).jpg \n",
- " inflating: datasets/images/a (7).jpg \n",
- " inflating: datasets/images/a (70).jpg \n",
- " inflating: datasets/images/a (71).jpg \n",
- " inflating: datasets/images/a (72).jpg \n",
- " inflating: datasets/images/a (73).jpg \n",
- " inflating: datasets/images/a (74).jpg \n",
- " inflating: datasets/images/a (75).jpg \n",
- " inflating: datasets/images/a (76).jpg \n",
- " inflating: datasets/images/a (77).jpg \n",
- " inflating: datasets/images/a (78).jpg \n",
- " inflating: datasets/images/a (79).jpg \n",
- " inflating: datasets/images/a (8).jpg \n",
- " inflating: datasets/images/a (80).jpg \n",
- " inflating: datasets/images/a (81).jpg \n",
- " inflating: datasets/images/a (82).jpg \n",
- " inflating: datasets/images/a (83).jpg \n",
- " inflating: datasets/images/a (84).jpg \n",
- " inflating: datasets/images/a (85).jpg \n",
- " inflating: datasets/images/a (86).jpg \n",
- " inflating: datasets/images/a (87).jpg \n",
- " inflating: datasets/images/a (88).jpg \n",
- " inflating: datasets/images/a (89).jpg \n",
- " inflating: datasets/images/a (9).jpg \n",
- " inflating: datasets/images/a (90).jpg \n",
- " inflating: datasets/images/a (91).jpg \n",
- " inflating: datasets/images/a (92).jpg \n",
- " inflating: datasets/images/a (93).jpg \n",
- " inflating: datasets/images/a (94).jpg \n",
- " inflating: datasets/images/a (95).jpg \n",
- " inflating: datasets/images/a (96).jpg \n",
- " inflating: datasets/images/a (97).jpg \n",
- " inflating: datasets/images/a (98).jpg \n",
- " inflating: datasets/images/a (99).jpg \n"
- ]
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "# Define Directory\n",
- "images_directory = \"/content/datasets/images\"\n",
- "annotations_directory=\"/content/datasets/annotations\"\n",
- "\n",
- "img_paths = sorted([os.path.join(images_directory, fname) for fname in os.listdir(images_directory) if fname.endswith(\".jpg\")])\n",
- "label_paths = sorted([os.path.join(annotations_directory, fname) for fname in os.listdir(annotations_directory) if fname.endswith(\".xml\")])\n",
- "\n",
- "k = len(img_paths)\n",
- "\n",
- "data_list = []\n",
- "\n",
- "for i in range(k):\n",
- " annotation_file=label_paths[i]\n",
- " ds = BeautifulSoup(open(annotation_file).read(), \"html.parser\")\n",
- "\n",
- " # Iterating over each object elements\n",
- " for o in ds.find_all(\"object\"):\n",
- "\n",
- " x_min = max(0, int(float(o.find(\"xmin\").string)))\n",
- " y_min = max(0, int(float(o.find(\"ymin\").string)))\n",
- " x_max = min(int(ds.find(\"width\").string), int(float(o.find(\"xmax\").string)))\n",
- " y_max = min(int(ds.find(\"height\").string), int(float(o.find(\"ymax\").string)))\n",
- "\n",
- " # in case the boundary goes above its limis, providing some restrictions.\n",
- " if x_min >= x_max or y_min >= y_max:\n",
- " continue\n",
- " elif x_max <= x_min or y_max <= y_min:\n",
- " continue\n",
- "\n",
- " sample = [str(img_paths[i]), x_min, y_min, x_max, y_max]\n",
- "\n",
- " data_list.append(sample)\n",
- "\n",
- "data = pd.DataFrame(data_list)"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2021-08-07T05:06:17.508034Z",
- "iopub.execute_input": "2021-08-07T05:06:17.50837Z",
- "iopub.status.idle": "2021-08-07T05:06:18.390511Z",
- "shell.execute_reply.started": "2021-08-07T05:06:17.508338Z",
- "shell.execute_reply": "2021-08-07T05:06:18.389703Z"
- },
- "trusted": true,
- "id": "lBNBbzYXJs88"
- },
- "execution_count": 3,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "source": [
- "# EDA"
- ],
- "metadata": {
- "id": "Dd1IQdGsJs89"
- }
- },
- {
- "cell_type": "code",
- "source": [
- "data.head()"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2021-08-07T05:06:56.257092Z",
- "iopub.execute_input": "2021-08-07T05:06:56.257419Z",
- "iopub.status.idle": "2021-08-07T05:06:56.276996Z",
- "shell.execute_reply.started": "2021-08-07T05:06:56.25739Z",
- "shell.execute_reply": "2021-08-07T05:06:56.275936Z"
- },
- "trusted": true,
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 206
- },
- "id": "f8J2O8sFJs8-",
- "outputId": "469e0bf3-753f-4a39-92b4-5e9ccd9486a3"
- },
- "execution_count": 4,
- "outputs": [
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- " 0 1 2 3 4\n",
- "0 /content/datasets/images/a (1).jpg 38 54 179 173\n",
- "1 /content/datasets/images/a (10).jpg 58 14 155 117\n",
- "2 /content/datasets/images/a (100).jpg 86 18 182 125\n",
- "3 /content/datasets/images/a (101).jpg 23 16 120 115\n",
- "4 /content/datasets/images/a (102).jpg 33 30 166 173"
- ],
- "text/html": [
- "\n",
- "
\n",
- "
\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " 0 | \n",
- " 1 | \n",
- " 2 | \n",
- " 3 | \n",
- " 4 | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " /content/datasets/images/a (1).jpg | \n",
- " 38 | \n",
- " 54 | \n",
- " 179 | \n",
- " 173 | \n",
- "
\n",
- " \n",
- " 1 | \n",
- " /content/datasets/images/a (10).jpg | \n",
- " 58 | \n",
- " 14 | \n",
- " 155 | \n",
- " 117 | \n",
- "
\n",
- " \n",
- " 2 | \n",
- " /content/datasets/images/a (100).jpg | \n",
- " 86 | \n",
- " 18 | \n",
- " 182 | \n",
- " 125 | \n",
- "
\n",
- " \n",
- " 3 | \n",
- " /content/datasets/images/a (101).jpg | \n",
- " 23 | \n",
- " 16 | \n",
- " 120 | \n",
- " 115 | \n",
- "
\n",
- " \n",
- " 4 | \n",
- " /content/datasets/images/a (102).jpg | \n",
- " 33 | \n",
- " 30 | \n",
- " 166 | \n",
- " 173 | \n",
- "
\n",
- " \n",
- "
\n",
- "
\n",
- "
\n",
- "
\n"
- ],
- "application/vnd.google.colaboratory.intrinsic+json": {
- "type": "dataframe",
- "variable_name": "data",
- "summary": "{\n \"name\": \"data\",\n \"rows\": 112,\n \"fields\": [\n {\n \"column\": 0,\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 112,\n \"samples\": [\n \"/content/datasets/images/a (34).jpg\",\n \"/content/datasets/images/a (57).jpg\",\n \"/content/datasets/images/a (102).jpg\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": 1,\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 40,\n \"min\": 1,\n \"max\": 161,\n \"num_unique_values\": 70,\n \"samples\": [\n 24,\n 38,\n 95\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": 2,\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 48,\n \"min\": 1,\n \"max\": 177,\n \"num_unique_values\": 81,\n \"samples\": [\n 55,\n 54,\n 45\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": 3,\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 42,\n \"min\": 55,\n \"max\": 222,\n \"num_unique_values\": 77,\n \"samples\": [\n 166,\n 183,\n 178\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": 4,\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 38,\n \"min\": 100,\n \"max\": 224,\n \"num_unique_values\": 69,\n \"samples\": [\n 167,\n 173,\n 205\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
- }
- },
- "metadata": {},
- "execution_count": 4
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "img = plt.imread(data[0][0])\n",
- "plt.imshow(img)\n",
- "print('xmin', data[1][0], 'ymin',data[2][0],'xmax',data[3][0],'ymax',data[4][0])"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2021-08-07T05:06:58.523352Z",
- "iopub.execute_input": "2021-08-07T05:06:58.523693Z",
- "iopub.status.idle": "2021-08-07T05:06:58.755975Z",
- "shell.execute_reply.started": "2021-08-07T05:06:58.523659Z",
- "shell.execute_reply": "2021-08-07T05:06:58.754887Z"
- },
- "trusted": true,
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 451
- },
- "id": "0hUl1AoqJs8-",
- "outputId": "34e28b85-cab4-4dac-bc04-1ee390ce5878"
- },
- "execution_count": 5,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "xmin 38 ymin 54 xmax 179 ymax 173\n"
- ]
- },
- {
- "output_type": "display_data",
- "data": {
- "text/plain": [
- "