Swift:CoreML 中的图像预处理:调整大小和转置
我需要在输入模型之前对 UIImage 对象进行预处理。
该模型需要 2 次转换:
- 调整大小为 224,224
- 转置为 CHW
我搜索并发现有两种方法:
- 在 Swift 中进行预处理
- 使用 Coremltools 将操作添加到 AI 模型
我只设法找到如何在 Swift 中调整大小,但是有不知道如何进行转置以确保图像具有 CHW 数据格式。
也不知道如何从 UIImage 中查看数据格式(CHW 或 HWC)。
如何转置以及如何查看数据格式?
I need to preprocess the UIImage object before feeding to my model.
The model requires 2 transforms:
- resize to 224,224
- transpose to CHW
I searched and found there are 2 approaches:
- do the preprocessing in Swift
- add the operations to the AI model using Coremltools
I only managed to find how to do the resize in Swift, but have no idea how to do transpose to make sure the image has data format in CHW.
Also have no idea how to see the data format(CHW or HWC) from UIImage.
How to transpose and how to view the data format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置图像输入类型,不用担心大小和数据格式。有明确的API。
例子:
Setup Image input type and don't worry about sizes and data formats. Have clear API.
Example: