```
feat(iOS): 更新MNN后端模型配置优化性能 将MNN主模型从Qwen3.5-4B(~2.64GiB)降级为Qwen3.5-2B(~1.1GiB),因为4B版本 实测运行过慢,影响用户体验。iPhone17+/SME2设备使用2B模型,保留MLX 兜底方案用于模拟器和备用场景,确保AI推理性能和存储效率的平衡。 ```
This commit is contained in:
@@ -3,7 +3,7 @@ import CoreGraphics
|
||||
import AVFoundation
|
||||
@testable import 康康
|
||||
|
||||
/// 异常项快拍的局部裁剪几何。
|
||||
/// 指标速记的局部裁剪几何。
|
||||
/// 回归用例:屏上「宽而矮」的小框,必须裁出「宽 > 高」的照片 rect。
|
||||
/// 旧实现用 `metadataOutputRectConverted`(传感器横向坐标)套到竖屏照片 → x/y 轴对调,
|
||||
/// 把宽框裁成竖窄条(2026-05-31 真机 bug)。本组用例钉住正确的纯几何映射。
|
||||
@@ -113,40 +113,4 @@ final class RegionImageCropperTests: XCTestCase {
|
||||
.zero)
|
||||
}
|
||||
|
||||
/// Qwen3-VL 对宽而矮的局部小图更容易在 processor 缩放后丢字。
|
||||
/// 进入 VL 前应把短边放大并加白边,但不拉伸内容。
|
||||
func testPrepareForQwenVLUpscalesWideShortCropAndAddsPadding() {
|
||||
let image = solidImage(size: CGSize(width: 320, height: 80))
|
||||
|
||||
let prepared = RegionImageCropper.prepareForQwenVL(image)
|
||||
|
||||
XCTAssertGreaterThanOrEqual(prepared.size.height, 448)
|
||||
XCTAssertGreaterThan(prepared.size.width, 320)
|
||||
XCTAssertEqual(prepared.size.width / prepared.size.height,
|
||||
4.0,
|
||||
accuracy: 0.8,
|
||||
"预处理应大致保留宽条内容比例,只允许白边造成轻微变化")
|
||||
}
|
||||
|
||||
func testPrepareForQwenVLDoesNotEnlargePastLongEdgeLimit() {
|
||||
let image = solidImage(size: CGSize(width: 5000, height: 900))
|
||||
|
||||
let prepared = RegionImageCropper.prepareForQwenVL(image)
|
||||
|
||||
XCTAssertLessThanOrEqual(max(prepared.size.width, prepared.size.height), 2400 + 128)
|
||||
}
|
||||
|
||||
private func solidImage(size: CGSize) -> UIImage {
|
||||
let format = UIGraphicsImageRendererFormat.default()
|
||||
format.scale = 1
|
||||
return UIGraphicsImageRenderer(size: size, format: format).image { ctx in
|
||||
UIColor.white.setFill()
|
||||
ctx.fill(CGRect(origin: .zero, size: size))
|
||||
UIColor.black.setFill()
|
||||
ctx.fill(CGRect(x: size.width * 0.1,
|
||||
y: size.height * 0.35,
|
||||
width: size.width * 0.8,
|
||||
height: size.height * 0.3))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user