├── AV_ComputerVision.ipynb
├── CVLB.png
├── DataLeak.ipynb
├── Data_Photos.png
├── Data_df.png
├── README.md
└── Sorted_Data_Photos.png
/CVLB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saikrithik/JanataHack-Computer-Vision-Hackathon/5ceedfc942256f64e877055a4efeb618adc0d911/CVLB.png
--------------------------------------------------------------------------------
/DataLeak.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 6,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "import pandas as pd\n",
10 | "#1- 990 --> 1\n",
11 | "test = pd.read_csv(\"test.csv\")\n",
12 | "test2 = pd.read_csv(\"test.csv\")\n",
13 | "# test[\"emergency_or_not\"]=0\n",
14 | "train =pd.read_csv(\"train/train.csv\")\n",
15 | "train = train.append(test)"
16 | ]
17 | },
18 | {
19 | "cell_type": "markdown",
20 | "metadata": {},
21 | "source": [
22 | "## Joining Train and Test and sorting the images"
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {},
28 | "source": [
29 | "#### Here we can see Data is splitted 0-990 images are 1 and rest are 0"
30 | ]
31 | },
32 | {
33 | "cell_type": "code",
34 | "execution_count": 11,
35 | "metadata": {},
36 | "outputs": [
37 | {
38 | "data": {
39 | "text/html": [
40 | "
\n",
41 | "\n",
54 | "
\n",
55 | " \n",
56 | " \n",
57 | " | \n",
58 | " image_names | \n",
59 | " emergency_or_not | \n",
60 | " no. | \n",
61 | " jpg | \n",
62 | "
\n",
63 | " \n",
64 | " \n",
65 | " \n",
66 | " 880 | \n",
67 | " 0.jpg | \n",
68 | " 1.0 | \n",
69 | " 0 | \n",
70 | " jpg | \n",
71 | "
\n",
72 | " \n",
73 | " 1489 | \n",
74 | " 1.jpg | \n",
75 | " 1.0 | \n",
76 | " 1 | \n",
77 | " jpg | \n",
78 | "
\n",
79 | " \n",
80 | " 545 | \n",
81 | " 10.jpg | \n",
82 | " 1.0 | \n",
83 | " 10 | \n",
84 | " jpg | \n",
85 | "
\n",
86 | " \n",
87 | " 96 | \n",
88 | " 100.jpg | \n",
89 | " NaN | \n",
90 | " 100 | \n",
91 | " jpg | \n",
92 | "
\n",
93 | " \n",
94 | " 684 | \n",
95 | " 1000.jpg | \n",
96 | " NaN | \n",
97 | " 1000 | \n",
98 | " jpg | \n",
99 | "
\n",
100 | " \n",
101 | " ... | \n",
102 | " ... | \n",
103 | " ... | \n",
104 | " ... | \n",
105 | " ... | \n",
106 | "
\n",
107 | " \n",
108 | " 1587 | \n",
109 | " 995.jpg | \n",
110 | " 0.0 | \n",
111 | " 995 | \n",
112 | " jpg | \n",
113 | "
\n",
114 | " \n",
115 | " 1252 | \n",
116 | " 996.jpg | \n",
117 | " 0.0 | \n",
118 | " 996 | \n",
119 | " jpg | \n",
120 | "
\n",
121 | " \n",
122 | " 358 | \n",
123 | " 997.jpg | \n",
124 | " 0.0 | \n",
125 | " 997 | \n",
126 | " jpg | \n",
127 | "
\n",
128 | " \n",
129 | " 234 | \n",
130 | " 998.jpg | \n",
131 | " NaN | \n",
132 | " 998 | \n",
133 | " jpg | \n",
134 | "
\n",
135 | " \n",
136 | " 9 | \n",
137 | " 999.jpg | \n",
138 | " 0.0 | \n",
139 | " 999 | \n",
140 | " jpg | \n",
141 | "
\n",
142 | " \n",
143 | "
\n",
144 | "
2352 rows × 4 columns
\n",
145 | "
"
146 | ],
147 | "text/plain": [
148 | " image_names emergency_or_not no. jpg\n",
149 | "880 0.jpg 1.0 0 jpg\n",
150 | "1489 1.jpg 1.0 1 jpg\n",
151 | "545 10.jpg 1.0 10 jpg\n",
152 | "96 100.jpg NaN 100 jpg\n",
153 | "684 1000.jpg NaN 1000 jpg\n",
154 | "... ... ... ... ...\n",
155 | "1587 995.jpg 0.0 995 jpg\n",
156 | "1252 996.jpg 0.0 996 jpg\n",
157 | "358 997.jpg 0.0 997 jpg\n",
158 | "234 998.jpg NaN 998 jpg\n",
159 | "9 999.jpg 0.0 999 jpg\n",
160 | "\n",
161 | "[2352 rows x 4 columns]"
162 | ]
163 | },
164 | "execution_count": 11,
165 | "metadata": {},
166 | "output_type": "execute_result"
167 | }
168 | ],
169 | "source": [
170 | "train[['no.','jpg']] = train.image_names.str.split(\".\",expand=True)\n",
171 | "train.sort_values(by=[\"no.\"],ascending=True)"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": 116,
177 | "metadata": {},
178 | "outputs": [
179 | {
180 | "name": "stdout",
181 | "output_type": "stream",
182 | "text": [
183 | " image_names emergency_or_not no. jpg\n",
184 | "0 1960.jpg 0 1960 jpg\n",
185 | "1 1 1 1 1\n",
186 | "2 2082.jpg 0 2082 jpg\n",
187 | "3 1 1 1 1\n",
188 | "4 1907.jpg 0 1907 jpg\n",
189 | ".. ... ... ... ...\n",
190 | "701 1 1 1 1\n",
191 | "702 1027.jpg 0 1027 jpg\n",
192 | "703 1 1 1 1\n",
193 | "704 2176.jpg 0 2176 jpg\n",
194 | "705 1014.jpg 0 1014 jpg\n",
195 | "\n",
196 | "[706 rows x 4 columns]\n"
197 | ]
198 | }
199 | ],
200 | "source": [
201 | "test = pd.read_csv(\"test.csv\")\n",
202 | "test2 = pd.read_csv(\"test.csv\")\n",
203 | "test[\"emergency_or_not\"]=0\n",
204 | "test[['no.','jpg']] = test.image_names.str.split(\".\",expand=True,)\n",
205 | "test[test[\"no.\"].astype(int) <= 990] = 1\n",
206 | "test[\"emergency_or_not\"] = test[test[\"no.\"].astype(int) <= 990]\n",
207 | "test[\"emergency_or_not\"] = test[\"emergency_or_not\"].fillna(0)\n",
208 | "print(test)\n",
209 | "test2[\"emergency_or_not\"] = test[\"emergency_or_not\"]\n",
210 | "test2.to_csv(\"submit.csv\",index=False)"
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": null,
216 | "metadata": {},
217 | "outputs": [],
218 | "source": [
219 | "train[['no.','jpg']] = train.image_names.str.split(\".\",expand=True)\n",
220 | "train[\"no.\"] = train[\"no.\"].astype(int)\n",
221 | "train.sort_values([\"no.\"],ascending=True).to_excel(\"refer.xlsx\",index=False)"
222 | ]
223 | }
224 | ],
225 | "metadata": {
226 | "kernelspec": {
227 | "display_name": "Python 3",
228 | "language": "python",
229 | "name": "python3"
230 | },
231 | "language_info": {
232 | "codemirror_mode": {
233 | "name": "ipython",
234 | "version": 3
235 | },
236 | "file_extension": ".py",
237 | "mimetype": "text/x-python",
238 | "name": "python",
239 | "nbconvert_exporter": "python",
240 | "pygments_lexer": "ipython3",
241 | "version": "3.7.6"
242 | }
243 | },
244 | "nbformat": 4,
245 | "nbformat_minor": 4
246 | }
247 |
--------------------------------------------------------------------------------
/Data_Photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saikrithik/JanataHack-Computer-Vision-Hackathon/5ceedfc942256f64e877055a4efeb618adc0d911/Data_Photos.png
--------------------------------------------------------------------------------
/Data_df.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saikrithik/JanataHack-Computer-Vision-Hackathon/5ceedfc942256f64e877055a4efeb618adc0d911/Data_df.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JanataHack-Computer-Vision-Hackathon
2 | Winning solution for JanataHack: Computer Vision Hackathon
3 | ## Private LB Rank:1
4 | ### Leader Board:
5 |
8 | #### Emergency vs Non-Emergency Vehicle Classification
9 | Fatalities due to traffic delays of emergency vehicles such as ambulance & fire brigade is a huge problem. In daily life, we often see that emergency vehicles face difficulty in passing through traffic. So differentiating a vehicle into an emergency and non emergency category can be an important component in traffic monitoring as well as self drive car systems as reaching on time to their destination is critical for these services.
10 |
11 | In this problem, you will be working on classifying vehicle images as either belonging to the emergency vehicle or non-emergency vehicle category. For the same, you are provided with the train and the test dataset. Emergency vehicles usually includes police cars, ambulance and fire brigades.
12 | ### Data Description:-
13 | - **train.zip**: contains 2 csvs and 1 folder containing image data
14 | 1. ****train.csv**** – [‘image_names’, ‘emergency_or_not’] contains the image name and correct class for 1646 (70%) train images
15 | 2. ****images**** – contains 2352 images for both train and test sets
16 | - **test.csv**: [‘image_names’] contains just the image names for the 706 (30%) test images-
17 | - **sample_submission.csv**: [‘image_names’,’emergency_or_not’] contains the exact format for a valid submission (1 - For Emergency Vehicle, 0 - For Non Emergency Vehicle)
18 | ## Data at a Glance
19 |
22 | ## Data Photos
23 |
26 | #### Data Augmentation & Approach
27 | 1. Regular Transformation and data augmentation.
28 | 2. Used Fastai Resnet101 model.
29 | #### Tools used
30 | 1. Python for programming
31 | 2. numpy library for methodology
32 | 3. OpenCV for reading the images and stuff.
33 | 3. fastai library for the model
34 | 4. matplotlib and seaborn was used for plotting and analyzing the data
35 | ##### Data_Leak(Sorted images shows everything!)
36 |
39 | #### Competition Result
40 | Rank: 5th on public LB and **1st** on private LB\
41 | [Link to LeaderBoard](https://datahack.analyticsvidhya.com/contest/janatahack-computer-vision-hackathon/#LeaderBoard)
42 |
--------------------------------------------------------------------------------
/Sorted_Data_Photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saikrithik/JanataHack-Computer-Vision-Hackathon/5ceedfc942256f64e877055a4efeb618adc0d911/Sorted_Data_Photos.png
--------------------------------------------------------------------------------