提交 96bf6b1f 编写于 作者: 绝不原创的飞龙's avatar 绝不原创的飞龙

2024-02-05 19:02:08

上级 c1f91be3
此差异已折叠。
- en: TVTensors - en: TVTensors
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: TVTensors
- en: 原文:[https://pytorch.org/vision/stable/tv_tensors.html](https://pytorch.org/vision/stable/tv_tensors.html) - en: 原文:[https://pytorch.org/vision/stable/tv_tensors.html](https://pytorch.org/vision/stable/tv_tensors.html)
id: totrans-1
prefs: prefs:
- PREF_BQ - PREF_BQ
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/vision/stable/tv_tensors.html](https://pytorch.org/vision/stable/tv_tensors.html)
- en: TVTensors are [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor - en: TVTensors are [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") subclasses which the v2 [transforms](transforms.html#transforms) "(in PyTorch v2.2)") subclasses which the v2 [transforms](transforms.html#transforms)
use under the hood to dispatch their inputs to the appropriate lower-level kernels. use under the hood to dispatch their inputs to the appropriate lower-level kernels.
Most users do not need to manipulate TVTensors directly. Most users do not need to manipulate TVTensors directly.
id: totrans-2
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: TVTensors是[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)")的子类,v2 [transforms](transforms.html#transforms)在内部使用它们来将输入分派到适当的底层内核。大多数用户不需要直接操作TVTensors。
- en: Refer to [Getting started with transforms v2](auto_examples/transforms/plot_transforms_getting_started.html#sphx-glr-auto-examples-transforms-plot-transforms-getting-started-py) - en: Refer to [Getting started with transforms v2](auto_examples/transforms/plot_transforms_getting_started.html#sphx-glr-auto-examples-transforms-plot-transforms-getting-started-py)
for an introduction to TVTensors, or [TVTensors FAQ](auto_examples/transforms/plot_tv_tensors.html#sphx-glr-auto-examples-transforms-plot-tv-tensors-py) for an introduction to TVTensors, or [TVTensors FAQ](auto_examples/transforms/plot_tv_tensors.html#sphx-glr-auto-examples-transforms-plot-tv-tensors-py)
for more advanced info. for more advanced info.
id: totrans-3
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 有关TVTensors的介绍,请参阅[开始使用transforms v2](auto_examples/transforms/plot_transforms_getting_started.html#sphx-glr-auto-examples-transforms-plot-transforms-getting-started-py),或者查看[TVTensors
FAQ](auto_examples/transforms/plot_tv_tensors.html#sphx-glr-auto-examples-transforms-plot-tv-tensors-py)以获取更多高级信息。
- en: '| [`Image`](generated/torchvision.tv_tensors.Image.html#torchvision.tv_tensors.Image - en: '| [`Image`](generated/torchvision.tv_tensors.Image.html#torchvision.tv_tensors.Image
"torchvision.tv_tensors.Image")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "torchvision.tv_tensors.Image")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") subclass for images. |' "(in PyTorch v2.2)") subclass for images. |'
id: totrans-4
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`Image`](generated/torchvision.tv_tensors.Image.html#torchvision.tv_tensors.Image
"torchvision.tv_tensors.Image")(data, *[, dtype, device, requires_grad]) | 用于图像的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)")子类。 |'
- en: '| [`Video`](generated/torchvision.tv_tensors.Video.html#torchvision.tv_tensors.Video - en: '| [`Video`](generated/torchvision.tv_tensors.Video.html#torchvision.tv_tensors.Video
"torchvision.tv_tensors.Video")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "torchvision.tv_tensors.Video")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") subclass for videos. |' "(in PyTorch v2.2)") subclass for videos. |'
id: totrans-5
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`Video`](generated/torchvision.tv_tensors.Video.html#torchvision.tv_tensors.Video
"torchvision.tv_tensors.Video")(data, *[, dtype, device, requires_grad]) | 用于视频的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)")子类。 |'
- en: '| [`BoundingBoxFormat`](generated/torchvision.tv_tensors.BoundingBoxFormat.html#torchvision.tv_tensors.BoundingBoxFormat - en: '| [`BoundingBoxFormat`](generated/torchvision.tv_tensors.BoundingBoxFormat.html#torchvision.tv_tensors.BoundingBoxFormat
"torchvision.tv_tensors.BoundingBoxFormat")(value) | Coordinate format of a bounding "torchvision.tv_tensors.BoundingBoxFormat")(value) | Coordinate format of a bounding
box. |' box. |'
id: totrans-6
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`BoundingBoxFormat`](generated/torchvision.tv_tensors.BoundingBoxFormat.html#torchvision.tv_tensors.BoundingBoxFormat
"torchvision.tv_tensors.BoundingBoxFormat")(value) | 边界框的坐标格式。 |'
- en: '| [`BoundingBoxes`](generated/torchvision.tv_tensors.BoundingBoxes.html#torchvision.tv_tensors.BoundingBoxes - en: '| [`BoundingBoxes`](generated/torchvision.tv_tensors.BoundingBoxes.html#torchvision.tv_tensors.BoundingBoxes
"torchvision.tv_tensors.BoundingBoxes")(data, *, format, canvas_size) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "torchvision.tv_tensors.BoundingBoxes")(data, *, format, canvas_size) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") subclass for bounding boxes. |' "(in PyTorch v2.2)") subclass for bounding boxes. |'
id: totrans-7
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`BoundingBoxes`](generated/torchvision.tv_tensors.BoundingBoxes.html#torchvision.tv_tensors.BoundingBoxes
"torchvision.tv_tensors.BoundingBoxes")(data, *, format, canvas_size) | 用于边界框的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)")子类。 |'
- en: '| [`Mask`](generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask - en: '| [`Mask`](generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask
"torchvision.tv_tensors.Mask")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "torchvision.tv_tensors.Mask")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") subclass for segmentation and detection masks. |' "(in PyTorch v2.2)") subclass for segmentation and detection masks. |'
id: totrans-8
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`Mask`](generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask
"torchvision.tv_tensors.Mask")(data, *[, dtype, device, requires_grad]) | 用于分割和检测掩码的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)")子类。 |'
- en: '| [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor - en: '| [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor") | Base class for all TVTensors. |' "torchvision.tv_tensors.TVTensor") | Base class for all TVTensors. |'
id: totrans-9
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor") | 所有TVTensors的基类。 |'
- en: '| [`set_return_type`](generated/torchvision.tv_tensors.set_return_type.html#torchvision.tv_tensors.set_return_type - en: '| [`set_return_type`](generated/torchvision.tv_tensors.set_return_type.html#torchvision.tv_tensors.set_return_type
"torchvision.tv_tensors.set_return_type")(return_type) | Set the return type of "torchvision.tv_tensors.set_return_type")(return_type) | Set the return type of
torch operations on [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor torch operations on [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor"). |' "torchvision.tv_tensors.TVTensor"). |'
id: totrans-10
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`set_return_type`](generated/torchvision.tv_tensors.set_return_type.html#torchvision.tv_tensors.set_return_type
"torchvision.tv_tensors.set_return_type")(return_type) | 设置[`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor")上torch操作的返回类型。 |'
- en: '| [`wrap`](generated/torchvision.tv_tensors.wrap.html#torchvision.tv_tensors.wrap - en: '| [`wrap`](generated/torchvision.tv_tensors.wrap.html#torchvision.tv_tensors.wrap
"torchvision.tv_tensors.wrap")(wrappee, *, like, **kwargs) | Convert a [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "torchvision.tv_tensors.wrap")(wrappee, *, like, **kwargs) | Convert a [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(in PyTorch v2.2)") (`wrappee`) into the same [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "(in PyTorch v2.2)") (`wrappee`) into the same [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor") subclass as `like`. |' "torchvision.tv_tensors.TVTensor") subclass as `like`. |'
id: totrans-11
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`wrap`](generated/torchvision.tv_tensors.wrap.html#torchvision.tv_tensors.wrap
"torchvision.tv_tensors.wrap")(wrappee, *, like, **kwargs) | 将[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor
"(在PyTorch v2.2中)") (`wrappee`)转换为与`like`相同的[`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor
"torchvision.tv_tensors.TVTensor")子类。 |'
此差异已折叠。
此差异已折叠。
- en: Utils - en: Utils
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: Utils
- en: 原文:[https://pytorch.org/vision/stable/utils.html](https://pytorch.org/vision/stable/utils.html) - en: 原文:[https://pytorch.org/vision/stable/utils.html](https://pytorch.org/vision/stable/utils.html)
id: totrans-1
prefs: prefs:
- PREF_BQ - PREF_BQ
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/vision/stable/utils.html](https://pytorch.org/vision/stable/utils.html)
- en: The `torchvision.utils` module contains various utilities, mostly [for visualization](auto_examples/others/plot_visualization_utils.html#sphx-glr-auto-examples-others-plot-visualization-utils-py). - en: The `torchvision.utils` module contains various utilities, mostly [for visualization](auto_examples/others/plot_visualization_utils.html#sphx-glr-auto-examples-others-plot-visualization-utils-py).
id: totrans-2
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: '`torchvision.utils` 模块包含各种实用工具,主要用于[可视化](auto_examples/others/plot_visualization_utils.html#sphx-glr-auto-examples-others-plot-visualization-utils-py)。'
- en: '| [`draw_bounding_boxes`](generated/torchvision.utils.draw_bounding_boxes.html#torchvision.utils.draw_bounding_boxes - en: '| [`draw_bounding_boxes`](generated/torchvision.utils.draw_bounding_boxes.html#torchvision.utils.draw_bounding_boxes
"torchvision.utils.draw_bounding_boxes")(image, boxes[, labels, ...]) | Draws "torchvision.utils.draw_bounding_boxes")(image, boxes[, labels, ...]) | Draws
bounding boxes on given image. |' bounding boxes on given image. |'
id: totrans-3
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`draw_bounding_boxes`](generated/torchvision.utils.draw_bounding_boxes.html#torchvision.utils.draw_bounding_boxes
"torchvision.utils.draw_bounding_boxes")(image, boxes[, labels, ...]) | 在给定的图像上绘制边界框。
|'
- en: '| [`draw_segmentation_masks`](generated/torchvision.utils.draw_segmentation_masks.html#torchvision.utils.draw_segmentation_masks - en: '| [`draw_segmentation_masks`](generated/torchvision.utils.draw_segmentation_masks.html#torchvision.utils.draw_segmentation_masks
"torchvision.utils.draw_segmentation_masks")(image, masks[, ...]) | Draws segmentation "torchvision.utils.draw_segmentation_masks")(image, masks[, ...]) | Draws segmentation
masks on given RGB image. |' masks on given RGB image. |'
id: totrans-4
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`draw_segmentation_masks`](generated/torchvision.utils.draw_segmentation_masks.html#torchvision.utils.draw_segmentation_masks
"torchvision.utils.draw_segmentation_masks")(image, masks[, ...]) | 在给定的 RGB 图像上绘制分割蒙版。
|'
- en: '| [`draw_keypoints`](generated/torchvision.utils.draw_keypoints.html#torchvision.utils.draw_keypoints - en: '| [`draw_keypoints`](generated/torchvision.utils.draw_keypoints.html#torchvision.utils.draw_keypoints
"torchvision.utils.draw_keypoints")(image, keypoints[, ...]) | Draws Keypoints "torchvision.utils.draw_keypoints")(image, keypoints[, ...]) | Draws Keypoints
on given RGB image. |' on given RGB image. |'
id: totrans-5
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`draw_keypoints`](generated/torchvision.utils.draw_keypoints.html#torchvision.utils.draw_keypoints
"torchvision.utils.draw_keypoints")(image, keypoints[, ...]) | 在给定的 RGB 图像上绘制关键点。
|'
- en: '| [`flow_to_image`](generated/torchvision.utils.flow_to_image.html#torchvision.utils.flow_to_image - en: '| [`flow_to_image`](generated/torchvision.utils.flow_to_image.html#torchvision.utils.flow_to_image
"torchvision.utils.flow_to_image")(flow) | Converts a flow to an RGB image. |' "torchvision.utils.flow_to_image")(flow) | Converts a flow to an RGB image. |'
id: totrans-6
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`flow_to_image`](generated/torchvision.utils.flow_to_image.html#torchvision.utils.flow_to_image
"torchvision.utils.flow_to_image")(flow) | 将光流转换为 RGB 图像。 |'
- en: '| [`make_grid`](generated/torchvision.utils.make_grid.html#torchvision.utils.make_grid - en: '| [`make_grid`](generated/torchvision.utils.make_grid.html#torchvision.utils.make_grid
"torchvision.utils.make_grid")(tensor[, nrow, padding, ...]) | Make a grid of "torchvision.utils.make_grid")(tensor[, nrow, padding, ...]) | Make a grid of
images. |' images. |'
id: totrans-7
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`make_grid`](generated/torchvision.utils.make_grid.html#torchvision.utils.make_grid
"torchvision.utils.make_grid")(tensor[, nrow, padding, ...]) | 制作图像网格。 |'
- en: '| [`save_image`](generated/torchvision.utils.save_image.html#torchvision.utils.save_image - en: '| [`save_image`](generated/torchvision.utils.save_image.html#torchvision.utils.save_image
"torchvision.utils.save_image")(tensor, fp[, format]) | Save a given Tensor into "torchvision.utils.save_image")(tensor, fp[, format]) | Save a given Tensor into
an image file. |' an image file. |'
id: totrans-8
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`save_image`](generated/torchvision.utils.save_image.html#torchvision.utils.save_image
"torchvision.utils.save_image")(tensor, fp[, format]) | 将给定的张量保存为图像文件。 |'
此差异已折叠。
- en: Decoding / Encoding images and videos - en: Decoding / Encoding images and videos
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 解码/编码图像和视频
- en: 原文:[https://pytorch.org/vision/stable/io.html](https://pytorch.org/vision/stable/io.html) - en: 原文:[https://pytorch.org/vision/stable/io.html](https://pytorch.org/vision/stable/io.html)
id: totrans-1
prefs: prefs:
- PREF_BQ - PREF_BQ
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/vision/stable/io.html](https://pytorch.org/vision/stable/io.html)
- en: The `torchvision.io` package provides functions for performing IO operations. - en: The `torchvision.io` package provides functions for performing IO operations.
They are currently specific to reading and writing images and videos. They are currently specific to reading and writing images and videos.
id: totrans-2
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: '`torchvision.io`包提供了执行IO操作的函数。目前这些函数专门用于读取和写入图像和视频。'
- en: Images[](#images "Permalink to this heading") - en: Images[](#images "Permalink to this heading")
id: totrans-3
prefs: prefs:
- PREF_H2 - PREF_H2
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 图像[](#images "跳转到此标题")
- en: '| [`read_image`](generated/torchvision.io.read_image.html#torchvision.io.read_image - en: '| [`read_image`](generated/torchvision.io.read_image.html#torchvision.io.read_image
"torchvision.io.read_image")(path[, mode]) | Reads a JPEG or PNG image into a "torchvision.io.read_image")(path[, mode]) | Reads a JPEG or PNG image into a
3 dimensional RGB or grayscale Tensor. |' 3 dimensional RGB or grayscale Tensor. |'
id: totrans-4
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`read_image`](generated/torchvision.io.read_image.html#torchvision.io.read_image
"torchvision.io.read_image")(path[, mode]) | 将JPEG或PNG图像读入三维RGB或灰度张量。 |'
- en: '| [`decode_image`](generated/torchvision.io.decode_image.html#torchvision.io.decode_image - en: '| [`decode_image`](generated/torchvision.io.decode_image.html#torchvision.io.decode_image
"torchvision.io.decode_image")(input[, mode]) | Detects whether an image is a "torchvision.io.decode_image")(input[, mode]) | Detects whether an image is a
JPEG or PNG and performs the appropriate operation to decode the image into a JPEG or PNG and performs the appropriate operation to decode the image into a
3 dimensional RGB or grayscale Tensor. |' 3 dimensional RGB or grayscale Tensor. |'
id: totrans-5
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`decode_image`](generated/torchvision.io.decode_image.html#torchvision.io.decode_image
"torchvision.io.decode_image")(input[, mode]) | 检测图像是JPEG还是PNG,并执行适当的操作将图像解码为三维RGB或灰度张量。
|'
- en: '| [`encode_jpeg`](generated/torchvision.io.encode_jpeg.html#torchvision.io.encode_jpeg - en: '| [`encode_jpeg`](generated/torchvision.io.encode_jpeg.html#torchvision.io.encode_jpeg
"torchvision.io.encode_jpeg")(input[, quality]) | Takes an input tensor in CHW "torchvision.io.encode_jpeg")(input[, quality]) | Takes an input tensor in CHW
layout and returns a buffer with the contents of its corresponding JPEG file. layout and returns a buffer with the contents of its corresponding JPEG file.
|' |'
id: totrans-6
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`encode_jpeg`](generated/torchvision.io.encode_jpeg.html#torchvision.io.encode_jpeg
"torchvision.io.encode_jpeg")(input[, quality]) | 将输入张量按CHW布局编码为其对应JPEG文件内容的缓冲区。
|'
- en: '| [`decode_jpeg`](generated/torchvision.io.decode_jpeg.html#torchvision.io.decode_jpeg - en: '| [`decode_jpeg`](generated/torchvision.io.decode_jpeg.html#torchvision.io.decode_jpeg
"torchvision.io.decode_jpeg")(input[, mode, device]) | Decodes a JPEG image into "torchvision.io.decode_jpeg")(input[, mode, device]) | Decodes a JPEG image into
a 3 dimensional RGB or grayscale Tensor. |' a 3 dimensional RGB or grayscale Tensor. |'
id: totrans-7
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`decode_jpeg`](generated/torchvision.io.decode_jpeg.html#torchvision.io.decode_jpeg
"torchvision.io.decode_jpeg")(input[, mode, device]) | 将JPEG图像解码为三维RGB或灰度张量。 |'
- en: '| [`write_jpeg`](generated/torchvision.io.write_jpeg.html#torchvision.io.write_jpeg - en: '| [`write_jpeg`](generated/torchvision.io.write_jpeg.html#torchvision.io.write_jpeg
"torchvision.io.write_jpeg")(input, filename[, quality]) | Takes an input tensor "torchvision.io.write_jpeg")(input, filename[, quality]) | Takes an input tensor
in CHW layout and saves it in a JPEG file. |' in CHW layout and saves it in a JPEG file. |'
id: totrans-8
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`write_jpeg`](generated/torchvision.io.write_jpeg.html#torchvision.io.write_jpeg
"torchvision.io.write_jpeg")(input, filename[, quality]) | 将输入张量按CHW布局保存为JPEG文件。
|'
- en: '| [`encode_png`](generated/torchvision.io.encode_png.html#torchvision.io.encode_png - en: '| [`encode_png`](generated/torchvision.io.encode_png.html#torchvision.io.encode_png
"torchvision.io.encode_png")(input[, compression_level]) | Takes an input tensor "torchvision.io.encode_png")(input[, compression_level]) | Takes an input tensor
in CHW layout and returns a buffer with the contents of its corresponding PNG in CHW layout and returns a buffer with the contents of its corresponding PNG
file. |' file. |'
id: totrans-9
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`encode_png`](generated/torchvision.io.encode_png.html#torchvision.io.encode_png
"torchvision.io.encode_png")(input[, compression_level]) | 将输入张量按CHW布局编码为其对应PNG文件内容的缓冲区。
|'
- en: '| [`decode_png`](generated/torchvision.io.decode_png.html#torchvision.io.decode_png - en: '| [`decode_png`](generated/torchvision.io.decode_png.html#torchvision.io.decode_png
"torchvision.io.decode_png")(input[, mode]) | Decodes a PNG image into a 3 dimensional "torchvision.io.decode_png")(input[, mode]) | Decodes a PNG image into a 3 dimensional
RGB or grayscale Tensor. |' RGB or grayscale Tensor. |'
id: totrans-10
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`decode_png`](generated/torchvision.io.decode_png.html#torchvision.io.decode_png
"torchvision.io.decode_png")(input[, mode]) | 将PNG图像解码为三维RGB或灰度张量。 |'
- en: '| [`write_png`](generated/torchvision.io.write_png.html#torchvision.io.write_png - en: '| [`write_png`](generated/torchvision.io.write_png.html#torchvision.io.write_png
"torchvision.io.write_png")(input, filename[, compression_level]) | Takes an input "torchvision.io.write_png")(input, filename[, compression_level]) | Takes an input
tensor in CHW layout (or HW in the case of grayscale images) and saves it in a tensor in CHW layout (or HW in the case of grayscale images) and saves it in a
PNG file. |' PNG file. |'
id: totrans-11
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`write_png`](generated/torchvision.io.write_png.html#torchvision.io.write_png
"torchvision.io.write_png")(input, filename[, compression_level]) | 将输入张量按CHW布局(或灰度图像的情况下按HW布局)保存为PNG文件。
|'
- en: '| [`read_file`](generated/torchvision.io.read_file.html#torchvision.io.read_file - en: '| [`read_file`](generated/torchvision.io.read_file.html#torchvision.io.read_file
"torchvision.io.read_file")(path) | Reads and outputs the bytes contents of a "torchvision.io.read_file")(path) | Reads and outputs the bytes contents of a
file as a uint8 Tensor with one dimension. |' file as a uint8 Tensor with one dimension. |'
id: totrans-12
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`read_file`](generated/torchvision.io.read_file.html#torchvision.io.read_file
"torchvision.io.read_file")(path) | 读取文件的字节内容,并输出为具有一维uint8张量。 |'
- en: '| [`write_file`](generated/torchvision.io.write_file.html#torchvision.io.write_file - en: '| [`write_file`](generated/torchvision.io.write_file.html#torchvision.io.write_file
"torchvision.io.write_file")(filename, data) | Writes the contents of an uint8 "torchvision.io.write_file")(filename, data) | Writes the contents of an uint8
tensor with one dimension to a file. |' tensor with one dimension to a file. |'
id: totrans-13
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`write_file`](generated/torchvision.io.write_file.html#torchvision.io.write_file
"torchvision.io.write_file")(filename, data) | 将具有一维的uint8张量内容写入文件。 |'
- en: '| [`ImageReadMode`](generated/torchvision.io.ImageReadMode.html#torchvision.io.ImageReadMode - en: '| [`ImageReadMode`](generated/torchvision.io.ImageReadMode.html#torchvision.io.ImageReadMode
"torchvision.io.ImageReadMode")(value) | Support for various modes while reading "torchvision.io.ImageReadMode")(value) | Support for various modes while reading
images. |' images. |'
id: totrans-14
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`ImageReadMode`](generated/torchvision.io.ImageReadMode.html#torchvision.io.ImageReadMode
"torchvision.io.ImageReadMode")(value) | 在读取图像时支持各种模式。 |'
- en: Video[](#video "Permalink to this heading") - en: Video[](#video "Permalink to this heading")
id: totrans-15
prefs: prefs:
- PREF_H2 - PREF_H2
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 视频[](#video "跳转到此标题")
- en: '| [`read_video`](generated/torchvision.io.read_video.html#torchvision.io.read_video - en: '| [`read_video`](generated/torchvision.io.read_video.html#torchvision.io.read_video
"torchvision.io.read_video")(filename[, start_pts, end_pts, ...]) | Reads a video "torchvision.io.read_video")(filename[, start_pts, end_pts, ...]) | Reads a video
from a file, returning both the video frames and the audio frames |' from a file, returning both the video frames and the audio frames |'
id: totrans-16
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`read_video`](generated/torchvision.io.read_video.html#torchvision.io.read_video
"torchvision.io.read_video")(filename[, start_pts, end_pts, ...]) | 从文件中读取视频,返回视频帧和音频帧
|'
- en: '| [`read_video_timestamps`](generated/torchvision.io.read_video_timestamps.html#torchvision.io.read_video_timestamps - en: '| [`read_video_timestamps`](generated/torchvision.io.read_video_timestamps.html#torchvision.io.read_video_timestamps
"torchvision.io.read_video_timestamps")(filename[, pts_unit]) | List the video "torchvision.io.read_video_timestamps")(filename[, pts_unit]) | List the video
frames timestamps. |' frames timestamps. |'
id: totrans-17
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`read_video_timestamps`](generated/torchvision.io.read_video_timestamps.html#torchvision.io.read_video_timestamps
"torchvision.io.read_video_timestamps")(filename[, pts_unit]) | 列出视频帧的时间戳。 |'
- en: '| [`write_video`](generated/torchvision.io.write_video.html#torchvision.io.write_video - en: '| [`write_video`](generated/torchvision.io.write_video.html#torchvision.io.write_video
"torchvision.io.write_video")(filename, video_array, fps[, ...]) | Writes a 4d "torchvision.io.write_video")(filename, video_array, fps[, ...]) | Writes a 4d
tensor in [T, H, W, C] format in a video file |' tensor in [T, H, W, C] format in a video file |'
id: totrans-18
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`write_video`](generated/torchvision.io.write_video.html#torchvision.io.write_video
"torchvision.io.write_video")(filename, video_array, fps[, ...]) | 将[T, H, W,
C]格式的4维张量写入视频文件 |'
- en: Fine-grained video API[](#fine-grained-video-api "Permalink to this heading") - en: Fine-grained video API[](#fine-grained-video-api "Permalink to this heading")
id: totrans-19
prefs: prefs:
- PREF_H3 - PREF_H3
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 细粒度视频API[](#fine-grained-video-api "跳转到此标题")
- en: In addition to the `read_video` function, we provide a high-performance lower-level - en: In addition to the `read_video` function, we provide a high-performance lower-level
API for more fine-grained control compared to the `read_video` function. It does API for more fine-grained control compared to the `read_video` function. It does
all this whilst fully supporting torchscript. all this whilst fully supporting torchscript.
id: totrans-20
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 除了`read_video`函数外,我们还提供了一个高性能的低级API,用于比`read_video`函数更精细的控制。它在完全支持torchscript的同时完成所有这些操作。
- en: Warning - en: Warning
id: totrans-21
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 警告
- en: The fine-grained video API is in Beta stage, and backward compatibility is not - en: The fine-grained video API is in Beta stage, and backward compatibility is not
guaranteed. guaranteed.
id: totrans-22
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 细粒度视频API处于Beta阶段,不保证向后兼容性。
- en: '| [`VideoReader`](generated/torchvision.io.VideoReader.html#torchvision.io.VideoReader - en: '| [`VideoReader`](generated/torchvision.io.VideoReader.html#torchvision.io.VideoReader
"torchvision.io.VideoReader")(src[, stream, num_threads]) | Fine-grained video-reading "torchvision.io.VideoReader")(src[, stream, num_threads]) | Fine-grained video-reading
API. |' API. |'
id: totrans-23
prefs: [] prefs: []
type: TYPE_TB type: TYPE_TB
zh: '| [`VideoReader`](generated/torchvision.io.VideoReader.html#torchvision.io.VideoReader
"torchvision.io.VideoReader")(src[, stream, num_threads]) | 细粒度视频读取API。 |'
- en: 'Example of inspecting a video:' - en: 'Example of inspecting a video:'
id: totrans-24
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 检查视频的示例:
- en: '[PRE0]' - en: '[PRE0]'
id: totrans-25
prefs: [] prefs: []
type: TYPE_PRE type: TYPE_PRE
zh: '[PRE0]'
此差异已折叠。
- en: Examples and training references - en: Examples and training references
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 示例和培训参考资料
此差异已折叠。
- en: Training references - en: Training references
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 训练参考
- en: 原文:[https://pytorch.org/vision/stable/training_references.html](https://pytorch.org/vision/stable/training_references.html) - en: 原文:[https://pytorch.org/vision/stable/training_references.html](https://pytorch.org/vision/stable/training_references.html)
id: totrans-1
prefs: prefs:
- PREF_BQ - PREF_BQ
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/vision/stable/training_references.html](https://pytorch.org/vision/stable/training_references.html)
- en: On top of the many models, datasets, and image transforms, Torchvision also - en: On top of the many models, datasets, and image transforms, Torchvision also
provides training reference scripts. These are the scripts that we use to train provides training reference scripts. These are the scripts that we use to train
the [models](models.html#models) which are then available with pre-trained weights. the [models](models.html#models) which are then available with pre-trained weights.
id: totrans-2
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 除了许多模型、数据集和图像转换之外,Torchvision还提供训练参考脚本。这些脚本是我们用来训练[模型](models.html#models)的,然后这些模型就可以使用预训练的权重。
- en: These scripts are not part of the core package and are instead available [on - en: These scripts are not part of the core package and are instead available [on
GitHub](https://github.com/pytorch/vision/tree/main/references). We currently GitHub](https://github.com/pytorch/vision/tree/main/references). We currently
provide references for [classification](https://github.com/pytorch/vision/tree/main/references/classification), provide references for [classification](https://github.com/pytorch/vision/tree/main/references/classification),
...@@ -18,22 +24,32 @@ ...@@ -18,22 +24,32 @@
[segmentation](https://github.com/pytorch/vision/tree/main/references/segmentation), [segmentation](https://github.com/pytorch/vision/tree/main/references/segmentation),
[similarity learning](https://github.com/pytorch/vision/tree/main/references/similarity), [similarity learning](https://github.com/pytorch/vision/tree/main/references/similarity),
and [video classification](https://github.com/pytorch/vision/tree/main/references/video_classification). and [video classification](https://github.com/pytorch/vision/tree/main/references/video_classification).
id: totrans-3
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 这些脚本不是核心包的一部分,而是在[GitHub](https://github.com/pytorch/vision/tree/main/references)上提供。我们目前为[分类](https://github.com/pytorch/vision/tree/main/references/classification)、[检测](https://github.com/pytorch/vision/tree/main/references/detection)、[分割](https://github.com/pytorch/vision/tree/main/references/segmentation)、[相似性学习](https://github.com/pytorch/vision/tree/main/references/similarity)和[视频分类](https://github.com/pytorch/vision/tree/main/references/video_classification)提供参考。
- en: While these scripts are largely stable, they do not offer backward compatibility - en: While these scripts are largely stable, they do not offer backward compatibility
guarantees. guarantees.
id: totrans-4
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 尽管这些脚本在很大程度上是稳定的,但它们不提供向后兼容性保证。
- en: 'In general, these scripts rely on the latest (not yet released) pytorch version - en: 'In general, these scripts rely on the latest (not yet released) pytorch version
or the latest torchvision version. This means that to use them, **you might need or the latest torchvision version. This means that to use them, **you might need
to install the latest pytorch and torchvision versions**, with e.g.:' to install the latest pytorch and torchvision versions**, with e.g.:'
id: totrans-5
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 一般来说,这些脚本依赖于最新(尚未发布)的pytorch版本或最新的torchvision版本。这意味着要使用它们,**您可能需要安装最新的pytorch和torchvision版本**,例如:
- en: '[PRE0]' - en: '[PRE0]'
id: totrans-6
prefs: [] prefs: []
type: TYPE_PRE type: TYPE_PRE
zh: '[PRE0]'
- en: If you need to rely on an older stable version of pytorch or torchvision, e.g. - en: If you need to rely on an older stable version of pytorch or torchvision, e.g.
torchvision 0.10, then it’s safer to use the scripts from that corresponding release torchvision 0.10, then it’s safer to use the scripts from that corresponding release
on GitHub, namely [https://github.com/pytorch/vision/tree/v0.10.0/references](https://github.com/pytorch/vision/tree/v0.10.0/references). on GitHub, namely [https://github.com/pytorch/vision/tree/v0.10.0/references](https://github.com/pytorch/vision/tree/v0.10.0/references).
id: totrans-7
prefs: [] prefs: []
type: TYPE_NORMAL type: TYPE_NORMAL
zh: 如果您需要依赖于较旧的稳定版本的pytorch或torchvision,例如torchvision 0.10,那么最好使用GitHub上对应发布的脚本,即[https://github.com/pytorch/vision/tree/v0.10.0/references](https://github.com/pytorch/vision/tree/v0.10.0/references)。
- en: PyTorch Libraries - en: PyTorch Libraries
id: totrans-0
prefs: prefs:
- PREF_H1 - PREF_H1
type: TYPE_NORMAL type: TYPE_NORMAL
zh: PyTorch库
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册