-
Notifications
You must be signed in to change notification settings - Fork 282
iOS Guide
Haidong Lan edited this page May 7, 2018
·
1 revision
We start from a working blank project, and show necessary steps to use our library. Please make sure that your project works before proceeding to the following steps.
- Select your project in the navigator on the left, and then select the Build Phases tab on the right.
- Add feather framework in the Link Binary With Libraries section.
- In the pop up window select Add Other and navigate to the framework.
- Select the Build Settings tab, find the Framework Search Paths option.
- Add the path to your framework. It will tell Xcode where to find the headers.
- Press control key and click on the project, add the feathermodel to your project.
- Check the Copy Bundle Items section under the Build Phases tab, make sure it contains your feathermodel file.
- If the ViewController.mm file ends with .m, rename to .mm and open that file.
- Add feather header, and initialize the net as illustrated in the figure. The code snippet in the figure:
NSString *path = [[NSBundle mainBundle] resourcePath];
NSString *nsFeathermodelPath = [path stringByAppendingPathComponent:@"mobilenet.feathermodel"];
const char *netPath = [nsFeathermodelPath UTF8String];
int num_threads = 1;
feather::Net forward_net(num_threads);
forward_net.InitFromPath(netPath);
- The net is ready to go. Let's say the input image data is in a float array, you can call the forward procedure by
forward_net.Forward(input)
at wherever it needs. The input data should be in NCHW layout, which is row major for each image channel, and only infer one image at a time. For a batch of images, it requires several calls to the Forward procedure. You can extract your results afterwards by
forward_net.ExtractBlob(target_ptr, blob_name);
where the target_ptr is where you want to copy the results, and blob_name is a std string.