我有一个由 40 个数组组成的数组,其中包含 12 个双重特征,所以类型是 [[double]]。目前我正在将此数据发送到 Google Cloud ML API 以获得相关预测。
由于 Apple 最近推出了 CoreML 和 coremltools,我将我的模型从 keras 转换为 .mlmodel 以避免数千次 google cloud api 调用并直接在我的 iPhone 上进行推理:
coreml_model = coremltools.converters.keras.convert(new_Model, input_names=['accelerations'],
output_names=['scores'])
coreml_model.save('PredictionModel.mlmodel')
Run Code Online (Sandbox Code Playgroud)
我不知道这些其他输入和输出来自哪里。要获得预测,我需要将我的 12 个双精度数组数组转换为 MLMultiArray,但我不知道如何执行此操作。有没有人遇到过类似的问题?这是我目前未完成的方法:
_predictionModel = PredictionModel()
guard let mlMultiArray = try? MLMultiArray(dataPointer: <#T##UnsafeMutableRawPointer#>, shape: <#T##[NSNumber]#>, dataType: <#T##MLMultiArrayDataType#>, strides: <#T##[NSNumber]#>, deallocator: <#T##((UnsafeMutableRawPointer) -> Void)?##((UnsafeMutableRawPointer) -> Void)?##(UnsafeMutableRawPointer) -> Void#>) else {
fatalError("Unexpected runtime error.")
}
guard let predictionOutput = try? _predictionModel.prediction(accelerations: mlMultiArray, lstm_1_h_in: nil, lstm_1_c_in: …Run Code Online (Sandbox Code Playgroud) 从iOS 11的第3版开始,我的应用程序在初始化用于AirPlay的MPVolumeView时开始崩溃.以下代码在早期版本的iOS和iOS 11 beta 1和2上运行得非常好.
func setupAirplayButton() {
let rect = CGRect(x: -1000, y: -1000, width: 10, height: 10)
volumeView = MPVolumeView(frame: rect) //app crashes here
volumeView.showsVolumeSlider = false
volumeView.setRouteButtonImage(nil, for: .normal)
volumeView.translatesAutoresizingMaskIntoConstraints = false
volumeView.isHidden = true
if let airplayButton = volumeView.subviews.filter({$0 is UIButton }).first as? UIButton {
self.airplayButton = airplayButton
self.airplayButton?.addObserver(self, forKeyPath: "alpha", options: [.initial, .new], context: nil)
}
NotificationCenter.default.addObserver(self, selector: #selector(wirelessRouteActiveChanged), name: NSNotification.Name.MPVolumeViewWirelessRouteActiveDidChange, object: nil)
myView.addSubview(volumeView)
}
Run Code Online (Sandbox Code Playgroud)
还有其他人遇到过同样的问题吗?
编辑:
崩溃日志
Exception Type: EXC_CRASH (SIGTRAP)
Exception Codes: 0x0000000000000000, …Run Code Online (Sandbox Code Playgroud) MacBook Pro El Capitan(10.11.6)在这里.我正在尝试安装Xcode 9,以便我可以使用ARKit.在Apple Developer的网站上,我能找到的唯一版本是9 Xcode_9_beta_6.xip(如果我错了请纠正我!),所以我下载它:
然后我提取并运行XIP文件:
但是由于这个奇怪的错误谷歌并没有真正帮助我(根本),这个操作失败了:
有什么想法在这里发生了什么?
我有一个带有长动画的.dae模型.动画包括步行,跑步,击球,死亡等部分.我知道每个部分的开始和结束的帧数.我也知道每秒帧速率.因此,获取每个细分的开始和结束时间非常简单.
我可以将完整的动画作为SCNAnimationPlayer对象.我一直在尝试的是制作完整动画的副本,然后设置动画的timeOffset和持续时间.
let walkPlayer = fullPlayer.copy() as! SCNAnimationPlayer
walkPlayer.stop()
walkPlayer.animation.timeOffset = walk.offset
walkPlayer.animation.duration = walk.duration
Run Code Online (Sandbox Code Playgroud)
然后我将walkPlayer添加回Bip01节点(我从中获得了完整的动画).
我可以通过调用animationPlayer(forKey:"walk")来轻松地完成游戏.?play()
我可以很容易地改变动画的持续时间和其他方面.但是动画总是从第0帧开始.无论我放入什么值.timeOffset,它都会被忽略.
如何从SCNAnimationPlayer中的SCNAnimation的起始帧到结束帧进行播放?
我创建了一个 iOS 应用程序来搜索最近的蓝牙设备。但是当我在 iPhone 上运行这个应用程序时,出现以下错误
[CoreBluetooth] API MISUSE:只能在开机状态下接受此命令
我该如何解决此错误?为什么应用程序中会出现此错误?提前致谢
func centralManagerDidUpdateState(_ central: CBCentralManager) {
print(central.state)
switch (central.state) {
case CBManagerState.poweredOff:
print("CoreBluetooth BLE hardware is powered off")
break;
case CBManagerState.unauthorized:
print("CoreBluetooth BLE state is unauthorized")
break
case CBManagerState.unknown:
print("CoreBluetooth BLE state is unknown");
break
case CBManagerState.poweredOn:
print("CoreBluetooth BLE hardware is powered on and ready")
bluetoothAvailable = true;
break;
case CBManagerState.resetting:
print("CoreBluetooth BLE hardware is resetting")
break;
case CBManagerState.unsupported:
print("CoreBluetooth BLE hardware is unsupported on this platform");
break
}
if bluetoothAvailable == …Run Code Online (Sandbox Code Playgroud) 我正在使用下面的方法在Swift 3中将textView.typingAttributes前景色设置为红色.
textView.typingAttributes[NSForegroundColorAttributeName] = UIColor.red
Run Code Online (Sandbox Code Playgroud)
现在,我已经向Swift 4迁移了它的显示错误,我尝试如下,但它仍然显示错误.什么是正确的设置方式?
textView.typingAttributes[NSAttributedStringKey.foregroundColor] = UIColor.red
Run Code Online (Sandbox Code Playgroud) 该代码在iOS 10及更低版本中完美运行.但是,在iOS 11取消照片库并打开相机后,它总是打开照片库.这只发生在iOS 11中.
代码在Xcode 9 Beta 4中编译.
代码如下:
@IBAction func buttonProfilePicPressed(_ sender: UIButton)
{
let alert = UIAlertController(title: "Choose Image", message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Camera", style: .default, handler: { _ in
self.openCamera()
}))
alert.addAction(UIAlertAction(title: "Gallery", style: .default, handler: { _ in
self.openGallary()
}))
alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
imgPicker.delegate = self
self.present(imgPicker, animated: true, completion: nil)
}
func openCamera()
{
if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.camera))
{
imgPicker.sourceType = UIImagePickerControllerSourceType.camera
imgPicker.allowsEditing = true
self.present(imgPicker, …Run Code Online (Sandbox Code Playgroud) xcode9-beta ×10
ios11 ×5
ios ×4
xcode ×3
swift ×2
xcode9 ×2
airplay ×1
animation ×1
arkit ×1
autocomplete ×1
coreml ×1
macos ×1
mpvolumeview ×1
scenekit ×1
swift3 ×1
swift4 ×1
uitextview ×1