RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 58 but got size 57 fo

An error occurred: When using yolo v5n for network training, the input size used is 900*900. When connecting the Feature Map of the 11th layer and the 6th layer at the 12th layer Concat, there is a problem of different dimensions. After running, the following error message appears: RuntimeError: Sizes of tensors must match except […]

Solution to the “red” message when running tensorfow

Problem display When running tensor, a large amount of “red” information often appears, as shown below: import tensorflow as tf x = tf.constant(1) print(x) code display 2023-11-12 17:39:04.668566: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce MX250 computeCapability: 6.1 coreClock: 1.582GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 52.21GiB/s 2023-11-12 17:39:04.668943: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully […]

OpenMMlab exports the yolov3 model and uses onnxruntime and tensorrt for inference

Export onnx file Use script directly import torch from mmdet.apis import init_detector, inference_detector config_file = ‘./configs/yolo/yolov3_mobilenetv2_8xb24-ms-416-300e_coco.py’ checkpoint_file = ‘yolov3_mobilenetv2_mstrain-416_300e_coco_20210718_010823-f68a07b3.pth’ model = init_detector(config_file, checkpoint_file, device=’cpu’) # or device=’cuda:0′ torch.onnx.export(model, (torch.zeros(1, 3, 416, 416),), “yolov3.onnx”, opset_version=11) The exported onnx structure is as follows: The output is the output of three different levels of detection heads. If you […]

pytorch tensor operations

Table of Contents Creation and basic operations of tensor Initializing a Tensor–Creation method Attributes of a Tensor–Attributes of a tensor Operations on Tensors — Operations on Tensors Official Documentation Creation and basic operations of tensor Initializing a Tensor–creation method Directly from data — Create directly with data Create a tensor directly from data, and the […]

Deep Neural Networks – Convert a TensorFlow piecewise model and start using OpenCV v4.8.0

Goals In this tutorial you will learn how to Convert a TensorFlow (TF) segmentation model Run the converted TensorFlow model using OpenCV Evaluate TensorFlow and OpenCV DNN models We will discuss the above points using the DeepLab architecture as an example. Introduction Apart from the graph optimization stage, the key concepts involved in TensorFlow classification […]

[Distributed] tensorflow 1 distributed code practice and explanation; running 2 distributed worker threads on a single node

tensorflow.python.framework.errors_impl.UnknowError: Could not start gRPC server 1. tf distributed A computer = server = server is a node that contains multiple GPUs. First of all, the distributed method is to let the GPUs on multiple computers work together. Distributed work is divided into two parts, parameter server (ps) and worker. PS and worker look familiar, […]

Preprocessing of YOLOv5 classification model (2) ToTensor and Normalize

Preprocessing of YOLOv5 classification model (2) ToTensor and Normalize flyfish 1. The initial data is a floating point number import torch import numpy as np from torchvision import transforms mean = (0.485, 0.456, 0.406) std = (0.229, 0.224, 0.225) data0 = np.random.random((4, 5, 3)) # H x W x C data0 = np.round(data0,4) print(data0.shape) print(data0) […]

Algorithm Selection API usage example based off sampleMNIST in TensorRT

Algorithm Selection API usage example based off sampleMNIST in TensorRT Table Of Contents Description How does this sample work? – Setup the algorithm selectors Preparing sample data Running the sample – Sample –help options Additional resources License Changelog Known issues Description This sample, sampleAlgorithmSelector, shows an example of how to use the algorithm selection API […]

OpenMMlab exports the mobilenet-v2 model and uses onnxruntime and tensorrt for inference

Export onnx file Use mmpretrain to export the onnx model of mobilenet-v2: import torch from mmpretrain import get_model model = get_model(‘mobilenet-v2_8xb32_in1k’, pretrained=’mobilenet_v2_batch256_imagenet_20200708-3b2dc3af.pth’, device=’cpu’) input = torch.zeros(1, 3, 224, 224) out = model(input) torch.onnx.export(model, input, “mobilenet-v2.onnx”, opset_version=11) If mmdeploy is installed, you can export it as follows: from mmdeploy.apis import torch2onnx from mmdeploy.backend.sdk.export_info import export2SDK img […]

Shengteng Migration丨Interpretation of 4 TensorFlow model training cases

This article is shared from the Huawei Cloud Community “Common Cases of TensorFlow Model Training” by Shengteng CANN. Training scripts developed based on TensorFlow’s Python API run on the CPU/GPU/TPU by default. In order for these scripts to take advantage of the powerful computing power of the Ascend AI processor, they need to be migrated […]