Skip to content

Commit 1d1888a

Browse files
authored
Fixes after flake8 checking (#3673)
1 parent 7dbeb1d commit 1d1888a

File tree

14 files changed

+22
-21
lines changed

14 files changed

+22
-21
lines changed

demos/smartlab_demo/python/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def evaluate_end_tidy(self):
862862

863863
elif len(battery_coors) == 0:
864864
self.evaluate_rider()
865-
if self.rider_zero == True:
865+
if self.rider_zero:
866866
self.scoring["end_score_tidy"] = 1
867867
self.keyframe["end_score_tidy"] = self.frame_counter
868868
else:

demos/speech_recognition_deepspeech_demo/python/asr_utils/audio_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def samples_to_melspectrum(samples, sampling_rate, window_size, stride, n_mels,
7979
window_size, stride = round(window_size), round(stride)
8080

8181
# window_size must be a power of 2 to match tf:
82-
if not(window_size > 0 and (window_size - 1) & window_size == 0):
82+
if not (window_size > 0 and (window_size - 1) & window_size == 0):
8383
raise ValueError("window_size(ms)*sampling_rate(kHz) must be a power of two")
8484

8585
spec = np.abs(librosa.core.spectrum.stft(

demos/tests/cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def single_option_cases(key, *args):
629629
ModelArg('pspnet-pytorch'),
630630
ModelArg('drn-d-38'),
631631
# ModelArg('erfnet'), # TODO add after CI is up
632-
)),
632+
)),
633633
],
634634
)),
635635

@@ -1279,7 +1279,7 @@ def single_option_cases(key, *args):
12791279
ModelArg('pspnet-pytorch'),
12801280
ModelArg('drn-d-38'),
12811281
# ModelArg('erfnet'), # TODO add after CI is up
1282-
)),
1282+
)),
12831283
TestCase(options={
12841284
'-m': ModelArg('f3net'),
12851285
'-i': DataPatternArg('road-segmentation-adas'),

models/intel/handwritten-english-recognition-0001/preprocess_gnhk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def main():
5353
# open corresponding JSON annotation file
5454
with open(img_id + ".json") as f:
5555
data = json.load(f)
56-
line_indices = set(map(lambda obj: obj["line_idx"], data))
56+
line_indices = {obj["line_idx"] for obj in data}
5757
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
5858
img = binarize(img)
5959
for idx in sorted(line_indices):
@@ -63,7 +63,7 @@ def main():
6363
if not objects:
6464
continue
6565
objects = sorted(objects, key=lambda x: x['polygon']['x0'])
66-
label = " ".join(map(lambda obj: obj["text"], objects))
66+
label = " ".join((obj["text"] for obj in objects))
6767
print(img_id, idx, label)
6868

6969
# create mask for the words
@@ -82,12 +82,12 @@ def main():
8282
cv2.bitwise_not(bg, bg, mask = mask)
8383
overlay = bg + masked
8484
# crop bounding rectangle of the text region
85-
polys = list(map(lambda obj: [
85+
polys = [[
8686
[obj["polygon"]["x0"], obj["polygon"]["y0"]],
8787
[obj["polygon"]["x1"], obj["polygon"]["y1"]],
8888
[obj["polygon"]["x2"], obj["polygon"]["y2"]],
8989
[obj["polygon"]["x3"], obj["polygon"]["y3"]]
90-
], objects))
90+
] for obj in objects]
9191
flat = [item for sublist in polys for item in sublist]
9292
pts = np.array(flat)
9393
rect = cv2.boundingRect(pts)

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/dna_seq_recognition.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def backward_scores(self, scores):
153153
ms_t = scores[:, :, idx_t]
154154
idx_t = self._torch.div(idx_t, self.n_base + 1, rounding_mode='floor')
155155
return self.scan(ms_t.flip(0), idx_t.to(self._torch.int64), vt, self.log_semiring).flip(0)
156+
156157
def select_output_blob(self, outputs):
157158
self.output_verified = True
158159
if self.output_blob:

tools/accuracy_checker/openvino/tools/accuracy_checker/annotation_converters/_nlp_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def get_special_tokens_mask(self, token_ids_0, token_ids_1=None, already_has_spe
447447
if token_ids_1 is not None:
448448
raise ValueError("You should not supply a second sequence if the provided sequence of "
449449
"ids is already formatted with special tokens for the model.")
450-
return list(map(lambda x: 1 if x in [self.sep_token_id, self.cls_token_id] else 0, token_ids_0))
450+
return [1 if x in [self.sep_token_id, self.cls_token_id] else 0 for x in token_ids_0]
451451

452452
if token_ids_1 is not None:
453453
return [1] + ([0] * len(token_ids_0)) + [1] + ([0] * len(token_ids_1)) + [1]

tools/accuracy_checker/openvino/tools/accuracy_checker/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def __getitem__(self, item):
469469

470470
@property
471471
def identifiers(self):
472-
return list(map(lambda ann: ann.identifier, self._data_buffer.values()))
472+
return [ann.identifier for ann in self._data_buffer.values()]
473473

474474
def __len__(self):
475475
return len(self._data_buffer)

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/dlsdk_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def _set_affinity_via_layers(self, custom_affinity, automatic_affinity):
295295
layers[layer_name].affinity = device
296296

297297
def _is_vpu(self):
298-
device_list = map(lambda device: device.split('.')[0], self._devices_list())
298+
device_list = (device.split('.')[0] for device in self._devices_list())
299299
return contains_any(device_list, VPU_PLUGINS)
300300

301301
@property
@@ -413,7 +413,7 @@ def _device_specific_configuration(self):
413413
if config:
414414
self.ie_core.set_config(config, 'GPU')
415415
if self._is_vpu():
416-
device_list = map(lambda device: device.split('.')[0], self._devices_list())
416+
device_list = (device.split('.')[0] for device in self._devices_list())
417417
devices = [vpu_device for vpu_device in VPU_PLUGINS if vpu_device in device_list]
418418
log_level = self.config.get('_vpu_log_level')
419419
if log_level:

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def validate_config(cls, config, delayed_model_loading=False, fetch_only=False,
216216
validation_scheme=cls.validation_scheme())
217217
)
218218
return errors
219-
uri = uri_prefix or'launcher.{}'.format(cls.__provider__)
219+
uri = uri_prefix or 'launcher.{}'.format(cls.__provider__)
220220
return LauncherConfigValidator(
221221
uri, fields=cls.parameters(), delayed_model_loading=delayed_model_loading
222222
).validate(

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/openvino_launcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def _set_affinity(self, affinity_map_path):
273273
node.rt_info["affinity"] = device
274274

275275
def _is_vpu(self):
276-
device_list = map(lambda device: device.split('.')[0], self._devices_list())
276+
device_list = (device.split('.')[0] for device in self._devices_list())
277277
return contains_any(device_list, VPU_PLUGINS)
278278

279279
@property
@@ -377,7 +377,7 @@ def _device_specific_configuration(self):
377377
if config:
378378
ov_set_config(self.ie_core, config, device='GPU')
379379
if self._is_vpu():
380-
device_list = map(lambda device: device.split('.')[0], self._devices_list())
380+
device_list = (device.split('.')[0] for device in self._devices_list())
381381
devices = [vpu_device for vpu_device in VPU_PLUGINS if vpu_device in device_list]
382382
log_level = self.config.get('_vpu_log_level')
383383
if log_level:
@@ -484,7 +484,7 @@ def _set_infer_precision_hint(self):
484484
if 'INFERENCE_PRECISION_HINT' not in supported_props:
485485
warning(f'inference precision hint is not supported for device {self._device}, option will be ingnored')
486486
return
487-
if not precision_hint.upper() in PRECISION_STR_TO_TYPE and not precision_hint in format_map:
487+
if precision_hint.upper() not in PRECISION_STR_TO_TYPE and precision_hint not in format_map:
488488
raise ConfigError(f'Unknown precision {precision_hint} for inference precision hint')
489489
precision_type = PRECISION_STR_TO_TYPE.get(precision_hint.upper(), precision_hint)
490490
self.ie_core.set_property(self._device, {'INFERENCE_PRECISION_HINT': precision_type})

0 commit comments

Comments
 (0)