Datasets:
sartajbhuvaji
commited on
Commit
•
c0ffb46
1
Parent(s):
8181abf
Delete Training Data(1-100)
Browse files- Training Data(1-100)/README.md +0 -47
- Training Data(1-100)/mini/README.md +0 -40
- Training Data(1-100)/mini/training_data-mini.npy +0 -3
- Training Data(1-100)/mini/training_data_stats.py +0 -99
- Training Data(1-100)/training_data_count_001-100.csv +0 -101
- Training Data(1-100)/training_data_stats.py +0 -100
Training Data(1-100)/README.md
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
### Info
|
2 |
-
- Image Resolution : 270, 480
|
3 |
-
- Mode : RGB
|
4 |
-
- Dimension : (270, 480, 3)
|
5 |
-
- File Count : 100
|
6 |
-
- Size : 1.81 GB/file
|
7 |
-
- Total Size : 181 GB
|
8 |
-
- Total Frames : 500,000
|
9 |
-
|
10 |
-
### Data Count (1-100)
|
11 |
-
```
|
12 |
-
'W': [1, 0, 0, 0, 0, 0, 0, 0, 0] : 353725
|
13 |
-
'S': [0, 1, 0, 0, 0, 0, 0, 0, 0] : 2243
|
14 |
-
'A': [0, 0, 1, 0, 0, 0, 0, 0, 0] : 14303
|
15 |
-
'D': [0, 0, 0, 1, 0, 0, 0, 0, 0] : 13114
|
16 |
-
'WA': [0, 0, 0, 0, 1, 0, 0, 0, 0] : 30877
|
17 |
-
'WD': [0, 0, 0, 0, 0, 1, 0, 0, 0] : 29837
|
18 |
-
'SA': [0, 0, 0, 0, 0, 0, 1, 0, 0] : 1952
|
19 |
-
'SD': [0, 0, 0, 0, 0, 0, 0, 1, 0] : 1451
|
20 |
-
'NK': [0, 0, 0, 0, 0, 0, 0, 0, 1] : 52256
|
21 |
-
NONE : 242
|
22 |
-
```
|
23 |
-
|
24 |
-
### Graphics Details
|
25 |
-
- Original Resolution : 800 x 600
|
26 |
-
- Aspect Ratio : 16:10
|
27 |
-
- All Video Settings : Low
|
28 |
-
|
29 |
-
### Camera Details
|
30 |
-
- Camera : Hood Cam
|
31 |
-
- Vehical Camera Height : Low
|
32 |
-
- First Person Vehical Auto-Center : On
|
33 |
-
- First Person Head Bobbing : Off
|
34 |
-
|
35 |
-
### Other Details
|
36 |
-
- Vehical : Michael's Car
|
37 |
-
- Vehical Mods : All Max
|
38 |
-
- Cv2 Mask : None
|
39 |
-
- Way Point : Enabled/Following
|
40 |
-
- Weather Conditions : Mostly Sunny
|
41 |
-
- Time of Day : Day, Night
|
42 |
-
- Rain : Some
|
43 |
-
|
44 |
-
### Note
|
45 |
-
- Remove `NONE` while processing the data
|
46 |
-
- Check `training_data_count_001-100.csv` for detailed count
|
47 |
-
- Check `training_data_stats.py` for more info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Training Data(1-100)/mini/README.md
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
### Info
|
2 |
-
- Image Resolution : 270, 480
|
3 |
-
- Mode : RGB
|
4 |
-
- Dimension : (270, 480, 3)
|
5 |
-
- File Count : 01
|
6 |
-
- Size : 1.81 GB
|
7 |
-
|
8 |
-
### Data Count
|
9 |
-
```
|
10 |
-
'W': [1, 0, 0, 0, 0, 0, 0, 0, 0] : 3627
|
11 |
-
'S': [0, 1, 0, 0, 0, 0, 0, 0, 0] : 50
|
12 |
-
'A': [0, 0, 1, 0, 0, 0, 0, 0, 0] : 104
|
13 |
-
'D': [0, 0, 0, 1, 0, 0, 0, 0, 0] : 106
|
14 |
-
'WA': [0, 0, 0, 0, 1, 0, 0, 0, 0] : 364
|
15 |
-
'WD': [0, 0, 0, 0, 0, 1, 0, 0, 0] : 416
|
16 |
-
'SA': [0, 0, 0, 0, 0, 0, 1, 0, 0] : 35
|
17 |
-
'SD': [0, 0, 0, 0, 0, 0, 0, 1, 0] : 47
|
18 |
-
'NK': [0, 0, 0, 0, 0, 0, 0, 0, 1] : 248
|
19 |
-
NONE : 3
|
20 |
-
```
|
21 |
-
|
22 |
-
### Graphics Details
|
23 |
-
- Original Resolution : 800 x 600
|
24 |
-
- Aspect Ratio : 16:10
|
25 |
-
- All Video Settings : Low
|
26 |
-
|
27 |
-
### Camera Details
|
28 |
-
- Camera : Hood Cam
|
29 |
-
- Vehical Camera Height : Low
|
30 |
-
- First Person Vehical Auto-Center : On
|
31 |
-
- First Person Head Bobbing : Off
|
32 |
-
|
33 |
-
### Other Details
|
34 |
-
- Vehical : Michael's Car
|
35 |
-
- Vehical Mods : All Max
|
36 |
-
- Cv2 Mask : None
|
37 |
-
- Way Point : Enabled/Following
|
38 |
-
- Weather Conditions : Mostly Sunny
|
39 |
-
- Time of Day : Day, Night
|
40 |
-
- Rain : Some
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Training Data(1-100)/mini/training_data-mini.npy
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:489bbaecce52d879c1f6b629d7e49171db26a2cbbd81ca754da4a79cde7377e6
|
3 |
-
size 1944328936
|
|
|
|
|
|
|
|
Training Data(1-100)/mini/training_data_stats.py
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
#training_data_stats.py
|
2 |
-
import cv2
|
3 |
-
import numpy as np
|
4 |
-
import time
|
5 |
-
from collections import Counter
|
6 |
-
import pandas as pd
|
7 |
-
|
8 |
-
def get_count_choices(a,b):
|
9 |
-
total_count_choices = Counter()
|
10 |
-
for i in range(a,b):
|
11 |
-
training_data = np.load(f'training_data-mini.npy', allow_pickle=True)
|
12 |
-
choices = [str(data[1]) for data in training_data]
|
13 |
-
|
14 |
-
total_count_choices.update(choices)
|
15 |
-
count_choices_dict = dict(total_count_choices)
|
16 |
-
print(count_choices_dict)
|
17 |
-
|
18 |
-
def get_count_choices_per_file(a,b):
|
19 |
-
df = pd.DataFrame(columns=['File','W','S','A','D','WA','WD','SA','SD','NK','NONE'])
|
20 |
-
choice_to_column = {'[1, 0, 0, 0, 0, 0, 0, 0, 0]':'W',
|
21 |
-
'[0, 1, 0, 0, 0, 0, 0, 0, 0]':'S',
|
22 |
-
'[0, 0, 1, 0, 0, 0, 0, 0, 0]':'A',
|
23 |
-
'[0, 0, 0, 1, 0, 0, 0, 0, 0]':'D',
|
24 |
-
'[0, 0, 0, 0, 1, 0, 0, 0, 0]':'WA',
|
25 |
-
'[0, 0, 0, 0, 0, 1, 0, 0, 0]':'WD',
|
26 |
-
'[0, 0, 0, 0, 0, 0, 1, 0, 0]':'SA',
|
27 |
-
'[0, 0, 0, 0, 0, 0, 0, 1, 0]':'SD',
|
28 |
-
'[0, 0, 0, 0, 0, 0, 0, 0, 1]':'NK',
|
29 |
-
'None':'NONE'}
|
30 |
-
for i in range(a,b):
|
31 |
-
training_data = np.load(f'training_data-mini.npy', allow_pickle=True)
|
32 |
-
choice = [str(data[1]) for data in training_data]
|
33 |
-
count_choices = Counter(choice)
|
34 |
-
count_choices_dict = dict(count_choices)
|
35 |
-
df = df.append({'File': f'training_data-{i}.npy'}, ignore_index=True)
|
36 |
-
for key in count_choices_dict:
|
37 |
-
#print(key,':',count_choices_dict[key])
|
38 |
-
if key == None:
|
39 |
-
df.loc[i-a,'NONE'] = count_choices_dict['NONE']
|
40 |
-
else:
|
41 |
-
df.loc[i-a,choice_to_column[key]] = count_choices_dict[key]
|
42 |
-
#print(df)
|
43 |
-
df.replace(np.nan, 0, inplace=True)
|
44 |
-
df.to_csv('training_data_count_101-200.csv', index=False)
|
45 |
-
|
46 |
-
|
47 |
-
def roi(img, vertices):
|
48 |
-
# Applies ROI Mask to Image
|
49 |
-
mask = np.zeros_like(img)
|
50 |
-
cv2.fillPoly(mask, vertices, color=[255,255,255])
|
51 |
-
masked = cv2.bitwise_and(img, mask)
|
52 |
-
return masked
|
53 |
-
|
54 |
-
def display_training_data(n):
|
55 |
-
'''
|
56 |
-
Displays training data
|
57 |
-
'''
|
58 |
-
training_data = np.load(f'training_data-{n}.npy', allow_pickle=True)
|
59 |
-
mask = False #True
|
60 |
-
|
61 |
-
if mask:
|
62 |
-
# Masking Region of Interest
|
63 |
-
vertices = np.array([[0,25],[0,270],[100,270],[100,200],[430,200],[430,270],[480,270],[480,25],], np.int32)
|
64 |
-
|
65 |
-
for data in training_data:
|
66 |
-
img = data[0]
|
67 |
-
choice = data[1]
|
68 |
-
|
69 |
-
if mask:
|
70 |
-
img = roi(img, [vertices])
|
71 |
-
|
72 |
-
cv2.imshow('screen', img)
|
73 |
-
print(choice)
|
74 |
-
print(img.shape)
|
75 |
-
|
76 |
-
if cv2.waitKey(25) & 0xFF == ord('q'):
|
77 |
-
cv2.destroyAllWindows()
|
78 |
-
break
|
79 |
-
|
80 |
-
if __name__ == "__main__":
|
81 |
-
start_time = time.time()
|
82 |
-
#get_count_choices(1,2)
|
83 |
-
get_count_choices_per_file(1,2)
|
84 |
-
#display_training_data('mini')
|
85 |
-
print(f'Elapsed time: {time.time() - start_time} seconds')
|
86 |
-
|
87 |
-
# Output:
|
88 |
-
'''
|
89 |
-
'W': [1, 0, 0, 0, 0, 0, 0, 0, 0] : 3627
|
90 |
-
'S': [0, 1, 0, 0, 0, 0, 0, 0, 0] : 50
|
91 |
-
'A': [0, 0, 1, 0, 0, 0, 0, 0, 0] : 104
|
92 |
-
'D': [0, 0, 0, 1, 0, 0, 0, 0, 0] : 106
|
93 |
-
'WA': [0, 0, 0, 0, 1, 0, 0, 0, 0] : 364
|
94 |
-
'WD': [0, 0, 0, 0, 0, 1, 0, 0, 0] : 416
|
95 |
-
'SA': [0, 0, 0, 0, 0, 0, 1, 0, 0] : 35
|
96 |
-
'SD': [0, 0, 0, 0, 0, 0, 0, 1, 0] : 47
|
97 |
-
'NK': [0, 0, 0, 0, 0, 0, 0, 0, 1] : 248
|
98 |
-
NONE : 3
|
99 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Training Data(1-100)/training_data_count_001-100.csv
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
File,W,S,A,D,WA,WD,SA,SD,NK,NONE
|
2 |
-
training_data-1.npy,3442,0,165,197,348,233,0,0,615,0
|
3 |
-
training_data-2.npy,3566,48,125,90,373,379,0,0,418,1
|
4 |
-
training_data-3.npy,3310,0,214,163,272,269,0,0,771,1
|
5 |
-
training_data-4.npy,3263,54,219,295,632,365,3,0,167,2
|
6 |
-
training_data-5.npy,3411,46,174,163,267,397,46,0,495,1
|
7 |
-
training_data-6.npy,3143,92,187,113,336,421,23,58,625,2
|
8 |
-
training_data-7.npy,3035,122,247,185,296,406,11,3,694,1
|
9 |
-
training_data-8.npy,3440,47,194,114,326,467,0,1,406,5
|
10 |
-
training_data-9.npy,3259,10,125,92,257,159,61,120,916,1
|
11 |
-
training_data-10.npy,4190,0,151,10,263,243,0,0,140,3
|
12 |
-
training_data-11.npy,4203,0,57,21,235,366,0,0,117,1
|
13 |
-
training_data-12.npy,4213,0,29,47,235,244,0,0,231,1
|
14 |
-
training_data-13.npy,3294,59,166,153,281,248,0,0,797,2
|
15 |
-
training_data-14.npy,3814,0,18,53,477,348,0,0,289,1
|
16 |
-
training_data-15.npy,3157,46,192,313,264,393,0,97,536,2
|
17 |
-
training_data-16.npy,3234,90,143,232,509,304,56,29,400,3
|
18 |
-
training_data-17.npy,3398,122,172,207,309,323,0,27,441,1
|
19 |
-
training_data-18.npy,3839,0,47,68,267,318,0,0,460,1
|
20 |
-
training_data-19.npy,2809,79,415,153,399,242,18,0,884,1
|
21 |
-
training_data-20.npy,3955,24,78,46,161,335,0,0,400,1
|
22 |
-
training_data-21.npy,2731,45,231,210,516,397,8,174,685,3
|
23 |
-
training_data-22.npy,3164,6,460,353,229,337,0,1,450,0
|
24 |
-
training_data-23.npy,2536,5,346,524,376,692,9,0,511,1
|
25 |
-
training_data-24.npy,3680,0,192,200,266,395,0,0,266,1
|
26 |
-
training_data-25.npy,4054,19,42,26,221,381,0,0,255,2
|
27 |
-
training_data-26.npy,3792,84,70,65,307,283,2,118,278,1
|
28 |
-
training_data-27.npy,3348,109,193,124,242,376,6,12,589,1
|
29 |
-
training_data-28.npy,3753,0,135,143,237,393,0,0,338,1
|
30 |
-
training_data-29.npy,2868,2,362,410,344,271,3,60,677,3
|
31 |
-
training_data-30.npy,3463,3,167,215,344,249,0,37,521,1
|
32 |
-
training_data-31.npy,3485,69,242,137,486,261,72,92,137,19
|
33 |
-
training_data-32.npy,4295,0,28,29,214,259,0,0,174,1
|
34 |
-
training_data-33.npy,3394,10,356,146,222,306,0,0,563,3
|
35 |
-
training_data-34.npy,4285,16,67,15,189,242,0,0,184,2
|
36 |
-
training_data-35.npy,4098,30,112,15,221,193,27,0,304,0
|
37 |
-
training_data-36.npy,4089,0,71,31,303,240,0,0,262,4
|
38 |
-
training_data-37.npy,3343,13,96,159,231,414,93,0,644,7
|
39 |
-
training_data-38.npy,4022,0,61,79,300,284,0,0,251,3
|
40 |
-
training_data-39.npy,3351,27,249,207,258,252,31,87,538,0
|
41 |
-
training_data-40.npy,3303,56,254,164,316,373,0,0,529,5
|
42 |
-
training_data-41.npy,4054,28,87,72,219,249,43,0,246,2
|
43 |
-
training_data-42.npy,2914,62,380,187,420,426,0,0,610,1
|
44 |
-
training_data-43.npy,3338,13,95,155,473,507,0,25,393,1
|
45 |
-
training_data-44.npy,3728,0,95,104,352,277,0,0,443,1
|
46 |
-
training_data-45.npy,3911,3,101,86,272,209,45,0,368,5
|
47 |
-
training_data-46.npy,3874,0,113,62,340,343,0,0,268,0
|
48 |
-
training_data-47.npy,3841,24,59,95,258,186,0,2,532,3
|
49 |
-
training_data-48.npy,4386,0,17,4,282,197,0,0,112,2
|
50 |
-
training_data-49.npy,3380,79,123,116,295,238,51,66,651,1
|
51 |
-
training_data-50.npy,4165,0,57,40,291,250,0,0,197,0
|
52 |
-
training_data-51.npy,3684,15,100,74,392,267,32,29,403,4
|
53 |
-
training_data-52.npy,3495,78,148,94,374,391,10,4,405,1
|
54 |
-
training_data-53.npy,3721,0,77,123,231,290,0,0,557,1
|
55 |
-
training_data-54.npy,3344,28,147,195,274,316,58,0,636,2
|
56 |
-
training_data-55.npy,4144,0,27,14,273,256,0,0,286,0
|
57 |
-
training_data-56.npy,3993,0,29,12,292,241,0,0,431,2
|
58 |
-
training_data-57.npy,3559,13,94,55,367,453,68,0,389,2
|
59 |
-
training_data-58.npy,3329,2,228,225,317,338,64,3,493,1
|
60 |
-
training_data-59.npy,3675,24,136,81,349,329,0,0,403,3
|
61 |
-
training_data-60.npy,3284,0,122,155,363,230,18,29,794,5
|
62 |
-
training_data-61.npy,3662,0,115,14,178,157,0,0,872,2
|
63 |
-
training_data-62.npy,3535,9,81,54,328,332,114,0,545,2
|
64 |
-
training_data-63.npy,3118,49,148,170,246,227,0,0,1039,3
|
65 |
-
training_data-64.npy,3170,0,287,150,252,326,0,0,809,6
|
66 |
-
training_data-65.npy,3257,42,161,254,430,359,0,0,496,1
|
67 |
-
training_data-66.npy,4023,0,30,22,208,284,0,0,433,0
|
68 |
-
training_data-67.npy,4176,0,7,26,274,183,0,0,333,1
|
69 |
-
training_data-68.npy,3648,0,121,103,264,238,0,0,625,1
|
70 |
-
training_data-69.npy,3859,0,64,64,247,222,0,0,544,0
|
71 |
-
training_data-70.npy,3391,26,127,145,322,234,0,0,754,1
|
72 |
-
training_data-71.npy,2771,0,345,462,293,229,0,0,899,1
|
73 |
-
training_data-72.npy,2930,7,258,173,300,265,109,0,951,7
|
74 |
-
training_data-73.npy,3797,18,174,79,204,244,8,0,473,3
|
75 |
-
training_data-74.npy,3621,0,27,110,320,209,0,0,713,0
|
76 |
-
training_data-75.npy,3635,0,60,6,125,128,0,0,1044,2
|
77 |
-
training_data-76.npy,2755,0,228,244,356,352,0,0,1059,6
|
78 |
-
training_data-77.npy,3649,26,155,211,322,378,0,13,243,3
|
79 |
-
training_data-78.npy,3334,0,97,125,370,326,115,0,632,1
|
80 |
-
training_data-79.npy,4224,0,0,6,246,301,0,0,223,0
|
81 |
-
training_data-80.npy,4034,0,75,57,153,160,0,0,520,1
|
82 |
-
training_data-81.npy,3851,21,96,44,218,320,0,0,445,5
|
83 |
-
training_data-82.npy,3682,0,67,70,266,271,0,0,640,4
|
84 |
-
training_data-83.npy,3429,47,40,122,482,260,59,0,560,1
|
85 |
-
training_data-84.npy,3179,1,192,98,298,344,46,0,838,4
|
86 |
-
training_data-85.npy,2804,0,299,249,536,421,65,65,555,6
|
87 |
-
training_data-86.npy,3188,38,157,279,513,254,90,71,403,7
|
88 |
-
training_data-87.npy,4184,0,5,16,211,291,0,0,292,1
|
89 |
-
training_data-88.npy,3988,41,21,42,214,255,0,0,436,3
|
90 |
-
training_data-89.npy,3255,5,160,90,390,290,139,0,665,6
|
91 |
-
training_data-90.npy,3777,0,62,200,243,241,0,0,475,2
|
92 |
-
training_data-91.npy,3398,153,30,56,262,298,11,121,665,6
|
93 |
-
training_data-92.npy,4025,0,3,42,161,210,0,0,554,5
|
94 |
-
training_data-93.npy,3908,0,71,37,212,216,0,0,553,3
|
95 |
-
training_data-94.npy,3276,0,96,102,295,219,0,0,1010,2
|
96 |
-
training_data-95.npy,2747,6,282,254,361,205,85,0,1057,3
|
97 |
-
training_data-96.npy,2792,0,328,189,307,281,11,28,1058,6
|
98 |
-
training_data-97.npy,3309,4,155,188,419,344,180,71,326,4
|
99 |
-
training_data-98.npy,3668,14,121,52,376,378,20,0,371,0
|
100 |
-
training_data-99.npy,2485,34,284,279,459,257,42,8,1148,4
|
101 |
-
training_data-100.npy,3343,0,187,314,453,277,0,0,423,3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Training Data(1-100)/training_data_stats.py
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
# training_data_stats.py
|
2 |
-
import cv2
|
3 |
-
import numpy as np
|
4 |
-
import time
|
5 |
-
from collections import Counter
|
6 |
-
import pandas as pd
|
7 |
-
|
8 |
-
def get_count_choices(a,b):
|
9 |
-
total_count_choices = Counter()
|
10 |
-
for i in range(a,b):
|
11 |
-
training_data = np.load(f'training_data-{i}.npy', allow_pickle=True)
|
12 |
-
choices = [str(data[1]) for data in training_data]
|
13 |
-
|
14 |
-
total_count_choices.update(choices)
|
15 |
-
count_choices_dict = dict(total_count_choices)
|
16 |
-
print(count_choices_dict)
|
17 |
-
|
18 |
-
def get_count_choices_per_file(a,b):
|
19 |
-
df = pd.DataFrame(columns=['File','W','S','A','D','WA','WD','SA','SD','NK','NONE'])
|
20 |
-
choice_to_column = {'[1, 0, 0, 0, 0, 0, 0, 0, 0]':'W',
|
21 |
-
'[0, 1, 0, 0, 0, 0, 0, 0, 0]':'S',
|
22 |
-
'[0, 0, 1, 0, 0, 0, 0, 0, 0]':'A',
|
23 |
-
'[0, 0, 0, 1, 0, 0, 0, 0, 0]':'D',
|
24 |
-
'[0, 0, 0, 0, 1, 0, 0, 0, 0]':'WA',
|
25 |
-
'[0, 0, 0, 0, 0, 1, 0, 0, 0]':'WD',
|
26 |
-
'[0, 0, 0, 0, 0, 0, 1, 0, 0]':'SA',
|
27 |
-
'[0, 0, 0, 0, 0, 0, 0, 1, 0]':'SD',
|
28 |
-
'[0, 0, 0, 0, 0, 0, 0, 0, 1]':'NK',
|
29 |
-
'None':'NONE'}
|
30 |
-
for i in range(a,b):
|
31 |
-
training_data = np.load(f'training_data-{i}.npy', allow_pickle=True)
|
32 |
-
choice = [str(data[1]) for data in training_data]
|
33 |
-
count_choices = Counter(choice)
|
34 |
-
count_choices_dict = dict(count_choices)
|
35 |
-
df = df.append({'File': f'training_data-{i}.npy'}, ignore_index=True)
|
36 |
-
for key in count_choices_dict:
|
37 |
-
#print(key,':',count_choices_dict[key])
|
38 |
-
if key == None:
|
39 |
-
df.loc[i-a,'NONE'] = count_choices_dict['NONE']
|
40 |
-
else:
|
41 |
-
df.loc[i-a,choice_to_column[key]] = count_choices_dict[key]
|
42 |
-
#print(df)
|
43 |
-
df.replace(np.nan, 0, inplace=True)
|
44 |
-
df.to_csv('training_data_count_001-100.csv', index=False)
|
45 |
-
|
46 |
-
def roi(img, vertices):
|
47 |
-
# Applies ROI Mask to Image
|
48 |
-
mask = np.zeros_like(img)
|
49 |
-
cv2.fillPoly(mask, vertices, color=[255,255,255])
|
50 |
-
masked = cv2.bitwise_and(img, mask)
|
51 |
-
return masked
|
52 |
-
|
53 |
-
def display_training_data(n):
|
54 |
-
'''
|
55 |
-
Displays training data
|
56 |
-
'''
|
57 |
-
training_data = np.load(f'training_data-{n}.npy', allow_pickle=True)
|
58 |
-
mask = False #True
|
59 |
-
|
60 |
-
if mask:
|
61 |
-
# Masking Region of Interest
|
62 |
-
vertices = np.array([[0,25],[0,270],[100,270],[100,200],[430,200],[430,270],[480,270],[480,25],], np.int32)
|
63 |
-
|
64 |
-
for data in training_data:
|
65 |
-
img = data[0]
|
66 |
-
choice = data[1]
|
67 |
-
|
68 |
-
if mask:
|
69 |
-
img = roi(img, [vertices])
|
70 |
-
|
71 |
-
cv2.imshow('screen', img)
|
72 |
-
print(choice)
|
73 |
-
print(img.shape)
|
74 |
-
|
75 |
-
if cv2.waitKey(25) & 0xFF == ord('q'):
|
76 |
-
cv2.destroyAllWindows()
|
77 |
-
break
|
78 |
-
|
79 |
-
if __name__ == "__main__":
|
80 |
-
start_time = time.time()
|
81 |
-
#get_count_choices(1,101)
|
82 |
-
get_count_choices_per_file(1,101)
|
83 |
-
#display_training_data(74)
|
84 |
-
print(f'Elapsed time: {time.time() - start_time} seconds')
|
85 |
-
|
86 |
-
# Output:
|
87 |
-
'''
|
88 |
-
Image Resolution : (270, 480, 3)
|
89 |
-
'W': [1, 0, 0, 0, 0, 0, 0, 0, 0] : 353725
|
90 |
-
'S': [0, 1, 0, 0, 0, 0, 0, 0, 0] : 2243
|
91 |
-
'A': [0, 0, 1, 0, 0, 0, 0, 0, 0] : 14303
|
92 |
-
'D': [0, 0, 0, 1, 0, 0, 0, 0, 0] : 13114
|
93 |
-
'WA': [0, 0, 0, 0, 1, 0, 0, 0, 0] : 30877
|
94 |
-
'WD': [0, 0, 0, 0, 0, 1, 0, 0, 0] : 29837
|
95 |
-
'SA': [0, 0, 0, 0, 0, 0, 1, 0, 0] : 1952
|
96 |
-
'SD': [0, 0, 0, 0, 0, 0, 0, 1, 0] : 1451
|
97 |
-
'NK': [0, 0, 0, 0, 0, 0, 0, 0, 1] : 52256
|
98 |
-
NONE : 242
|
99 |
-
'''
|
100 |
-
# Elapsed time: 181.86165976524353 seconds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|