Variables | |
| _ | |
| bbox = draw.textbbox((x1, y1), label, font=font) | |
| best_class_indices = np.argmax(confs, axis=1) | |
| dict | best_class_scores = confs[np.arange(N), best_class_indices] |
| dict | boxes = output_dict["boxes"] |
| list | class_names = [f"class_{i}" for i in range(num_classes)] |
| cls = best_class_indices[idx] | |
| dict | confs = output_dict["confs"] |
| list | detections = [] |
| draw = ImageDraw.Draw(img) | |
| fill | |
| font = ImageFont.load_default() | |
| H | |
| H_img | |
| img = Image.open(sys.argv[2]).convert('RGB') | |
| float | img_np = np.array(img_resized).astype("float32") / 255.0 |
| img_resized = img.resize((W, H)) | |
| input_name = session.get_inputs()[0].name | |
| input_shape = session.get_inputs()[0].shape | |
| int | k = 10 |
| key | |
| str | label = f"{class_names[cls]} {score:.2f}" |
| N | |
| num_classes | |
| outline | |
| dict | output_dict = {name: value for name, value in zip(output_names, outputs)} |
| list | output_names = [o.name for o in session.get_outputs()] |
| outputs = session.run(output_names, {input_name: img_np}) | |
| dict | score = best_class_scores[idx] |
| session = ort.InferenceSession(sys.argv[1], providers=["CPUExecutionProvider"]) | |
| list | text_bg = [text_x, text_y, text_x + text_w, text_y + text_h] |
| text_h = bbox[3] - bbox[1] | |
| text_w = bbox[2] - bbox[0] | |
| text_x = x1 | |
| text_y = max(0, y1 - text_h) | |
| float | threshold = 0.75 |
| topk_indices = np.argsort(-best_class_scores)[:k] | |
| W | |
| W_img | |
| width | |
| x1 | |
| x1_pix = x1 * W_img | |
| x2 | |
| x2_pix = x2 * W_img | |
| y1 | |
| y1_pix = y1 * H_img | |
| y2 | |
| y2_pix = y2 * H_img | |
|
protected |
| onnx_test_model.best_class_indices = np.argmax(confs, axis=1) |
| dict onnx_test_model.best_class_scores = confs[np.arange(N), best_class_indices] |
| dict onnx_test_model.boxes = output_dict["boxes"] |
| list onnx_test_model.class_names = [f"class_{i}" for i in range(num_classes)] |
| onnx_test_model.cls = best_class_indices[idx] |
| dict onnx_test_model.confs = output_dict["confs"] |
| list onnx_test_model.detections = [] |
| onnx_test_model.draw = ImageDraw.Draw(img) |
| onnx_test_model.fill |
| onnx_test_model.font = ImageFont.load_default() |
| onnx_test_model.H |
| onnx_test_model.H_img |
| onnx_test_model.img = Image.open(sys.argv[2]).convert('RGB') |
| onnx_test_model.img_np = np.array(img_resized).astype("float32") / 255.0 |
| onnx_test_model.input_name = session.get_inputs()[0].name |
| onnx_test_model.input_shape = session.get_inputs()[0].shape |
| int onnx_test_model.k = 10 |
| onnx_test_model.key |
| onnx_test_model.label = f"{class_names[cls]} {score:.2f}" |
| onnx_test_model.N |
| onnx_test_model.num_classes |
| onnx_test_model.outline |
| dict onnx_test_model.output_dict = {name: value for name, value in zip(output_names, outputs)} |
| list onnx_test_model.output_names = [o.name for o in session.get_outputs()] |
| onnx_test_model.outputs = session.run(output_names, {input_name: img_np}) |
| dict onnx_test_model.score = best_class_scores[idx] |
| onnx_test_model.session = ort.InferenceSession(sys.argv[1], providers=["CPUExecutionProvider"]) |
| onnx_test_model.text_x = x1 |
| float onnx_test_model.threshold = 0.75 |
| onnx_test_model.topk_indices = np.argsort(-best_class_scores)[:k] |
| onnx_test_model.W |
| onnx_test_model.W_img |
| onnx_test_model.width |
| onnx_test_model.x1 |
| onnx_test_model.x2 |
| onnx_test_model.y1 |
| onnx_test_model.y2 |