mirror of
https://github.com/inzva/object-detection-with-street-view.git
synced 2021-06-01 09:33:47 +03:00
Merge pull request #2 from efehandanisman/main
Notebooks added, readme updated.
This commit is contained in:
250
1_Data_Acquisition_GSV.ipynb
Normal file
250
1_Data_Acquisition_GSV.ipynb
Normal file
@@ -0,0 +1,250 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"name": "street_view.ipynb",
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "KQSP7h-nrure"
|
||||
},
|
||||
"source": [
|
||||
"#This code uses the google streetview.api and the haversine formula to download Google Street View."
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "DLUJdoRpr5vL"
|
||||
},
|
||||
"source": [
|
||||
"!pip install google_streetview"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "XPEWOX8mr-Z5"
|
||||
},
|
||||
"source": [
|
||||
"# Import google_streetview for the api module\n",
|
||||
"import google_streetview.api\n",
|
||||
"from google.colab import files as FILE\n",
|
||||
"import requests\n",
|
||||
"import os\n",
|
||||
"import re"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "6ISp63NDsGhM"
|
||||
},
|
||||
"source": [
|
||||
"'''\n",
|
||||
"Calculate distance using the Haversine Formula\n",
|
||||
"'''\n",
|
||||
"#The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes\n",
|
||||
"\n",
|
||||
"def haversine(coord1: object, coord2: object):\n",
|
||||
" import math\n",
|
||||
"\n",
|
||||
" # Coordinates in decimal degrees (e.g. 2.89078, 12.79797)\n",
|
||||
" lon1, lat1 = coord1\n",
|
||||
" lon2, lat2 = coord2\n",
|
||||
"\n",
|
||||
" R = 6371000 # radius of Earth in meters\n",
|
||||
" phi_1 = math.radians(lat1)\n",
|
||||
" phi_2 = math.radians(lat2)\n",
|
||||
"\n",
|
||||
" delta_phi = math.radians(lat2 - lat1)\n",
|
||||
" delta_lambda = math.radians(lon2 - lon1)\n",
|
||||
"\n",
|
||||
" a = math.sin(delta_phi / 2.0) ** 2 + math.cos(phi_1) * math.cos(phi_2) * math.sin(delta_lambda / 2.0) ** 2\n",
|
||||
" \n",
|
||||
" c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))\n",
|
||||
" head= math.atan2(math.sin(delta_lambda)*math.cos(phi_2), math.cos(phi_1)*math.sin(phi_2)-math.sin(phi_1)*math.cos(phi_2)*math.cos(delta_lambda))\n",
|
||||
" meters = R * c # output distance in meters\n",
|
||||
" km = meters / 1000.0 # output distance in kilometers\n",
|
||||
"\n",
|
||||
" meters = round(meters, 3)\n",
|
||||
" headd=head*57.295779513 #convert radian to degree\n",
|
||||
" km = round(km, 3)\n",
|
||||
" kms=km/100\n",
|
||||
" stepsze=kms/111.2 #the number of grid points in each direction. \n",
|
||||
" print(f\"Distance: {meters} m\")\n",
|
||||
" print(f\"Distance: {km} km\")\n",
|
||||
" print(f\"stepsize: {kms} km\")\n",
|
||||
" print(f\"stepsizedegreee: {stepsze} degree\")\n",
|
||||
" print(f\"head: {headd} degree\")\n"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "Yc_enRjSsH5I"
|
||||
},
|
||||
"source": [
|
||||
"# da and db are the lengths of the sides of the rectangle in the latitude and longitude direction\n",
|
||||
"db=haversine([ 40.982199, 28.756978 ], [40.987382, 28.809335 ])"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "Zpgm8-IHsMiG"
|
||||
},
|
||||
"source": [
|
||||
"da=haversine([ 40.987382, 28.809335 ], [40.982199, 28.756978 ])"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "gkp1uS50sS2Q"
|
||||
},
|
||||
"source": [
|
||||
"image_links = []\n",
|
||||
"api_results=[]\n",
|
||||
"api_list=[]\n",
|
||||
"locs= []\n",
|
||||
"\n",
|
||||
"#Depending on the values above, the values they take should change.\n",
|
||||
"db= 0.0005255395683453238\n",
|
||||
"da= 0.0005255395683453238\n",
|
||||
"#longitudes and latitudes of two point \n",
|
||||
"rem= 41.016097\n",
|
||||
"rbm= 29.205892 \n",
|
||||
"ree= 41.127392\n",
|
||||
"rbe=29.296529\n",
|
||||
"while ree > rem and rbe > rbm:\n",
|
||||
" rem=rem+db;\n",
|
||||
" alst = list(str(rem)+ \",\")\n",
|
||||
" rbm=rbm+db;\n",
|
||||
" blst = list(str(rbm))\n",
|
||||
" a = ''.join(alst); b = ''.join(blst) \n",
|
||||
"#At this stage, the latitude and longitude are combined into a format that we can use. \n",
|
||||
" my_list = [a,b]\n",
|
||||
" my_string = ''.join(my_list)\n",
|
||||
" my_string\n",
|
||||
" locs.append(my_string)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "IbdfaTs-sZqA"
|
||||
},
|
||||
"source": [
|
||||
"# Define parameters for street view api\n",
|
||||
"for i in range(150):\n",
|
||||
" params = {\n",
|
||||
"\t'size': '300x300', # max 640x640 pixels\n",
|
||||
"\t'location': locs[i],\n",
|
||||
"\t'heading': '170;90;-90' #indicates the compass heading of the camera. Accepted values are from 0 to 360\n",
|
||||
" 'pitch': '-0.76', #(default is 0) specifies the up or down angle of the camera relative to the Street View vehicle.\n",
|
||||
"\t'key': '..... '\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
" api = google_streetview.helpers.api_list(params)\n",
|
||||
" api_list.append(api)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "WPpRxcYgsdVP"
|
||||
},
|
||||
"source": [
|
||||
"# Create a results object\n",
|
||||
"for i in range(350):\n",
|
||||
" api_result = google_streetview.api.results(api_list[i])\n",
|
||||
" api_results.append(api_result)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "SGLdezbNsdoX"
|
||||
},
|
||||
"source": [
|
||||
"#Download images as a link\n",
|
||||
"for i in range(240):\n",
|
||||
" link = api_results[i].links\n",
|
||||
" image_links.append(link)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "n3_7gxlSslsX"
|
||||
},
|
||||
"source": [
|
||||
"#Example link\n",
|
||||
"image_links[2][2]"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "i8hajtjqsdzl"
|
||||
},
|
||||
"source": [
|
||||
"# We get the data on our own google drive.\n",
|
||||
"from google.colab import drive\n",
|
||||
"drive.mount('/content/gdrive')"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "dWx4-PL7srYE"
|
||||
},
|
||||
"source": [
|
||||
"#Download images\n",
|
||||
"for i in range(240):\n",
|
||||
" img_data = requests.get(image_links[i][0]).content\n",
|
||||
" with open('/content/gdrive/My Drive/buyukcekmece/lbktz' + str(i)+ '.jpg', 'wb') as handler:\n",
|
||||
" handler.write(img_data)\n"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
292
2.Object_Detection_inzva.ipynb
Normal file
292
2.Object_Detection_inzva.ipynb
Normal file
@@ -0,0 +1,292 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"name": "Object_Detection_inzva.ipynb",
|
||||
"provenance": [],
|
||||
"collapsed_sections": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"accelerator": "GPU"
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "8k0QK_e7whr2"
|
||||
},
|
||||
"source": [
|
||||
"This notebook explains how to make predictions for Google Street View images using Yolo v3 and ImageAI library with the help of this [tutorial](https://github.com/OlafenwaMoses/ImageAI/tree/master/imageai/Detection).\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 815
|
||||
},
|
||||
"id": "P-q6wNsIHqTk",
|
||||
"outputId": "f5baf85f-8688-44f1-cc78-47782f0404f3"
|
||||
},
|
||||
"source": [
|
||||
"!pip install opencv-python==4.1.2.30 imageai\n",
|
||||
"!pip install requests\n",
|
||||
"from google.colab.patches import cv2_imshow\n",
|
||||
"import os\n",
|
||||
"import cv2 as cv\n",
|
||||
"from imageai.Detection import ObjectDetection\n",
|
||||
"from collections import Counter\n",
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"import requests as req\n",
|
||||
"import os as os"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Requirement already satisfied: opencv-python==4.1.2.30 in /usr/local/lib/python3.7/dist-packages (4.1.2.30)\n",
|
||||
"Collecting imageai\n",
|
||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/73/44/3d5d8ef572888025666eec284e85f9243faf06ca8c12085dcff1ca9754ed/imageai-2.1.6-py3-none-any.whl (160kB)\n",
|
||||
"\u001b[K |████████████████████████████████| 163kB 18.2MB/s \n",
|
||||
"\u001b[?25hRequirement already satisfied: numpy>=1.14.5 in /usr/local/lib/python3.7/dist-packages (from opencv-python==4.1.2.30) (1.19.5)\n",
|
||||
"Requirement already satisfied: keras==2.4.3 in /usr/local/lib/python3.7/dist-packages (from imageai) (2.4.3)\n",
|
||||
"Collecting pillow==7.0.0\n",
|
||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/f5/79/b2d5695d1a931474fa68b68ec93bdf08ba9acbc4d6b3b628eb6aac81d11c/Pillow-7.0.0-cp37-cp37m-manylinux1_x86_64.whl (2.1MB)\n",
|
||||
"\u001b[K |████████████████████████████████| 2.1MB 35.7MB/s \n",
|
||||
"\u001b[?25hCollecting matplotlib==3.3.2\n",
|
||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/87/a6/8d7d06f6b69236a3c1818157875ceb1259ba0d9df4194f4fe138ffdc0f41/matplotlib-3.3.2-cp37-cp37m-manylinux1_x86_64.whl (11.6MB)\n",
|
||||
"\u001b[K |████████████████████████████████| 11.6MB 241kB/s \n",
|
||||
"\u001b[?25hRequirement already satisfied: h5py==2.10.0 in /usr/local/lib/python3.7/dist-packages (from imageai) (2.10.0)\n",
|
||||
"Collecting keras-resnet==0.2.0\n",
|
||||
" Downloading https://files.pythonhosted.org/packages/76/d4/a35cbd07381139dda4db42c81b88c59254faac026109022727b45b31bcad/keras-resnet-0.2.0.tar.gz\n",
|
||||
"Requirement already satisfied: scipy==1.4.1 in /usr/local/lib/python3.7/dist-packages (from imageai) (1.4.1)\n",
|
||||
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from keras==2.4.3->imageai) (3.13)\n",
|
||||
"Requirement already satisfied: certifi>=2020.06.20 in /usr/local/lib/python3.7/dist-packages (from matplotlib==3.3.2->imageai) (2020.12.5)\n",
|
||||
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib==3.3.2->imageai) (2.8.1)\n",
|
||||
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib==3.3.2->imageai) (1.3.1)\n",
|
||||
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.7/dist-packages (from matplotlib==3.3.2->imageai) (2.4.7)\n",
|
||||
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib==3.3.2->imageai) (0.10.0)\n",
|
||||
"Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from h5py==2.10.0->imageai) (1.15.0)\n",
|
||||
"Building wheels for collected packages: keras-resnet\n",
|
||||
" Building wheel for keras-resnet (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
||||
" Created wheel for keras-resnet: filename=keras_resnet-0.2.0-py2.py3-none-any.whl size=20486 sha256=bfd0ac4844597cdd78f235432acbd86f52780d24e51cb2c09dc6a279636824ca\n",
|
||||
" Stored in directory: /root/.cache/pip/wheels/5f/09/a5/497a30fd9ad9964e98a1254d1e164bcd1b8a5eda36197ecb3c\n",
|
||||
"Successfully built keras-resnet\n",
|
||||
"\u001b[31mERROR: bokeh 2.3.1 has requirement pillow>=7.1.0, but you'll have pillow 7.0.0 which is incompatible.\u001b[0m\n",
|
||||
"\u001b[31mERROR: albumentations 0.1.12 has requirement imgaug<0.2.7,>=0.2.5, but you'll have imgaug 0.2.9 which is incompatible.\u001b[0m\n",
|
||||
"\u001b[31mERROR: imageai 2.1.6 has requirement numpy==1.19.3, but you'll have numpy 1.19.5 which is incompatible.\u001b[0m\n",
|
||||
"Installing collected packages: pillow, matplotlib, keras-resnet, imageai\n",
|
||||
" Found existing installation: Pillow 7.1.2\n",
|
||||
" Uninstalling Pillow-7.1.2:\n",
|
||||
" Successfully uninstalled Pillow-7.1.2\n",
|
||||
" Found existing installation: matplotlib 3.2.2\n",
|
||||
" Uninstalling matplotlib-3.2.2:\n",
|
||||
" Successfully uninstalled matplotlib-3.2.2\n",
|
||||
"Successfully installed imageai-2.1.6 keras-resnet-0.2.0 matplotlib-3.3.2 pillow-7.0.0\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"application/vnd.colab-display-data+json": {
|
||||
"pip_warning": {
|
||||
"packages": [
|
||||
"PIL",
|
||||
"matplotlib",
|
||||
"mpl_toolkits"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (2.23.0)\n",
|
||||
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests) (2.10)\n",
|
||||
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests) (3.0.4)\n",
|
||||
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests) (1.24.3)\n",
|
||||
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests) (2020.12.5)\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "09miic5WzgPR",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"outputId": "769b8cd7-5248-426f-aef1-ca1dd942026c"
|
||||
},
|
||||
"source": [
|
||||
"# At our work images were uploaded into Google Drive so we mouth here the drive.\n",
|
||||
"from google.colab import drive\n",
|
||||
"drive.mount('/content/drive')"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Mounted at /content/drive\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "Otae3QFWDA8E"
|
||||
},
|
||||
"source": [
|
||||
"#Some utility functions.\n",
|
||||
"\n",
|
||||
"def showImage(img):\n",
|
||||
" window_name = 'image'\n",
|
||||
" cv2_imshow(img)\n",
|
||||
" cv.waitKey(0)\n",
|
||||
" cv.destroyAllWindows()"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "TwzsrXl70MPD"
|
||||
},
|
||||
"source": [
|
||||
"#TO DO: This part will be filled with your input path for images.\n",
|
||||
"input_path = ''"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "S0TbsoI69dla"
|
||||
},
|
||||
"source": [
|
||||
"# Here we will list links to images we are going to detect objects.\n",
|
||||
"test_images = os.listdir(input_path)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "C4f9mR9v-ppq"
|
||||
},
|
||||
"source": [
|
||||
"# Getting our YOLOv3 model.\n",
|
||||
"modelYOLOv3 = 'https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5'\n",
|
||||
"\n",
|
||||
"if not os.path.exists('yolo.h5'):\n",
|
||||
" r = req.get(modelYOLOv3, timeout=0.5)\n",
|
||||
" with open('yolo.h5', 'wb') as outfile:\n",
|
||||
" outfile.write(r.content)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "76txCkmh_CSh"
|
||||
},
|
||||
"source": [
|
||||
"detector = ObjectDetection()\n",
|
||||
"detector.setModelTypeAsYOLOv3()\n",
|
||||
"detector.setModelPath('yolo.h5')\n",
|
||||
"detector.loadModel()"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "10A2wGwT_OEQ"
|
||||
},
|
||||
"source": [
|
||||
"# Predicting for images. This may take sometime depending on number of images.\n",
|
||||
"results = []\n",
|
||||
"bounded_images = []\n",
|
||||
"for i in test_images:\n",
|
||||
" detectedImage, detections = detector.detectObjectsFromImage(output_type=\"array\", input_image=input_path + i, minimum_percentage_probability=30)\n",
|
||||
" convertedImage = cv.cvtColor(detectedImage, cv.COLOR_RGB2BGR)\n",
|
||||
" results.append(detections)\n",
|
||||
" bounded_images.append(convertedImage)\n"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "GbqFaT_SEvx9"
|
||||
},
|
||||
"source": [
|
||||
"# Counting images in each item and writing into dataframe.\n",
|
||||
"all_items = []\n",
|
||||
"final_counts=[]\n",
|
||||
"new_item = {}\n",
|
||||
"for i in range(len(results)):\n",
|
||||
" result_dict = results[i]\n",
|
||||
" for z in range(len(result_dict)):\n",
|
||||
" image_objects= []\n",
|
||||
" new_item[z] = result_dict[z]['name']\n",
|
||||
" image_objects.append(new_item)\n",
|
||||
" number_of_items = Counter(image_objects[0].values())\n",
|
||||
" image_dict = {'image_name': test_images[i], 'no_of_items':number_of_items}\n",
|
||||
" final_counts.append(image_dict)"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "nZoxbXcUEiDB"
|
||||
},
|
||||
"source": [
|
||||
"# Finalizing into dataframe.\n",
|
||||
"final_df=pd.DataFrame(columns=['index','image_name','no_of_items'])\n",
|
||||
"for i in range(len(final_counts)):\n",
|
||||
" df = pd.DataFrame(final_counts[i]).reset_index()\n",
|
||||
" final_df =pd.concat([final_df,df],axis=0)\n"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "8qTTMnGD58SD"
|
||||
},
|
||||
"source": [
|
||||
"# Showing example predictions. You can change the images you would like to show by changing the number below.\n",
|
||||
"showImage(bounded_images[1])\n"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
23
README.md
23
README.md
@@ -1,2 +1,21 @@
|
||||
# object-detection-with-street-view
|
||||
GitHub repository for inzva AI Projects for Social Good #6 project - Object Detection with Street View Images for Demographic Analysis
|
||||
# inzva: AI PROJECTS #6 FOR SOCIAL GOOD
|
||||
|
||||
This is the repository for inzva AI Projects for Social Good #6 project - Object Detection with Street View Images for Demographic Analysis. Our project is inspired from the study conducted in [Stanford University](https://news.stanford.edu/2017/11/28/neighborhoods-cars-indicate-political-leanings/) and aims to replica the study in Istanbul using Google Street View (GSV) images. The study aims to extract insights from GSV images by using object detection in order to predict development level of the neighbourhoods.
|
||||
|
||||
For more details about the project you can refer to inzva's blog(-Blog post to be added)
|
||||
|
||||
We used [Social-Economic Welfare Level Index (SEGE)](https://kisi.deu.edu.tr/yunusemre.ozer/lce_sege-2017.pdf) developed by Ministry of Industry and Technology of Turkey as our target dataset to use as a benchmark for development level of the district in Istanbul. SEGE uses several features such as population, health and education accesses and economic levels to determine development level.
|
||||
|
||||
To do this, we developed a way to get images from each neighbourhood using Haversine Distance and acquired images (approximately 250 images each) for 10 different districts of Istanbul. After that using [imageAI](https://github.com/OlafenwaMoses/ImageAI/tree/master/imageai/Detection) library, we predicted objects in those districts and check whether is there any correlation between number of objects in each district and their SEGE score.
|
||||
|
||||
In this repository you can find the notebooks on acquiring data from Google Street View API, object detection via ImageAI library and our final presentation that is made at [AI Projects #6](https://inzva.com/2021/ai/projects/ai-project-group-6-social-good)
|
||||
|
||||
Contributors Github pages:
|
||||
|
||||
[Alara Hergün](https://github.com/alarahergun)
|
||||
|
||||
[Başak Ekinci](https://github.com/ekincibasak)
|
||||
|
||||
[Efehan Danışman](https://github.com/efehandanisman)
|
||||
|
||||
[Sefa Kurtipek](https://github.com/sefakurtipek)
|
||||
|
||||
Reference in New Issue
Block a user