Skip to content

Commit e9db096

Browse files
refactor: remove unnecessary whitespace
Blank lines should not contain any tabs or spaces.
1 parent b30201b commit e9db096

9 files changed

+50
-53
lines changed

auctionhouse.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
for ki,index in enumerate(indices): # ki is index of the kernel so far
4141
slice_conv[x] += slice_g[index] * k[ki]
42-
42+
4343
# print(slice_g[x], slice_conv[x])
4444

4545
# find transitions
@@ -72,7 +72,7 @@
7272
# count += 1
7373
elif val == 1 and startx > -1: # not the first one
7474
endx = i
75-
75+
7676
if endx - startx > 200:
7777
extents.append([startx+35,endx]) # add 35 to account for offset
7878
# TODO change this so it throws away first two points
@@ -173,7 +173,7 @@
173173
total_num_peaks=1)
174174
section[2] = cv2.circle(section[2], (cx[0],cy[0]), radii[0]+1, 1, -1)
175175

176-
176+
177177
# erode for better OCR
178178
for section in sections:
179179
section[0] = cv2.erode(section[0], np.ones((2,2), np.uint8), iterations=1)
@@ -189,7 +189,7 @@
189189
section[5] = cv2.morphologyEx(section[5], cv2.MORPH_CLOSE, np.ones((3,3)))
190190
plt.hist(section[5], [0,50,100,150,200,255])
191191
plt.show()
192-
192+
193193

194194

195195
# show sections
@@ -205,17 +205,16 @@
205205
overall = pytesseract.image_to_string(Image.fromarray(section[3].astype(np.uint8)),config=tessdata_dir_config)
206206
position = pytesseract.image_to_string(Image.fromarray(section[4].astype(np.uint8)),config=tessdata_dir_config)
207207
name = pytesseract.image_to_string(Image.fromarray(section[5].astype(np.uint8)),config=tessdata_dir_config)
208-
208+
209209
message = f"{overall} {name} who plays {position} has {timestamp} left on auction. Winning Bid is {winning_bid} while BIN is {buy_it_now}"
210210
alt_message = f"""Timestamp: {timestamp}
211211
Winning Bid: {winning_bid}
212212
Buy it Now: {buy_it_now}
213213
Overall: {overall}
214214
Position: {position}
215215
Name: {name}"""
216-
216+
217217
print(alt_message)
218-
218+
219219
plt.show()
220220

221-

efficientnet_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def load_data():
1717
image = imread("./samples/2021-05-02_17;54;46/img_191.png")
18-
18+
1919
plt.figure(figsize=(10, 10))
2020
plt.imshow(image)
2121
plt.show()

map_analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ def analyze(img):
6363
plt.imshow(img, cmap="gray")
6464
plt.scatter([point[0] for point in circle_points], [point[1] for point in circle_points])
6565
plt.hist(img.ravel(), 256, (0,256))
66-
66+
6767
plt.show()
6868
i+=20

ocrtest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def get_grayscale(image):
1414
# noise removal
1515
def remove_noise(image):
1616
return cv2.medianBlur(image,5)
17-
17+
1818
#thresholding
1919
def thresholding(image):
2020
return cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
@@ -23,7 +23,7 @@ def thresholding(image):
2323
def dilate(image):
2424
kernel = np.ones((5,5),np.uint8)
2525
return cv2.dilate(image, kernel, iterations = 1)
26-
26+
2727
#erosion
2828
def erode(image):
2929
kernel = np.ones((5,5),np.uint8)
@@ -82,4 +82,4 @@ def preprocess_img(img):
8282
img = preprocess_img(img)
8383

8484
print(pytesseract.image_to_string(img,config=tessdata_dir_config))
85-
85+

openvino_test.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def start():
2424

2525
net = ie.read_network(model="model/road-segmentation-adas-0001.xml")
2626
exec_net = ie.load_network(net, "CPU")
27-
27+
2828
output_layer_ir = next(iter(exec_net.outputs))
2929
input_layer_ir = next(iter(exec_net.input_info))
3030

@@ -66,46 +66,46 @@ def inference(image, ie, net, exec_net, output_layer_ir, input_layer_ir, return_
6666
# image = cv2.imread("data/empty_road_mapillary.jpg")
6767
# image = read_img_from_num(int(input("Image number: ")))
6868
# print(type(image))
69-
69+
7070
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
7171
image_h, image_w, _ = image.shape
72-
72+
7373
# N,C,H,W = batch size, number of channels, height, width
7474
N, C, H, W = net.input_info[input_layer_ir].tensor_desc.dims
75-
75+
7676
# OpenCV resize expects the destination size as (width, height)
7777
resized_image = cv2.resize(image, (W, H))
78-
78+
7979
# reshape to network input shape
8080
input_image = np.expand_dims(
8181
resized_image.transpose(2, 0, 1), 0
8282
)
8383
# plt.imshow(rgb_image)
8484
# plt.show()
85-
85+
8686
# Run the infernece
8787
result = exec_net.infer(inputs={input_layer_ir: input_image})
8888
result_ir = result[output_layer_ir]
89-
89+
9090
# Prepare data for visualization
9191
segmentation_mask = np.argmax(result_ir, axis=1)
9292
# plt.imshow(segmentation_mask[0])
9393
# plt.show()
94-
94+
9595
img = segmentation_mask[0]
9696

9797
if return_image:
9898
resized_image[img == 0] = [0, 0, 0]
9999
return resized_image
100100

101101
x, y = find_xy(img)
102-
102+
103103
# find first index where x = -1
104104
for i, xval in enumerate(x):
105105
if xval == -1:
106106
last = i
107107
break
108-
108+
109109
x = x[2:last - 1] # removing first two because they are usually outliers.
110110
y = y[2:last - 1] #z this can be manually tuned, for start and end
111111

@@ -127,7 +127,7 @@ def inference(image, ie, net, exec_net, output_layer_ir, input_layer_ir, return_
127127
# COMMENT ME OUT NOTE TODO when using with play.py
128128
# for i, item in enumerate(x):
129129
# print(f"{item}\t{y[i]}")
130-
130+
131131
try:
132132
slope = (yslope[-1] - yslope[0])/(x[-1] - x[0])
133133
except:
@@ -146,10 +146,10 @@ def inference(image, ie, net, exec_net, output_layer_ir, input_layer_ir, return_
146146
angle = -1 * (90+a)/90
147147
else:
148148
return "error"
149-
149+
150150
# angle = (x[0] - x[-1])/(y[0] - y[-1]) / 5 # NOTE This parameter should be manually tuned
151151
#print(angle)
152-
152+
153153
# has to be commented out when running in play.py
154154
xr = list(reversed(x))
155155
yr = list(reversed(y))

play.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ def cv_act_racing(self, img):
157157
print(f"ERROR: Last angle is used: {-self.lastvalue}")
158158
self.control_racing(joystick)
159159
return
160-
160+
161161
angle *= self.anglefactor
162162
self.lastvalue = angle
163-
163+
164164
print(angle)
165165
if angle > self.cutoff:
166166
angle = self.cutoff
@@ -169,7 +169,7 @@ def cv_act_racing(self, img):
169169
joystick = [angle, 0.3]
170170

171171
self.control_racing(joystick)
172-
172+
173173
def act(self, img):
174174

175175
## determine manual override
@@ -182,7 +182,7 @@ def act(self, img):
182182
## Think
183183
# joystick = self.model.predict(vec, batch_size=1)[0]
184184
joystick = categorical_model_predict(self.model, vec)
185-
185+
186186
print(joystick)
187187

188188
# if len(joystick) == 8:
@@ -200,7 +200,7 @@ def act(self, img):
200200

201201
self.control(joystick)
202202

203-
203+
204204
## Act
205205
## has been put in Think block NOTE
206206

@@ -214,7 +214,7 @@ def act(self, img):
214214
gpus = tf.config.list_physical_devices("GPU")
215215
for gpu in gpus:
216216
tf.config.experimental.set_memory_growth(gpu,True)
217-
217+
218218
# turn on program and let it run forever
219219
actor = Actor()
220220
screenshot = Screenshotter()

telemetry.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def save_waypoints():
1919
except KeyboardInterrupt:
2020
print("CtrlC detected, stopping ands saving")
2121
np.savetxt("waypoints.txt", vals)
22-
22+
2323
def get_waypoints(print_values=False):
2424
generator = return_vals(PORT_NUMBER)
25-
25+
2626
for i in generator:
2727
if print_values:
2828
print(i)
@@ -84,7 +84,7 @@ def follow_waypoints(waypoints_file="waypoints.txt"):
8484
except KeyboardInterrupt:
8585
print("Stopping due to Ctrl C Event")
8686
break
87-
87+
8888

8989

9090
if __name__ == "__main__":
@@ -97,4 +97,3 @@ def follow_waypoints(waypoints_file="waypoints.txt"):
9797
# # time.sleep(1)
9898

9999
follow_waypoints()
100-

train.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
import numpy as np
5-
5+
66
import tensorflow as tf
77

88
from tensorflow.keras.models import Sequential
@@ -204,7 +204,7 @@ def train_sequence_categorical_model(x_train, y_train, _model=sequence_categoric
204204

205205
# Train model
206206
model = _model()
207-
207+
208208
checkpoint = ModelCheckpoint("model_weights_seq_c1.h5", monitor='val_loss', verbose=1, save_best_only=True, mode='min')
209209
callbacks_list = [checkpoint]
210210

@@ -245,7 +245,7 @@ def autoencoder_model():
245245
y = Conv2DTranspose(filters=32, kernel_size=3, strides=2,
246246
name="deconv2d_5")(y)
247247
y = Conv2DTranspose(filters=1, kernel_size=3, strides=2, name="img_out")(y)
248-
248+
249249
x = Flatten(name='flattened')(x)
250250
x = Dense(256, activation='relu')(x)
251251
x = Dropout(drop)(x)
@@ -255,7 +255,7 @@ def autoencoder_model():
255255
x = Dropout(drop)(x)
256256

257257
angle_out = Dense(15, activation='softmax', name='angle_out')(x)
258-
258+
259259
model = Model(inputs=[img_in], outputs=[angle_out], name="latent")
260260
return model
261261

@@ -270,7 +270,7 @@ def train_model(x_train, y_train, _model=create_model, batch_size=128, epochs=10
270270

271271
checkpoint = ModelCheckpoint("model_weights_bal.h5", monitor='val_loss', verbose=1, save_best_only=True, mode='min')
272272
callbacks_list = [checkpoint]
273-
273+
274274
# model.compile(loss=customized_loss, optimizer="adam")
275275
# model.compile(loss="mean_squared_error", optimizer="adam")
276276
model.compile(loss="mean_squared_error", optimizer=optimizers.SGD(lr=0.1))
@@ -328,7 +328,7 @@ def train_autoencoder_model(x_train, y_train, _model=autoencoder_model, batch_si
328328
# tf.keras.utils.plot_model(sequence_categorical_model(), to_file='model.png', show_shapes=True)
329329
# exit()
330330

331-
331+
332332
# Load Training Data
333333
print("loading training data")
334334
# x_train = np.load("data/x_sbal.npy")
@@ -348,4 +348,3 @@ def train_autoencoder_model(x_train, y_train, _model=autoencoder_model, batch_si
348348
train_categorical_model(x_train, y_train, _model=categorical_model, batch_size=batch_size, epochs=epochs)
349349
# train_autoencoder_model(x_train, y_train, _model=autoencoder_model, batch_size=batch_size, epochs=epochs)
350350
# train_sequence_categorical_model(x_train, y_train, _model=sequence_categorical_model, batch_size=batch_size, epochs=epochs)
351-

0 commit comments

Comments
 (0)