Jetson 学习笔记(五):pb转uff---pb转onnx转trt----pth转onnx转pb

article/2025/8/16 6:55:44

文章目录

    • pb转uff具体代码
      • 运行结果
    • pb转onnx转trt具体代码
      • pb转onnx运行结果
      • onnx转化trt
        • 方法1:trtexec
        • 方法2:onnx-tensorrt工具
      • 推理trt模型
    • pth转onnx
    • onnx转pb
      • 方法1:onnx-tensorflow工具
      • 方法2:代码执行

pb转uff具体代码

这里用的是uff自带的一个转换器,直接通过调用这个包就可以完成转换,只需要自己定义输入和输出的路径,如果没有定义输出的路径那么它就会自己以输入路径当作输出路径。

python3 /usr/lib/python3.6/dist-packages/uff/bin/convert_to_uff.py --input_file models/yolov4-tiny.pb
#则会在models文件夹中生成yolov4-tiny.uff文件

运行结果

1211

pb转onnx转trt具体代码

install onnx

pip install numpy
pip install protobuf
sudo apt-get install protobuf-compiler libprotoc-dev
pip install onnx

首先完成pb转onnx,转换情况如下:
这里用的是tf2onnx官方自带的包,github下载链接为:
https://codechina.csdn.net/mirrors/onnx/tensorflow-onnx?utm_source=csdn_github_accelerator
直接通过调用这个包就可以完成转换,只需要自己定义一些参数,情况如下


python3 -m tf2onnx.convert\--input /home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny.pb\--inputs inputs:0\--outputs Reshape:0,Reshape_4:0\--output /home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny.onnx\--verbose

也就是pb输入路径,输入节点和输出节点(必须以A:B形式),然后输出路径,最后一个是verbose参数。

如果报错

  • ValueError: StridedSlice: only strides=1 is supported
    解决方法:加上–opset 10

  • OSError: SavedModel file does not exist at:checkpoints//{saved_model.pbtxt|saved_model.pb}
    原因:–saved-model参数路径不对,应该定位到yolov4-tiny目录
    解决:–saved-model参数后必须是存放.pb模型的目录,而不是直接是.pb文件

onnx前向推理

import numpy as np
import onnx
import onnxruntime as rtdef Yolov4_onnx(onnx_path):# create runtime sessionsess = rt.InferenceSession(onnx_path)# get output nameinput_name = sess.get_inputs()[0].nameoutput_name = sess.get_outputs()[0].nameoutput_name1 = sess.get_outputs()[1].nameoutput_shape = sess.get_outputs()[0].shape# forward modelouts1, outs2 = sess.run([output_name,output_name1], {input_name: input_data})return outs1,outs2# create input data
input_data = np.random.random((1,416,416,3)).astype('float32')
onnx_path='/home/lqs/Documents/feature_match/tools/yolov_4-tiny.onnx'

pb转onnx运行结果

在这里插入图片描述

在这里插入图片描述

onnx转化trt

方法1:trtexec

使用TensorRT的OSS工具
我的其中trtexec工具在/usr/src/tensorrt/bin/trtexec
–verbose,verbose打印日志看着能安心点

# fp32---noTF32 fp16---fp16 int8---int8
# set enviornment export PATH="$PATH:/usr/src/tensorrt/bin" sudo /usr/src/tensorrt/bin/trtexec
trtexec --explicitBatch=1 --onnx=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.onnx --saveEngine=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny-fp16.trt --fp16 --workspace=1 --verbosetrtexec --explicitBatch=1 --onnx=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.onnx --saveEngine=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny-fp32.trt --noTF32 --workspace=1 --verbosetrtexec --explicitBatch=1 --onnx=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.onnx --saveEngine=/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny-int8.trt --int8 --workspace=1 --verbose

方法2:onnx-tensorrt工具

GITHUB

$ git clone --recursive https://github.com/onnx/onnx-tensorrt.git
$ mkdir build
$ cd build
$ cmake .. -DTENSORRT_ROOT=/home/wt/download/TensorRT-5.1.5.0
or 
# 根据GPU的实际计算能力,修改 DGPU_ARCHS 值
$ cmake .. -DTENSORRT_ROOT=/home/wt/download/TensorRT-5.1.5.0 -DGPU_ARCHS="61"
$ make -j8
$ sudo make install
通过 ONNX-TensorRT 工具,可以将 onnx 模型转换为 tensorrt 模型,如
onnx2trt my_model.onnx -o my_engine.trt
还可以将 onnx 模型转换为人们可读的txt文档
onnx2trt my_model.onnx -t my_model.onnx.txt
更多用法,输入
onnx2trt -h

方法3:使用以下代码(结合着改)
3.1

#!/usr/bin/env python3import tensorrt as trtimport sys, os
sys.path.insert(1, os.path.join(sys.path[0], ".."))TRT_LOGGER = trt.Logger()
EXPLICIT_BATCH = 1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)#batchsize=1
def get_engine(onnx_file_path, engine_file_path):"""Attempts to load a serialized engine if available, otherwise builds a new TensorRT engine and saves it."""def build_engine():"""Takes an ONNX file and creates a TensorRT engine to run inference with"""with trt.Builder(TRT_LOGGER) as builder, builder.create_network(EXPLICIT_BATCH) as network, builder.create_builder_config() as config, trt.OnnxParser(network, TRT_LOGGER) as parser:builder.max_batch_size = 1config.max_workspace_size = 1 << 30 # 30:1GB;28:256MiB configbuilder.fp16_mode=True# Parse model fileif not os.path.exists(onnx_file_path):print('ONNX file {} not found, please run yolov3_to_onnx.py first to generate it.'.format(onnx_file_path))exit(0)print('Loading ONNX file from path {}...'.format(onnx_file_path))with open(onnx_file_path, 'rb') as model:print('Beginning ONNX file parsing')parser.parse(model.read())if not parser.parse(model.read()):print ('ERROR: Failed to parse the ONNX file.')for error in range(parser.num_errors):print (parser.get_error(error))return None# The actual yolov3.onnx is generated with batch size 64. Reshape input to batch size 1print('Completed parsing of ONNX file')print('Building an engine from file {}; this may take a while...'.format(onnx_file_path))engine = builder.build_engine(network,config)print("Completed creating Engine")with open(engine_file_path, "wb") as f:f.write(bytearray(engine.serialize()))return engineif os.path.exists(engine_file_path):# If a serialized engine exists, use it instead of building an engine.print("Reading engine from file {}".format(engine_file_path))with open(engine_file_path, "rb") as f, trt.Runtime(TRT_LOGGER) as runtime:return runtime.deserialize_cuda_engine(f.read())else:return build_engine()def get_engine1(engine_path):# If a serialized engine exists, use it instead of building an engine.print("Reading engine from file {}".format(engine_path))with open(engine_path, "rb") as f, trt.Runtime(TRT_LOGGER) as runtime:return runtime.deserialize_cuda_engine(f.read())if __name__ == '__main__':#main()onnx_file_path = '/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.onnx'engine_file_path = "/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.trt"get_engine(onnx_file_path, engine_file_path)# 可用netron查看onnx的输出数量和尺寸engines=get_engine1(engine_file_path)for binding in engines:size = trt.volume(engines.get_binding_shape(binding)) * 1dims = engines.get_binding_shape(binding)print('size=',size)print('dims=',dims)print('binding=',binding)print("input =", engines.binding_is_input(binding))dtype = trt.nptype(engines.get_binding_dtype(binding))

3.2

#!/usr/bin/env python3import tensorrt as trtimport sys, os
sys.path.insert(1, os.path.join(sys.path[0], ".."))TRT_LOGGER = trt.Logger()
EXPLICIT_BATCH = 1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)#batchsize=1
def get_engine(onnx_file_path, engine_file_path):"""Attempts to load a serialized engine if available, otherwise builds a new TensorRT engine and saves it."""def build_engine(mode='int8',calib=None):"""Takes an ONNX file and creates a TensorRT engine to run inference with"""with trt.Builder(TRT_LOGGER) as builder, builder.create_network(EXPLICIT_BATCH) as network, builder.create_builder_config() as config, trt.OnnxParser(network, TRT_LOGGER) as parser:builder.max_batch_size = 1config.max_workspace_size = 1 << 30 # 30:1GB;28:256MiB configif mode=='int8':print('the type is int8')builder.int8_mode=Truebuilder.int8_calibrator=calibelif mode=='fp16':print('the type is fp16')builder.fp16_mode=True# Parse model fileif not os.path.exists(onnx_file_path):print('ONNX file {} not found, please run yolov3_to_onnx.py first to generate it.'.format(onnx_file_path))exit(0)print('Loading ONNX file from path {}...'.format(onnx_file_path))with open(onnx_file_path, 'rb') as model:print('Beginning ONNX file parsing')parser.parse(model.read())if not parser.parse(model.read()):print ('ERROR: Failed to parse the ONNX file.')for error in range(parser.num_errors):print (parser.get_error(error))return None# The actual yolov3.onnx is generated with batch size 64. Reshape input to batch size 1print('Completed parsing of ONNX file')print('Building an engine from file {}; this may take a while...'.format(onnx_file_path))engine = builder.build_engine(network,config)print("Completed creating Engine")with open(engine_file_path, "wb") as f:f.write(bytearray(engine.serialize()))return engineif os.path.exists(engine_file_path):# If a serialized engine exists, use it instead of building an engine.print("Reading engine from file {}".format(engine_file_path))with open(engine_file_path, "rb") as f, trt.Runtime(TRT_LOGGER) as runtime:return runtime.deserialize_cuda_engine(f.read())else:return build_engine()def get_engine1(engine_path):# If a serialized engine exists, use it instead of building an engine.print("Reading engine from file {}".format(engine_path))with open(engine_path, "rb") as f, trt.Runtime(TRT_LOGGER) as runtime:return runtime.deserialize_cuda_engine(f.read())if __name__ == '__main__':#main()onnx_file_path = '/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.onnx'engine_file_path = "/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny-int8.trt"get_engine(onnx_file_path, engine_file_path)# 可用netron查看onnx的输出数量和尺寸engines=get_engine1(engine_file_path)for binding in engines:size = trt.volume(engines.get_binding_shape(binding)) * 1dims = engines.get_binding_shape(binding)print('size=',size)print('dims=',dims)print('binding=',binding)print("input =", engines.binding_is_input(binding))dtype = trt.nptype(engines.get_binding_dtype(binding))print("dtype =", dtype)

3.3
[TensorRT] ERROR: Network must have at least one output
[TensorRT] ERROR: Network validation failed.
在with open(onnx_file_path, ‘rb’) as model:之后加两行:

last_layer = network.get_layer(network.num_layers - 1)
network.mark_output(last_layer.get_output(0))
import os
import tensorrt as trt
max_batch_size = 1
explicit_batch = 1
TRT_LOGGER = trt.Logger()
def get_engine(max_batch_size=1, onnx_file_path="", engine_file_path="", save_engine=False):with trt.Builder(TRT_LOGGER) as builder, \builder.create_network(explicit_batch) as network, \trt.OnnxParser(network, TRT_LOGGER) as parser:  # 使用onnx的解析器绑定计算图,后续将通过解析填充计算图builder.max_workspace_size = 1 << 30  # 预先分配的工作空间大小,即ICudaEngine执行时GPU最大需要的空间builder.max_batch_size = max_batch_size  # 执行时最大可以使用的batchsizebuilder.fp16_mode = True#  使用logger创建一个builder#  builder创建一个计算图 INetworkDefinition# 解析onnx文件,填充计算图if not os.path.exists(onnx_file_path):quit("ONNX file {} not found!".format(onnx_file_path))print('loading onnx file from path {} ...'.format(onnx_file_path))with open(onnx_file_path, 'rb') as model:  # 二值化的网络结果和参数print("Begining onnx file parsing")parser.parse(model.read())  # 解析onnx文件# parser.parse_from_file(onnx_file_path) # parser还有一个从文件解析onnx的方法print("Completed parsing of onnx file")# 填充计算图完成后,则使用builder从计算图中创建CudaEngineprint("Building an engine from file{}' this may take a while...".format(onnx_file_path))#################print(network.get_layer(network.num_layers - 1).get_output(0).shape)# network.mark_output(network.get_layer(network.num_layers -1).get_output(0))last_layer = network.get_layer(network.num_layers - 1)network.mark_output(last_layer.get_output(0))engine = builder.build_cuda_engine(network)  # 注意,这里的network是INetworkDefinition类型,即填充后的计算图print("Completed creating Engine")if save_engine:  # 保存engine供以后直接反序列化使用with open(engine_file_path, 'wb') as f:f.write(engine.serialize())  # 序列化return engine
  • 如果运行出错
    [TensorRT] ERROR: Network must have at least one output 解决:在parser.parse下with循环外添加两行代码
    last_layer = network.get_layer(network.num_layers - 1)
    network.mark_output(last_layer.get_output(0))

推理trt模型

我通过trtexec工具完成的转换并通过下面这篇博客检查trt模型是否转换成功,查看输出https://blog.csdn.net/m0_51004308/article/details/115407130?spm=1001.2014.3001.5501
结果如下
在这里插入图片描述

运行成功之后可以按照下面的代码进行推理:

import pycuda.driver as cuda
import pycuda.autoinit
import cv2,time
import numpy as np
import os
import tensorrt as trtTRT_LOGGER = trt.Logger()
engine_file_path = "/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/yolov4-tiny.trt"class HostDeviceMem(object):def __init__(self, host_mem, device_mem):self.host = host_memself.device = device_memdef __str__(self):return "Host:\n" + str(self.host) + "\nDevice:\n" + str(self.device)def __repr__(self):return self.__str__()
# Allocates all buffers required for an engine, i.e. host/device inputs/outputs. 分配引擎所需的所有缓冲区
def allocate_buffers(engine):inputs = []outputs = []bindings = []stream = cuda.Stream()for binding in engine:size = trt.volume(engine.get_binding_shape(binding)) * engine.max_batch_sizedtype = trt.nptype(engine.get_binding_dtype(binding))# Allocate host and device buffershost_mem = cuda.pagelocked_empty(size, dtype)device_mem = cuda.mem_alloc(host_mem.nbytes)# Append the device buffer to device bindings.bindings.append(int(device_mem))# Append to the appropriate list.if engine.binding_is_input(binding):inputs.append(HostDeviceMem(host_mem, device_mem))else:outputs.append(HostDeviceMem(host_mem, device_mem))return inputs, outputs, bindings, streamdef do_inference_v2(context, bindings, inputs, outputs, stream):# Transfer input data to the GPU.[cuda.memcpy_htod_async(inp.device, inp.host, stream) for inp in inputs]# Run inference.context.execute_async_v2(bindings=bindings, stream_handle=stream.handle)# Transfer predictions back from the GPU.[cuda.memcpy_dtoh_async(out.host, out.device, stream) for out in outputs]# Synchronize the streamstream.synchronize()# Return only the host outputs.return [out.host for out in outputs]with open(engine_file_path, "rb") as f, trt.Runtime(TRT_LOGGER) as runtime,\
runtime.deserialize_cuda_engine(f.read()) as engine, engine.create_execution_context() as context:inputs, outputs, bindings, stream = allocate_buffers(engine)#print('Len of inputs:',len(inputs))#print('Len of outputs:',len(outputs))image = cv2.imread('4.jpg',cv2.IMREAD_GRAYSCALE)image=cv2.resize(image,(28,28))print(image.shape)image=image[np.newaxis,np.newaxis,:,:].astype(np.float32)inputs[0].host = imageprint('开始推理')start = time.time()trt_outputs =do_inference_v2(context, bindings=bindings, \inputs=inputs, outputs=outputs, stream=stream)finish = time.time()#print('inference time {} sec'.format(finish - start))print(trt_outputs)

结果如下:
在这里插入图片描述
如果要直接调用两个trt模型推理也是一样的道理,直接看代码。


import pycuda.driver as cuda
import pycuda.autoinit
import cv2, time
import numpy as np
import os
import pickle
import tensorrt as trtclass HostDeviceMem(object):def __init__(self, host_mem, device_mem):self.host = host_memself.device = device_memdef __str__(self):return "Host:\n" + str(self.host) + "\nDevice:\n" + str(self.device)def __repr__(self):return self.__str__()# Allocates all buffers required for an engine, i.e. host/device inputs/outputs. 分配引擎所需的所有缓冲区
def allocate_buffers(engine):inputs = []outputs = []bindings = []stream = cuda.Stream()for binding in engine:size = trt.volume(engine.get_binding_shape(binding)) * engine.max_batch_sizedtype = trt.nptype(engine.get_binding_dtype(binding))# Allocate host and device buffershost_mem = cuda.pagelocked_empty(size, dtype)device_mem = cuda.mem_alloc(host_mem.nbytes)# Append the device buffer to device bindings.bindings.append(int(device_mem))# Append to the appropriate list.if engine.binding_is_input(binding):inputs.append(HostDeviceMem(host_mem, device_mem))else:outputs.append(HostDeviceMem(host_mem, device_mem))return inputs, outputs, bindings, streamdef do_inference_v2(context, bindings, inputs, outputs, stream):# Transfer input data to the GPU.[cuda.memcpy_htod_async(inp.device, inp.host, stream) for inp in inputs]# Run inference.context.execute_async_v2(bindings=bindings, stream_handle=stream.handle)# Transfer predictions back from the GPU.[cuda.memcpy_dtoh_async(out.host, out.device, stream) for out in outputs]# Synchronize the streamstream.synchronize()# Return only the host outputs.return [out.host for out in outputs]if __name__ == "__main__":TRT_LOGGER = trt.Logger()arc_engine_file_path = "/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/arcface/resnet18_110.trt"yolo_engine_file_path = "/home/z/Documents/face_detect_yolov4_yolov4tiny_ssd-master/tools/yolov4-tiny.trt"with open(yolo_engine_file_path, "rb") as f, open(arc_engine_file_path, "rb") as y, trt.Runtime(TRT_LOGGER) as runtime, \runtime.deserialize_cuda_engine(f.read()) as engine, engine.create_execution_context() as context, runtime.deserialize_cuda_engine(y.read()) as engine1, engine1.create_execution_context() as context1:inputs, outputs, bindings, stream = allocate_buffers(engine)inputs1, outputs1, bindings1, stream1 = allocate_buffers(engine1)

pth转onnx

pth是pytorch结合网络架构生成的模型文件。主要是需要找到model加载部分的代码,然后在结合下面的代码进行修改即可。还需要找到输入尺寸的值,也就是input的值。

import torch
import torch.onnx
import numpy as np
import os
from nets.yolo4_tiny import YoloBodydef pth_to_onnx(checkpoint, onnx_path, input_names=['input'], output_names=['output'], device='cpu'):if not onnx_path.endswith('.onnx'):print('Warning! The onnx model name is not correct,\please give a name that ends with \'.onnx\'!')return 0#加载模型model = YoloBody(3, 16).eval()model.load_state_dict(torch.load(checkpoint))#将模型切换到推理状态model.eval()# model.to(device)#创建输入张量input = torch.randn(1, 3, 416, 416)#转化onnx模型torch.onnx.export(model, input, onnx_path, verbose=True, input_names=input_names, output_names=output_names)print("Exporting .pth model to onnx model has been successful!")if __name__ == '__main__':os.environ['CUDA_VISIBLE_DEVICES'] = '0'checkpoint = 'D:/pycharm/tinyyolov4/model_data/yolo4_tiny_weights_100epoch.pth'onnx_path = 'D:/pycharm/tinyyolov4/model_data/yolo4_tiny_weights_100epoch.onnx'  # device = torch.device("cuda:2" if torch.cuda.is_available() else 'cpu')pth_to_onnx(checkpoint, onnx_path)

onnx转pb

方法1:onnx-tensorflow工具

  • 注意安装时onnx-tensorflow与tensorflow的版本对应关系
    在这里插入图片描述
  • 如果你是tensorflow1.15的版本就直接安装(下载github):https://github.com/onnx/onnx-tensorflow/tree/rel-1.5.0
  • 下载代码,解压后进入onnx-tensorflow目录,然后执行python3 setup.py -e ./ 就可以了

转换方式如下

onnx-tf convert -i input_onnx_path -o output_pb_path
  • 遇到问题 TypeErro: pad() got multiple values for argument 'name’参考下面博客https://github.com/onnx/onnx-tensorflow/issues/673修改onnx_tf/handlers/backend_hander.py文件

在这里插入图片描述

方法2:代码执行

import onnx
from onnx_tf.backend import preparedef onnx2pb(onnx_input_path, pb_output_path):onnx_model = onnx.load(onnx_input_path)tf_exp = prepare(onnx_model)tf_exp.export_graph(pb_output_path)if __name__ == "__main__":onnx_input_path = './culane_resnet50.onnx'pb_output_path = './culane_resnet50.pb'onnx2pb(onnx_input_path, pb_output_path)

http://chatgpt.dhexx.cn/article/TxJQSOHj.shtml

相关文章

Tensorflow pb模型转uff模型方法及遇到KeyError20和expected Const问题解决

项目所需要将Tensorflow 生成的pb模型转为uff模型&#xff0c;方法很简单&#xff0c;但是遇到的问题着实很多&#xff0c;这里主要记录下问题及解决方法&#xff0c;总之&#xff0c;最后是成功生成uff格式的模型的&#xff0c;有需要的可以参考。 pb模型转为uff模型的方法及步…

安装TensorRT,然后导入uff库包的时候报错:ImportError: ERROR: Failed to import module(cannot import name ‘GraphDef`)

欢迎大家关注笔者&#xff0c;你的关注是我持续更博的最大动力 原创文章&#xff0c;转载告知&#xff0c;盗版必究 安装TensorRT&#xff0c;然后导入uff库包的时候报错&#xff1a;ImportError: ERROR: Failed to import module&#xff08;cannot import name GraphDef from…

pb模型转uff模型(tensorflow2.x)

大多数的博客只是提到tensorflow1.x系列下的转换。大概步骤就是安装tensorrt&#xff0c;同时安装tensorrt下的几个python的wl文件。可参见博主之前的博客: 1.tensorrt的安装Ubuntu配置TensorRT及验证_竹叶青lvye的博客-CSDN博客 2.tensorrt下几个whl文件的安装TensorRT加速方…

Sony索尼HLG灰片电影调色LUT预设合集 HLG CINEMATIC LUTPACK BUNDLE

Sony索尼HLG灰片电影调色LUT预设合集 HLG CINEMATIC LUTPACK BUNDLE 原文地址&#xff1a;https://www.aeziyuan.com/t-20546.html 包括用于Sony索尼LOG相机的39组LUT预设。是目前为止Sony索尼相机最好的预设之一。 它适用于支持LUT预设效果的大多数软件。例如Premiere Pro&…

两种HDR格式(HLG, HDR10)的理解

1、HLG只在sps的vui中会携带信息&#xff0c;包括colour_primaries(9)&#xff0c;transfer_characteristics(18)&#xff0c;matrix_coefficients(9) 2、HDR10除了SPS的VUI中携带的信息&#xff0c;在key frame会携带相应的SEI&#xff08;mastering display、content light l…

详解HDR的三个标准——HLG/HDR10/Dolby Vision

HDR的三大标准&#xff1a;HLG&#xff08;Hybrid Log Gamma&#xff09;&#xff1b;HDR10&#xff1b;Dolby Vision HLG&#xff1a;HLG的全称是Hybrid Log Gamma&#xff0c;它是由英国BBC和日本NHK电视台联合开发的高动态范围HDR的一个标准。HLG不需要元数据&#xff0c;能…

HLG移动

在平面坐标系内&#xff0c;有两个坐标轴x轴和y轴。&#xff08;x,y&#xff09;表示点的坐标。 有一点处于&#xff08;x1,y1&#xff09;位置上&#xff0c;他可以向相临8个位置移动&#xff08;移动方式见下图&#xff09;。 划定范围&#xff1a;此点只可以在[0<x<3…

HLG 2025

确定大小 Time Limit: 1000 MSMemory Limit: 32768 K Total Submit: 50(15 users)Total Accepted: 12(11 users)Rating: Special Judge: NoDescription现在有N个字母&#xff0c;&#xff08;N < 26&#xff09;&#xff0c;我们称之为A、B、C、D......。这次他们之间想确定…

SDR屏幕放HDR(HLG)视频画面泛灰

假设场景线性光E&#xff08;RGB&#xff09;1. SDR&#xff1a;数据位宽为10bit。灰度值2^10 * E1023; HDR&#xff1a;HDR根据OETF&#xff08;光电转换&#xff09;将相对场景线性光映射到非线性信号值 E 0.5&#xff1b; 灰度值2^10*0.5512&#xff1b; 所以本来需要显…

HDR相关标准-HLG/HDR10/HDR10+/DOLBY VISION

目录 主要参考信息 动态元数据及使用 相关标准文件 主要参考信息 杜比视界HDR参数_qq26983255的博客-CSDN博客_pq和hlghttps://blog.csdn.net/qq26983255/article/details/119830337?spm1001.2014.3001.5502 HDR到底是什么&#xff1f;_相见不如怀念-CSDN博客一&#xf…

PQ和HLG标准及其转换

目录 PQ标准的电光转换函数PQ_EOTF PQ标准的光电转换函数PQ_OETF HLG标准的电光转换函数HLG_EOTF HLG标准的光电转换函数 HLG_OETF HLG标准转PQ标准HLG2PQ PQ标准转HLG标准PQ2HLG PQ标准的电光转换函数PQ_EOTF PQ标准的光电转换函数PQ_OETF HLG标准的电光转换函数HLG_EOTF…

OpenGLSL中处理HDR.ToneMapping(HLG)

紧跟前提文章&#xff0c;没有HDR.ToneMapping知识基础的同学请先阅读之前的文章&#xff1a; HDR in Android 专栏 这篇文章主要是介绍在GLSL中处理HLG&#xff08;hybrid-log-gamma 混合对数伽马曲线&#xff09;的HDR tonemap SDR的渲染流程。 先看看Wiki有关HLG的概述&am…

HDR中HLG与PQ曲线的互转

HDR视频中由于电光转换曲线的不同&#xff0c;技术标准也大致分为了杜比视界、HDR10、HDR10、HLG等&#xff0c;目前常用的主要是以PQ曲线的HDR10和HLG。这两者之间的区别在HDR视频编码参数中进行过详细的说明。一般的HLG适用于广电&#xff08;根据用户设备的峰值亮度动态的调…

使用DataList吧

这是个具有明显煽动性的标题&#xff0c;没错&#xff0c;在这里就是提议大家使用DataList。在MSDN中文站有一篇关于repeater&#xff0c;datalist和datagrid的性能测试的文章&#xff0c;我也把这篇文章转到了我的站的“转载嘿嘿 希望你接受我的教训 一定早做打算 精华”里&am…

html5-datalist标签-定义选项列表

datalist使用 datalist使用需与input关联起来&#xff0c;input定义list属性&#xff0c;同时datalist定义id属性&#xff0c;两者的值必须相同。 实例代码 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><m…

常用数据集合—List

1、List、Map、Set、Queue、Array 2、数据结构&#xff1a;数组、链表 3、实现List方法的类Ctrl T&#xff08;设置的是Eclipse快捷键&#xff09;或右键查找 4、这里就简单看下最常用的ArrayList 5、构造方法一目了然 6、添加数据&#xff0c;一条条添加或者添加集合 良好…

DataList的数据绑定

8.4.1 DataList的数据绑定 DataList控件中通过自定义模板来设置数据的显示样式&#xff0c;它支持如下模板类型&#xff1a; ItemTemplate&#xff1a;包含一些 HTML元素和控件&#xff0c;将为数据源中的每一行呈现一次这些HTML元素和控件。 AlternatingItemTemplate&#xf…

datalist标签

学习笔记&#xff0c;仅供参考&#xff0c;有错必纠 参考自&#xff1a;w3school 关于datalist标签 <datalist> 标签定义选项列表&#xff0c;应该与 <input>标签配合使用该&#xff0c;它定义 input 可能的值&#xff1b; <datalist> 及其选项不会被显示出…

datalist 元素

效果图&#xff1a; 代码如下&#xff1a; <!DOCTYPE html> <html> <head><meta charset"UTF-8"><title>datalist 元素</title> </head> <body><form action"#" method"post">请输入用户…