Skip to content

Commit 89cbded

Browse files
Merge pull request #381 from Programmer-RD-AI/deepsource-fix-c27dbd67
Remove unnecessary whitespace
2 parents 03baadf + 0b07acb commit 89cbded

File tree

3 files changed

+162
-261
lines changed

3 files changed

+162
-261
lines changed

.history/ML/Model/dataset/download_20220509231425.py

Lines changed: 54 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -112,65 +112,55 @@ def __init__(
112112
self.idx_2 = idx_2
113113
self.idx_3 = idx_3
114114
except Exception as e:
115-
raise ValueError(
116-
f"""
115+
raise ValueError(f"""
117116
In the indexing parameters
118117
there was a error occurred
119118
\n
120-
{e}"""
121-
)
119+
{e}""")
122120
try:
123121
# Initinalizing Data Storage
124122
self.data = data
125123
except Exception as e:
126-
raise ValueError(
127-
f"""
124+
raise ValueError(f"""
128125
In the Initinalizing Data Storage
129126
parameters there was a error occurred.
130127
\n
131-
{e}"""
132-
)
128+
{e}""")
133129
try:
134130
# Labels of data
135131
self.labels = labels
136132
self.labels_r = labels_r
137133
except Exception as e:
138-
raise ValueError(
139-
f"""
134+
raise ValueError(f"""
140135
In the Labels of data
141136
parameters there was a error occurred
142137
\n
143138
{e}
144-
"""
145-
)
139+
""")
146140
try:
147141
# Data Loading file paths
148142
self.labels_and_imageids = labels_and_imageids
149143
self.bboxs = bboxs
150144
self.image_urls = image_urls
151145
except Exception as e:
152-
raise ValueError(
153-
f"""
146+
raise ValueError(f"""
154147
In the Data Loading
155148
file paths parameters there
156149
was a error occurred.
157150
\n
158-
{e}"""
159-
)
151+
{e}""")
160152
try:
161153
# Collection of data
162154
self.imageids = init_imageids
163155
self.images_and_bbox_and_imgid_ = images_and_bbox_and_imgid_
164156
self.imgids = imgids
165157
except Exception as e:
166-
raise ValueError(
167-
f"""
158+
raise ValueError(f"""
168159
In the Collection of data
169160
parameters there was a error occurred
170161
\n
171162
{e}
172-
"""
173-
)
163+
""")
174164

175165
# Loading data section
176166

@@ -186,22 +176,19 @@ def load_labels_and_imageid(self) -> pd.DataFrame:
186176
loader_iter = tqdm(range(1, len(self.labels_and_imageids)))
187177
for i in loader_iter:
188178
labels_and_imageid = labels_and_imageid.append(
189-
pd.read_csv(self.labels_and_imageids[i])
190-
)
179+
pd.read_csv(self.labels_and_imageids[i]))
191180
loader_iter.set_description(str(len(labels_and_imageid)))
192181
labels_and_imageid.sample(frac=1)
193182
return labels_and_imageid
194183
except Exception as e:
195-
raise ValueError(
196-
f"""
184+
raise ValueError(f"""
197185
The function
198186
self.load_labels_and_imageid()
199187
or
200188
Download().load_labels_and_imageid()
201189
is not working correctly.
202190
\n
203-
{e}"""
204-
)
191+
{e}""")
205192

206193
def load_bbox(self) -> pd.DataFrame:
207194
"""summary_line
@@ -221,16 +208,14 @@ def load_bbox(self) -> pd.DataFrame:
221208

222209
return bboxs_df
223210
except Exception as e:
224-
raise ValueError(
225-
f"""
211+
raise ValueError(f"""
226212
The function
227213
self.load_bbox()
228214
or
229215
Download().load_bbox()
230216
is not working correctly.
231217
\n
232-
{e}"""
233-
)
218+
{e}""")
234219

235220
def load_image_urls(self) -> pd.DataFrame:
236221
"""summary_line
@@ -245,22 +230,21 @@ def load_image_urls(self) -> pd.DataFrame:
245230
loader_iter = tqdm(range(1, len(self.image_urls)))
246231
for i in loader_iter:
247232
loader_iter.set_description(str(len(image_urls_df)))
248-
image_urls_df = image_urls_df.append(pd.read_csv(self.image_urls[i]))
233+
image_urls_df = image_urls_df.append(
234+
pd.read_csv(self.image_urls[i]))
249235
image_urls_df.sample(frac=1)
250236

251237
print("Loaded Image Urls")
252238
return image_urls_df
253239
except Exception as e:
254-
raise ValueError(
255-
f"""
240+
raise ValueError(f"""
256241
The function
257242
self.load_image_urls()
258243
or
259244
Download().load_image_urls()
260245
is not working correctly.
261246
\n
262-
{e}"""
263-
)
247+
{e}""")
264248

265249
# Creating data section
266250

@@ -275,8 +259,8 @@ def create_imageids(self) -> bool:
275259
print("Creating imageids")
276260
labels_and_imageid = self.load_labels_and_imageid()
277261
for labelname, imageid in zip(
278-
tqdm(labels_and_imageid["LabelName"]), labels_and_imageid["ImageID"]
279-
):
262+
tqdm(labels_and_imageid["LabelName"]),
263+
labels_and_imageid["ImageID"]):
280264
if labelname in self.labels_r:
281265
self.idx_1 += 1
282266
threading.Thread(
@@ -291,16 +275,14 @@ def create_imageids(self) -> bool:
291275

292276
return True
293277
except Exception as e:
294-
raise ValueError(
295-
f"""
278+
raise ValueError(f"""
296279
The function
297280
self.create_imageids()
298281
or
299282
Download().create_imageids()
300283
is not working correctly.
301284
\n
302-
{e}"""
303-
)
285+
{e}""")
304286

305287
def create_bbox(self) -> bool:
306288
"""summary_line
@@ -310,24 +292,21 @@ def create_bbox(self) -> bool:
310292
"""
311293
try:
312294

313-
if self.recover is True and (
314-
os.path.exists(
295+
if self.recover is True and (os.path.exists(
315296
"/media/indika/Sync/Programmer-RD-AI/Programming/Projects/Python/Rest-Api/Car-Object-Detection-REST-API/Find-Card/ML/Model/dataset/save/create_bbox.csv"
316-
)
317-
is True
318-
):
297+
) is True):
319298
self.images_and_bbox_and_imgid_ = pd.read_csv(
320299
"/media/indika/Sync/Programmer-RD-AI/Programming/Projects/Python/Rest-Api/Car-Object-Detection-REST-API/Find-Card/ML/Model/dataset/save/create_bbox.csv"
321300
)
322301
return True
323302
print("Creating Box")
324303
bboxs = self.load_bbox()
325304
for imgid in zip(
326-
tqdm(bboxs["ImageID"]),
327-
bboxs["XMin"],
328-
bboxs["YMin"],
329-
bboxs["XMax"],
330-
bboxs["YMax"],
305+
tqdm(bboxs["ImageID"]),
306+
bboxs["XMin"],
307+
bboxs["YMin"],
308+
bboxs["XMax"],
309+
bboxs["YMax"],
331310
):
332311
imgid = list(imgid)
333312
if str(imgid[0]) in self.imageids:
@@ -363,16 +342,14 @@ def create_bbox(self) -> bool:
363342

364343
return True
365344
except Exception as e:
366-
raise ValueError(
367-
f"""
345+
raise ValueError(f"""
368346
The function
369347
self.create_bbox()
370348
or
371349
Download().create_bbox()
372350
is not working correctly.
373351
\n
374-
{e}"""
375-
)
352+
{e}""")
376353

377354
def create_image_urls(self) -> bool:
378355
"""summary_line
@@ -382,16 +359,14 @@ def create_image_urls(self) -> bool:
382359
"""
383360
try:
384361

385-
if self.recover is True and (
386-
os.path.exists(
362+
if self.recover is True and (os.path.exists(
387363
"/media/indika/Sync/Programmer-RD-AI/Programming/Projects/Python/Rest-Api/Car-Object-Detection-REST-API/Find-Card/ML/Model/dataset/save/create_image_urls.csv"
388-
)
389-
is True
390-
):
364+
) is True):
391365
self.download_url_data = pd.read_csv(
392366
"/media/indika/Sync/Programmer-RD-AI/Programming/Projects/Python/Rest-Api/Car-Object-Detection-REST-API/Find-Card/ML/Model/dataset/save/create_image_urls.csv"
393367
) # [: self.number_of_split]
394-
self.download_url_data = self.download_url_data.drop_duplicates()
368+
self.download_url_data = self.download_url_data.drop_duplicates(
369+
)
395370
return True
396371
print("Creating Image Urls")
397372
data = {
@@ -406,18 +381,17 @@ def create_image_urls(self) -> bool:
406381
}
407382
image_urls = self.load_image_urls()
408383
for imgid in zip(
409-
tqdm((image_urls["ImageID"])),
410-
image_urls["OriginalURL"],
411-
image_urls["OriginalLandingURL"],
384+
tqdm((image_urls["ImageID"])),
385+
image_urls["OriginalURL"],
386+
image_urls["OriginalLandingURL"],
412387
):
413388
if imgid[0] in self.imgids:
414389
imgid_of_iabaid = self.images_and_bbox_and_imgid_[
415-
self.images_and_bbox_and_imgid_["ImageID"] == imgid[0]
416-
]
390+
self.images_and_bbox_and_imgid_["ImageID"] == imgid[0]]
417391
for idx_3 in range(len(imgid_of_iabaid)):
418392
imgid_of_iabaid_iter = self.images_and_bbox_and_imgid_[
419-
self.images_and_bbox_and_imgid_["ImageID"] == imgid[0]
420-
].iloc[idx_3]
393+
self.images_and_bbox_and_imgid_["ImageID"] ==
394+
imgid[0]].iloc[idx_3]
421395
threading.Thread(
422396
target=data["ImageID"].append,
423397
args=[imgid[0]],
@@ -464,16 +438,14 @@ def create_image_urls(self) -> bool:
464438

465439
return True
466440
except Exception as e:
467-
raise ValueError(
468-
f"""
441+
raise ValueError(f"""
469442
The function
470443
self.create_image_urls()
471444
or
472445
Download().create_image_urls()
473446
is not working correctly.
474447
\n
475-
{e}"""
476-
)
448+
{e}""")
477449

478450
# Downloading data section
479451

@@ -498,12 +470,12 @@ def download_images(self) -> pd.DataFrame:
498470
image_id_iter = tqdm((self.download_url_data["ImageID"]))
499471
old_ourl = ""
500472
for img_url, xmin, ymin, xmax, ymax, ourl in zip(
501-
image_id_iter,
502-
self.download_url_data["XMin"],
503-
self.download_url_data["YMin"],
504-
self.download_url_data["XMax"],
505-
self.download_url_data["YMax"],
506-
self.download_url_data["OriginalURL"],
473+
image_id_iter,
474+
self.download_url_data["XMin"],
475+
self.download_url_data["YMin"],
476+
self.download_url_data["XMax"],
477+
self.download_url_data["YMax"],
478+
self.download_url_data["OriginalURL"],
507479
):
508480
try:
509481
if ourl != old_ourl:
@@ -530,21 +502,18 @@ def download_images(self) -> pd.DataFrame:
530502
)
531503
data.to_json(
532504
"/media/indika/Sync/Programmer-RD-AI/Programming/Projects/Python/Rest-Api/Car-Object-Detection-REST-API/Find-Card/ML/Model/dataset/save/Data.csv",
533-
534505
)
535506
print("Downloaded Images")
536507
return new_data
537508
except Exception as e:
538-
raise ValueError(
539-
f"""
509+
raise ValueError(f"""
540510
The function
541511
self.download_images()
542512
or
543513
Download().download_images()
544514
is not working correctly.
545515
\n
546-
{e}"""
547-
)
516+
{e}""")
548517

549518
def download(self) -> bool:
550519
"""summary_line
@@ -565,12 +534,10 @@ def download(self) -> bool:
565534

566535
print("Finished Download Process")
567536
except Exception as e:
568-
raise ValueError(
569-
f"""
537+
raise ValueError(f"""
570538
The function self.download()
571539
or
572540
Download().download()
573541
is not working correctly.
574542
\n
575-
{e}"""
576-
)
543+
{e}""")

0 commit comments

Comments
 (0)