从目标C中的Bundle读取mlmodel

时间:2018-06-11 15:08:05

标签: objective-c coreml coremltools

我正在尝试读取.mlmodel文件进​​行编译并在我们的库中使用它。我正在测试库,但我无法读取文件并进行编译......我不知道究竟是为什么。我正在使用这两个功能(都不起作用)

-(NSString*) FilePathForResourceName:(NSString*) name  forExtension:(NSString*) extension {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSString* file_path = [bundle pathForResource:name ofType:extension];
    return file_path;
}


-(NSString*) FilePathForMainBundleResourceName:(NSString*) name  forExtension:(NSString*) extension {
    NSBundle *main = [NSBundle mainBundle];
    NSString* file_path = [main pathForResource:name ofType:extension];
    return file_path;
}

这是测试示例,其中network_path总是返回nil:

- (void)testShouldAnalyseCorrectlyWithDetectionBicycles {
    NSString* image_path = [self FilePathForResourceName:@"bicycles" forExtension:@"jpg"];
    NSString* labels_path = [self FilePathForResourceName:@"coco_labels_list" forExtension:@"txt"];
    NSString* network_path = [self FilePathForResourceName:@"ssd_mobilenet_feature_extractor" forExtension:@"mlmodel"];
    CoreMLLib* lib = [[CoreMLLib alloc] init:network_path forLabel:labels_path];
    [lib run:image_path];
}

我认为,它正确添加了项目中的文件(对于目标测试和库):

enter image description here

FilePathForResourceName

中的

值参数

  • 名称 - > ssd_mobilenet_feature_extractor
  • 扩展程序 - > mlmodel
  • file_path - > nil
  • 捆绑 - >一个NSBundle “/Users/joan/Library/Developer/Xcode/DerivedData/draagu-ios-tensorflow-lib-hglbgbpvrarumdfwwgjoebcuesar/Build/Products/Debug-iphonesimulator/draagu-ios-tensorflow-libTests.xctest”0x00007f7f1fc2cb40

0 个答案:

没有答案