From 70fa19f74502905237d8e7c4ae4e8e944fb4ec74 Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Mon, 10 Apr 2023 10:05:59 +0400 Subject: [PATCH] fix bandit scan issues (#999) --- .ci/convert_notebooks.py | 2 +- .ci/validate_notebooks.py | 2 +- check_install.py | 2 +- notebooks/405-paddle-ocr-webcam/pre_post_processing.py | 7 +++---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.ci/convert_notebooks.py b/.ci/convert_notebooks.py index ae1066e2494..35212989a3e 100644 --- a/.ci/convert_notebooks.py +++ b/.ci/convert_notebooks.py @@ -1,6 +1,6 @@ import argparse import shutil -import subprocess +import subprocess # nosec - disable B404:import-subprocess check import time from pathlib import Path diff --git a/.ci/validate_notebooks.py b/.ci/validate_notebooks.py index dfa28958294..e3bfd205660 100644 --- a/.ci/validate_notebooks.py +++ b/.ci/validate_notebooks.py @@ -1,6 +1,6 @@ import sys import os -import subprocess +import subprocess # nosec - disable B404:import-subprocess check import csv import shutil from pathlib import Path diff --git a/check_install.py b/check_install.py index f3aad4c77ec..1bf161afd16 100644 --- a/check_install.py +++ b/check_install.py @@ -1,5 +1,5 @@ import os -import subprocess +import subprocess # nosec - disable B404:import-subprocess check import sys from pathlib import Path from pprint import pprint diff --git a/notebooks/405-paddle-ocr-webcam/pre_post_processing.py b/notebooks/405-paddle-ocr-webcam/pre_post_processing.py index 74ad23dc61d..e17a9f14a2e 100644 --- a/notebooks/405-paddle-ocr-webcam/pre_post_processing.py +++ b/notebooks/405-paddle-ocr-webcam/pre_post_processing.py @@ -3,7 +3,6 @@ import numpy as np import paddle import math -import random from PIL import Image, ImageDraw, ImageFont import copy @@ -423,14 +422,14 @@ def draw_ocr_box_txt(image, img_left = image.copy() img_right = Image.new('RGB', (w, h), (255, 255, 255)) - random.seed(0) + np.random.seed(0) draw_left = ImageDraw.Draw(img_left) draw_right = ImageDraw.Draw(img_right) for idx, (box, txt) in enumerate(zip(boxes, txts)): if scores is not None and scores[idx] < drop_score: continue - color = (random.randint(0, 255), random.randint(0, 255), - random.randint(0, 255)) + color = (np.random.randint(0, 255), np.random.randint(0, 255), + np.random.randint(0, 255)) draw_left.polygon(box, fill=color) draw_right.polygon( [