[
  {
    "path": ".gitignore",
    "content": "# Xcode\nbuild/\nDerivedData/\n\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\n\n*.xcuserstate\nxcuserdata/\n\n## Other\n*.moved-aside\n*.xccheckout\n*.xcscmblueprint\n\nprofile\n*.hmap\n*.ipa\n\n# CocoaPods\nPods/\n!Podfile.lock\n\n# Temporary files\n.DS_Store\n.Trashes\n.Spotlight-V100\n*.swp\n*.lock\n\n# Python\n__pycache__/\n*.py[cod]\n*$py.class\n\n# Jupyter Notebook\n.ipynb_checkpoints\n"
  },
  {
    "path": "Convert/coreml.py",
    "content": "import coremltools\n\ncoreml_model = coremltools.converters.keras.convert('./model_data/yolo.h5', input_names='input1', image_input_names='input1', output_names=['output1', 'output2', 'output3'], image_scale=1/255.)\n\ncoreml_model.input_description['input1'] = 'Input image'\ncoreml_model.output_description['output1'] = 'The 13x13 grid (Scale1)'\ncoreml_model.output_description['output2'] = 'The 26x26 grid (Scale2)'\ncoreml_model.output_description['output3'] = 'The 52x52 grid (Scale3)'\n\ncoreml_model.author = 'Original paper: Joseph Redmon, Ali Farhadi'\ncoreml_model.license = 'Public Domain'\ncoreml_model.short_description = \"The YOLOv3 network from the paper 'YOLOv3: An Incremental Improvement'\"\n\ncoreml_model.save('Yolov3.mlmodel')\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Copyright (c) 2017 M.I. Hollemans\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to\ndeal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or\nsell copies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n"
  },
  {
    "path": "README.markdown",
    "content": "# YOLOv3 with Core ML\n\nThis repo was forked and modified from [hollance/YOLO-CoreML-MPSNNGraph](https://github.com/hollance/YOLO-CoreML-MPSNNGraph). Some changes I made:\n\n1. Add YOLOv3 model.\n2. Only keep Keras converter.\n\n\n## About YOLO object detection\n\nYOLO is an object detection network. It can detect multiple objects in an image and puts bounding boxes around these objects. [Read hollance's blog post about YOLO](http://machinethink.net/blog/object-detection-with-yolo/) to learn more about how it works.\n\n![YOLO in action](YOLO.jpg)\n\nIn this repo you'll find:\n\n- **YOLOv3-CoreML:** A demo app that runs the YOLOv3 neural network on Core ML.\n- **Converter:** The scripts needed to convert the original Keras YOLOv3 model to Core ML.\n\nTo run the app:\n\n1. Extract YOLOv3 CoreML model in YOLOv3 CoreML model folder and copy to YOLOv3-CoreML/YOLOv3-CoreML folder.\n2. Open the **xcodeproj** file in Xcode 9 and run it on a device with iOS 11 or better installed.\n\nThe reported \"elapsed\" time is how long it takes the YOLO neural net to process a single image. The FPS is the actual throughput achieved by the app.\n\n> **NOTE:** Running these kinds of neural networks eats up a lot of battery power. The app can put a limit on the number of times per second it runs the neural net. You can change this in `setUpCamera()` by changing the line `videoCapture.fps = 50` to a smaller number.\n\n## Converting the models\n\n> **NOTE:** You don't need to convert the models yourself. Everything you need to run the demo apps is included in the Xcode projects already. \n\nThe model is converted from Keras h5 model, follow the Quick Start guide [keras-yolo3](https://github.com/qqwweee/keras-yolo3) to get YOLOv3 Keras h5 model, then use coreml.py to convert h5 model to CoreML model.\n\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/AppDelegate.swift",
    "content": "import UIKit\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n  var window: UIWindow?\n\n  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n    // Override point for customization after application launch.\n    return true\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "content": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"83.5x83.5\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ios-marketing\",\n      \"size\" : \"1024x1024\",\n      \"scale\" : \"1x\"\n    }\n  ],\n  \"info\" : {\n    \"version\" : 1,\n    \"author\" : \"xcode\"\n  }\n}"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/Base.lproj/Main.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"13122.17\" systemVersion=\"16E195\" targetRuntime=\"iOS.CocoaTouch\" propertyAccessControl=\"none\" useAutolayout=\"YES\" useTraitCollections=\"YES\" colorMatched=\"YES\" initialViewController=\"BYZ-38-t0r\">\n    <device id=\"retina4_7\" orientation=\"portrait\">\n        <adaptation id=\"fullscreen\"/>\n    </device>\n    <dependencies>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.IBCocoaTouchPlugin\" version=\"13104.14\"/>\n        <capability name=\"documents saved in the Xcode 8 format\" minToolsVersion=\"8.0\"/>\n    </dependencies>\n    <customFonts key=\"customFonts\">\n        <array key=\"Menlo.ttc\">\n            <string>Menlo-Regular</string>\n        </array>\n    </customFonts>\n    <scenes>\n        <!--View Controller-->\n        <scene sceneID=\"tne-QT-ifu\">\n            <objects>\n                <viewController id=\"BYZ-38-t0r\" customClass=\"ViewController\" customModule=\"YOLOv3_CoreML\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"y3c-jy-aDJ\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"wfy-db-euE\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"8bC-Xf-vdC\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"667\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"6b2-uP-TiX\" userLabel=\"Video Preview\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"667\"/>\n                                <color key=\"backgroundColor\" white=\"0.0\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                            </view>\n                            <imageView userInteractionEnabled=\"NO\" contentMode=\"center\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" fixedFrame=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"YNc-Bp-8Q7\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"416\" height=\"416\"/>\n                                <autoresizingMask key=\"autoresizingMask\" flexibleMaxX=\"YES\" flexibleMaxY=\"YES\"/>\n                            </imageView>\n                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Cau-LW-nDZ\" userLabel=\"Results\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"633\" width=\"375\" height=\"34\"/>\n                                <subviews>\n                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Elapsed time\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Nv7-zv-Hv7\">\n                                        <rect key=\"frame\" x=\"20\" y=\"10\" width=\"335\" height=\"14\"/>\n                                        <fontDescription key=\"fontDescription\" name=\"Menlo-Regular\" family=\"Menlo\" pointSize=\"12\"/>\n                                        <color key=\"textColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                                        <nil key=\"highlightedColor\"/>\n                                    </label>\n                                </subviews>\n                                <color key=\"backgroundColor\" white=\"0.0\" alpha=\"0.5\" colorSpace=\"calibratedWhite\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"Nv7-zv-Hv7\" secondAttribute=\"bottom\" constant=\"10\" id=\"RnN-mQ-1Ld\"/>\n                                    <constraint firstItem=\"Nv7-zv-Hv7\" firstAttribute=\"leading\" secondItem=\"Cau-LW-nDZ\" secondAttribute=\"leading\" constant=\"20\" id=\"YWK-0U-hbi\"/>\n                                    <constraint firstAttribute=\"trailing\" secondItem=\"Nv7-zv-Hv7\" secondAttribute=\"trailing\" constant=\"20\" id=\"c27-CJ-wZL\"/>\n                                    <constraint firstItem=\"Nv7-zv-Hv7\" firstAttribute=\"top\" secondItem=\"Cau-LW-nDZ\" secondAttribute=\"top\" constant=\"10\" id=\"lQX-Nw-dxK\"/>\n                                </constraints>\n                            </view>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"0.0\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                        <constraints>\n                            <constraint firstItem=\"6b2-uP-TiX\" firstAttribute=\"top\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"top\" id=\"5fy-Bv-RZx\"/>\n                            <constraint firstItem=\"Cau-LW-nDZ\" firstAttribute=\"leading\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"leading\" id=\"F86-Vt-lK5\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"6b2-uP-TiX\" secondAttribute=\"trailing\" id=\"VLN-Lj-dMD\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"Cau-LW-nDZ\" secondAttribute=\"trailing\" id=\"bJZ-RP-DH0\"/>\n                            <constraint firstAttribute=\"bottom\" secondItem=\"Cau-LW-nDZ\" secondAttribute=\"bottom\" id=\"nW1-Gf-bkQ\"/>\n                            <constraint firstItem=\"6b2-uP-TiX\" firstAttribute=\"leading\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"leading\" id=\"tQx-fh-d7D\"/>\n                            <constraint firstAttribute=\"bottom\" secondItem=\"6b2-uP-TiX\" secondAttribute=\"bottom\" id=\"xIr-G9-dgn\"/>\n                        </constraints>\n                    </view>\n                    <connections>\n                        <outlet property=\"debugImageView\" destination=\"YNc-Bp-8Q7\" id=\"Efd-I1-2Hu\"/>\n                        <outlet property=\"timeLabel\" destination=\"Nv7-zv-Hv7\" id=\"U6m-yA-4aP\"/>\n                        <outlet property=\"videoPreview\" destination=\"6b2-uP-TiX\" id=\"F9M-LA-bjs\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"dkx-z0-nzr\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"140\" y=\"137.18140929535232\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/BoundingBox.swift",
    "content": "import Foundation\nimport UIKit\n\nclass BoundingBox {\n  let shapeLayer: CAShapeLayer\n  let textLayer: CATextLayer\n\n  init() {\n    shapeLayer = CAShapeLayer()\n    shapeLayer.fillColor = UIColor.clear.cgColor\n    shapeLayer.lineWidth = 4\n    shapeLayer.isHidden = true\n\n    textLayer = CATextLayer()\n    textLayer.foregroundColor = UIColor.black.cgColor\n    textLayer.isHidden = true\n    textLayer.contentsScale = UIScreen.main.scale\n    textLayer.fontSize = 14\n    textLayer.font = UIFont(name: \"Avenir\", size: textLayer.fontSize)\n    textLayer.alignmentMode = kCAAlignmentCenter\n  }\n\n  func addToLayer(_ parent: CALayer) {\n    parent.addSublayer(shapeLayer)\n    parent.addSublayer(textLayer)\n  }\n\n  func show(frame: CGRect, label: String, color: UIColor) {\n    CATransaction.setDisableActions(true)\n\n    let path = UIBezierPath(rect: frame)\n    shapeLayer.path = path.cgPath\n    shapeLayer.strokeColor = color.cgColor\n    shapeLayer.isHidden = false\n\n    textLayer.string = label\n    textLayer.backgroundColor = color.cgColor\n    textLayer.isHidden = false\n\n    let attributes = [\n      NSAttributedStringKey.font: textLayer.font as Any\n    ]\n\n    let textRect = label.boundingRect(with: CGSize(width: 400, height: 100),\n                                      options: .truncatesLastVisibleLine,\n                                      attributes: attributes, context: nil)\n    let textSize = CGSize(width: textRect.width + 12, height: textRect.height)\n    let textOrigin = CGPoint(x: frame.origin.x - 2, y: frame.origin.y - textSize.height)\n    textLayer.frame = CGRect(origin: textOrigin, size: textSize)\n  }\n\n  func hide() {\n    shapeLayer.isHidden = true\n    textLayer.isHidden = true\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/CVPixelBuffer+Helpers.swift",
    "content": "import Foundation\nimport Accelerate\n\nfunc resizePixelBuffer(_ srcPixelBuffer: CVPixelBuffer,\n                       cropX: Int,\n                       cropY: Int,\n                       cropWidth: Int,\n                       cropHeight: Int,\n                       scaleWidth: Int,\n                       scaleHeight: Int) -> CVPixelBuffer? {\n\n  CVPixelBufferLockBaseAddress(srcPixelBuffer, CVPixelBufferLockFlags(rawValue: 0))\n  guard let srcData = CVPixelBufferGetBaseAddress(srcPixelBuffer) else {\n    print(\"Error: could not get pixel buffer base address\")\n    return nil\n  }\n  let srcBytesPerRow = CVPixelBufferGetBytesPerRow(srcPixelBuffer)\n  let offset = cropY*srcBytesPerRow + cropX*4\n  var srcBuffer = vImage_Buffer(data: srcData.advanced(by: offset),\n                                height: vImagePixelCount(cropHeight),\n                                width: vImagePixelCount(cropWidth),\n                                rowBytes: srcBytesPerRow)\n\n  let destBytesPerRow = scaleWidth*4\n  guard let destData = malloc(scaleHeight*destBytesPerRow) else {\n    print(\"Error: out of memory\")\n    return nil\n  }\n  var destBuffer = vImage_Buffer(data: destData,\n                                 height: vImagePixelCount(scaleHeight),\n                                 width: vImagePixelCount(scaleWidth),\n                                 rowBytes: destBytesPerRow)\n\n  let error = vImageScale_ARGB8888(&srcBuffer, &destBuffer, nil, vImage_Flags(0))\n  CVPixelBufferUnlockBaseAddress(srcPixelBuffer, CVPixelBufferLockFlags(rawValue: 0))\n  if error != kvImageNoError {\n    print(\"Error:\", error)\n    free(destData)\n    return nil\n  }\n\n  let releaseCallback: CVPixelBufferReleaseBytesCallback = { _, ptr in\n    if let ptr = ptr {\n      free(UnsafeMutableRawPointer(mutating: ptr))\n    }\n  }\n\n  let pixelFormat = CVPixelBufferGetPixelFormatType(srcPixelBuffer)\n  var dstPixelBuffer: CVPixelBuffer?\n  let status = CVPixelBufferCreateWithBytes(nil, scaleWidth, scaleHeight,\n                                            pixelFormat, destData,\n                                            destBytesPerRow, releaseCallback,\n                                            nil, nil, &dstPixelBuffer)\n  if status != kCVReturnSuccess {\n    print(\"Error: could not create new pixel buffer\")\n    free(destData)\n    return nil\n  }\n  return dstPixelBuffer\n}\n\nfunc resizePixelBuffer(_ pixelBuffer: CVPixelBuffer,\n                       width: Int, height: Int) -> CVPixelBuffer? {\n  return resizePixelBuffer(pixelBuffer, cropX: 0, cropY: 0,\n                           cropWidth: CVPixelBufferGetWidth(pixelBuffer),\n                           cropHeight: CVPixelBufferGetHeight(pixelBuffer),\n                           scaleWidth: width, scaleHeight: height)\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/Helpers.swift",
    "content": "import Foundation\nimport UIKit\nimport CoreML\nimport Accelerate\n\n// The labels for the 80 classes.\nlet labels = [\n    \"person\", \"bicycle\", \"car\", \"motorbike\", \"aeroplane\", \"bus\", \"train\", \"truck\", \"boat\", \"traffic light\",\n    \"fire hydrant\", \"stop sign\", \"parking meter\", \"bench\", \"bird\", \"cat\", \"dog\", \"horse\", \"sheep\", \"cow\",\n    \"elephant\", \"bear\", \"zebra\", \"giraffe\", \"backpack\", \"umbrella\", \"handbag\", \"tie\", \"suitcase\", \"frisbee\",\n    \"skis\", \"snowboard\", \"sports ball\", \"kite\", \"baseball bat\", \"baseball glove\", \"skateboard\", \"surfboard\", \"tennis racket\", \"bottle\",\n    \"wine glass\", \"cup\", \"fork\", \"knife\", \"spoon\", \"bowl\", \"banana\", \"apple\", \"sandwich\", \"orange\",\n    \"broccoli\", \"carrot\", \"hot dog\", \"pizza\", \"donut\", \"cake\", \"chair\", \"sofa\", \"pottedplant\", \"bed\",\n    \"diningtable\", \"toilet\", \"tvmonitor\", \"laptop\", \"mouse\", \"remote\", \"keyboard\", \"cell phone\", \"microwave\", \"oven\",\n    \"toaster\", \"sink\", \"refrigerator\", \"book\", \"clock\", \"vase\", \"scissors\", \"teddy bear\", \"hair drier\", \"toothbrush\"\n]\n\nlet anchors: [[Float]] = [[116,90,  156,198,  373,326], [30,61,  62,45,  59,119], [10,13,  16,30,  33,23]]\n\n/**\n  Removes bounding boxes that overlap too much with other boxes that have\n  a higher score.\n\n  Based on code from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/non_max_suppression_op.cc\n\n  - Parameters:\n    - boxes: an array of bounding boxes and their scores\n    - limit: the maximum number of boxes that will be selected\n    - threshold: used to decide whether boxes overlap too much\n*/\nfunc nonMaxSuppression(boxes: [YOLO.Prediction], limit: Int, threshold: Float) -> [YOLO.Prediction] {\n\n  // Do an argsort on the confidence scores, from high to low.\n  let sortedIndices = boxes.indices.sorted { boxes[$0].score > boxes[$1].score }\n\n  var selected: [YOLO.Prediction] = []\n  var active = [Bool](repeating: true, count: boxes.count)\n  var numActive = active.count\n\n  // The algorithm is simple: Start with the box that has the highest score.\n  // Remove any remaining boxes that overlap it more than the given threshold\n  // amount. If there are any boxes left (i.e. these did not overlap with any\n  // previous boxes), then repeat this procedure, until no more boxes remain\n  // or the limit has been reached.\n  outer: for i in 0..<boxes.count {\n    if active[i] {\n      let boxA = boxes[sortedIndices[i]]\n      selected.append(boxA)\n      if selected.count >= limit { break }\n\n      for j in i+1..<boxes.count {\n        if active[j] {\n          let boxB = boxes[sortedIndices[j]]\n          if IOU(a: boxA.rect, b: boxB.rect) > threshold {\n            active[j] = false\n            numActive -= 1\n            if numActive <= 0 { break outer }\n          }\n        }\n      }\n    }\n  }\n  return selected\n}\n\n/**\n  Computes intersection-over-union overlap between two bounding boxes.\n*/\npublic func IOU(a: CGRect, b: CGRect) -> Float {\n  let areaA = a.width * a.height\n  if areaA <= 0 { return 0 }\n\n  let areaB = b.width * b.height\n  if areaB <= 0 { return 0 }\n\n  let intersectionMinX = max(a.minX, b.minX)\n  let intersectionMinY = max(a.minY, b.minY)\n  let intersectionMaxX = min(a.maxX, b.maxX)\n  let intersectionMaxY = min(a.maxY, b.maxY)\n  let intersectionArea = max(intersectionMaxY - intersectionMinY, 0) *\n                         max(intersectionMaxX - intersectionMinX, 0)\n  return Float(intersectionArea / (areaA + areaB - intersectionArea))\n}\n\nextension Array where Element: Comparable {\n  /**\n    Returns the index and value of the largest element in the array.\n  */\n  public func argmax() -> (Int, Element) {\n    precondition(self.count > 0)\n    var maxIndex = 0\n    var maxValue = self[0]\n    for i in 1..<self.count {\n      if self[i] > maxValue {\n        maxValue = self[i]\n        maxIndex = i\n      }\n    }\n    return (maxIndex, maxValue)\n  }\n}\n\n/**\n  Logistic sigmoid.\n*/\npublic func sigmoid(_ x: Float) -> Float {\n  return 1 / (1 + exp(-x))\n}\n\n/**\n  Computes the \"softmax\" function over an array.\n\n  Based on code from https://github.com/nikolaypavlov/MLPNeuralNet/\n\n  This is what softmax looks like in \"pseudocode\" (actually using Python\n  and numpy):\n\n      x -= np.max(x)\n      exp_scores = np.exp(x)\n      softmax = exp_scores / np.sum(exp_scores)\n\n  First we shift the values of x so that the highest value in the array is 0.\n  This ensures numerical stability with the exponents, so they don't blow up.\n*/\npublic func softmax(_ x: [Float]) -> [Float] {\n  var x = x\n  let len = vDSP_Length(x.count)\n\n  // Find the maximum value in the input array.\n  var max: Float = 0\n  vDSP_maxv(x, 1, &max, len)\n\n  // Subtract the maximum from all the elements in the array.\n  // Now the highest value in the array is 0.\n  max = -max\n  vDSP_vsadd(x, 1, &max, &x, 1, len)\n\n  // Exponentiate all the elements in the array.\n  var count = Int32(x.count)\n  vvexpf(&x, x, &count)\n\n  // Compute the sum of all exponentiated values.\n  var sum: Float = 0\n  vDSP_sve(x, 1, &sum, len)\n\n  // Divide each element by the sum. This normalizes the array contents\n  // so that they all add up to 1.\n  vDSP_vsdiv(x, 1, &sum, &x, 1, len)\n\n  return x\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>$(DEVELOPMENT_LANGUAGE)</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n\t<key>LSRequiresIPhoneOS</key>\n\t<true/>\n\t<key>NSCameraUsageDescription</key>\n\t<string>Let's do some deep learning!</string>\n\t<key>UILaunchStoryboardName</key>\n\t<string>Main</string>\n\t<key>UIMainStoryboardFile</key>\n\t<string>Main</string>\n\t<key>UIRequiredDeviceCapabilities</key>\n\t<array>\n\t\t<string>armv7</string>\n\t</array>\n\t<key>UIRequiresFullScreen</key>\n\t<true/>\n\t<key>UIStatusBarStyle</key>\n\t<string>UIStatusBarStyleLightContent</string>\n\t<key>UISupportedInterfaceOrientations</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations~ipad</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/UIImage+CVPixelBuffer.swift",
    "content": "import UIKit\n\nextension UIImage {\n  public func pixelBuffer(width: Int, height: Int) -> CVPixelBuffer? {\n    var maybePixelBuffer: CVPixelBuffer?\n    let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue,\n                 kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue]\n    let status = CVPixelBufferCreate(kCFAllocatorDefault,\n                                     Int(width),\n                                     Int(height),\n                                     kCVPixelFormatType_32ARGB,\n                                     attrs as CFDictionary,\n                                     &maybePixelBuffer)\n\n    guard status == kCVReturnSuccess, let pixelBuffer = maybePixelBuffer else {\n      return nil\n    }\n\n    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: 0))\n    let pixelData = CVPixelBufferGetBaseAddress(pixelBuffer)\n\n    guard let context = CGContext(data: pixelData,\n                                  width: Int(width),\n                                  height: Int(height),\n                                  bitsPerComponent: 8,\n                                  bytesPerRow: CVPixelBufferGetBytesPerRow(pixelBuffer),\n                                  space: CGColorSpaceCreateDeviceRGB(),\n                                  bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue)\n    else {\n      return nil\n    }\n\n    context.translateBy(x: 0, y: CGFloat(height))\n    context.scaleBy(x: 1, y: -1)\n\n    UIGraphicsPushContext(context)\n    self.draw(in: CGRect(x: 0, y: 0, width: width, height: height))\n    UIGraphicsPopContext()\n    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: 0))\n\n    return pixelBuffer\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/VideoCapture.swift",
    "content": "import UIKit\nimport AVFoundation\nimport CoreVideo\n\npublic protocol VideoCaptureDelegate: class {\n  func videoCapture(_ capture: VideoCapture, didCaptureVideoFrame: CVPixelBuffer?, timestamp: CMTime)\n}\n\npublic class VideoCapture: NSObject {\n  public var previewLayer: AVCaptureVideoPreviewLayer?\n  public weak var delegate: VideoCaptureDelegate?\n  public var fps = 15\n\n  let captureSession = AVCaptureSession()\n  let videoOutput = AVCaptureVideoDataOutput()\n  let queue = DispatchQueue(label: \"net.machinethink.camera-queue\")\n\n  var lastTimestamp = CMTime()\n\n  public func setUp(sessionPreset: AVCaptureSession.Preset = .medium,\n                    completion: @escaping (Bool) -> Void) {\n    queue.async {\n      let success = self.setUpCamera(sessionPreset: sessionPreset)\n      DispatchQueue.main.async {\n        completion(success)\n      }\n    }\n  }\n\n  func setUpCamera(sessionPreset: AVCaptureSession.Preset) -> Bool {\n    captureSession.beginConfiguration()\n    captureSession.sessionPreset = sessionPreset\n\n    guard let captureDevice = AVCaptureDevice.default(for: AVMediaType.video) else {\n      print(\"Error: no video devices available\")\n      return false\n    }\n\n    guard let videoInput = try? AVCaptureDeviceInput(device: captureDevice) else {\n      print(\"Error: could not create AVCaptureDeviceInput\")\n      return false\n    }\n\n    if captureSession.canAddInput(videoInput) {\n      captureSession.addInput(videoInput)\n    }\n\n    let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)\n    previewLayer.videoGravity = AVLayerVideoGravity.resizeAspect\n    previewLayer.connection?.videoOrientation = .portrait\n    self.previewLayer = previewLayer\n\n    let settings: [String : Any] = [\n      kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32BGRA),\n    ]\n\n    videoOutput.videoSettings = settings\n    videoOutput.alwaysDiscardsLateVideoFrames = true\n    videoOutput.setSampleBufferDelegate(self, queue: queue)\n    if captureSession.canAddOutput(videoOutput) {\n      captureSession.addOutput(videoOutput)\n    }\n\n    // We want the buffers to be in portrait orientation otherwise they are\n    // rotated by 90 degrees. Need to set this _after_ addOutput()!\n    videoOutput.connection(with: AVMediaType.video)?.videoOrientation = .portrait\n\n    captureSession.commitConfiguration()\n    return true\n  }\n\n  public func start() {\n    if !captureSession.isRunning {\n      captureSession.startRunning()\n    }\n  }\n\n  public func stop() {\n    if captureSession.isRunning {\n      captureSession.stopRunning()\n    }\n  }\n}\n\nextension VideoCapture: AVCaptureVideoDataOutputSampleBufferDelegate {\n  public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {\n    // Because lowering the capture device's FPS looks ugly in the preview,\n    // we capture at full speed but only call the delegate at its desired\n    // framerate.\n    let timestamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)\n    let deltaTime = timestamp - lastTimestamp\n    if deltaTime >= CMTimeMake(1, Int32(fps)) {\n      lastTimestamp = timestamp\n      let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)\n      delegate?.videoCapture(self, didCaptureVideoFrame: imageBuffer, timestamp: timestamp)\n    }\n  }\n\n  public func captureOutput(_ output: AVCaptureOutput, didDrop sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {\n    //print(\"dropped frame\")\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/ViewController.swift",
    "content": "import UIKit\nimport Vision\nimport AVFoundation\nimport CoreMedia\nimport VideoToolbox\n\nclass ViewController: UIViewController {\n  @IBOutlet weak var videoPreview: UIView!\n  @IBOutlet weak var timeLabel: UILabel!\n  @IBOutlet weak var debugImageView: UIImageView!\n\n  let yolo = YOLO()\n\n  var videoCapture: VideoCapture!\n  var request: VNCoreMLRequest!\n  var startTimes: [CFTimeInterval] = []\n\n  var boundingBoxes = [BoundingBox]()\n  var colors: [UIColor] = []\n\n  let ciContext = CIContext()\n  var resizedPixelBuffer: CVPixelBuffer?\n\n  var framesDone = 0\n  var frameCapturingStartTime = CACurrentMediaTime()\n  let semaphore = DispatchSemaphore(value: 2)\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n\n    timeLabel.text = \"\"\n\n    setUpBoundingBoxes()\n    setUpCoreImage()\n    setUpVision()\n    setUpCamera()\n\n    frameCapturingStartTime = CACurrentMediaTime()\n  }\n\n  override func didReceiveMemoryWarning() {\n    super.didReceiveMemoryWarning()\n    print(#function)\n  }\n\n  // MARK: - Initialization\n\n  func setUpBoundingBoxes() {\n    for _ in 0..<YOLO.maxBoundingBoxes {\n      boundingBoxes.append(BoundingBox())\n    }\n\n    // Make colors for the bounding boxes. There is one color for each class,\n    // 80 classes in total.\n    for r: CGFloat in [0.2, 0.4, 0.6, 0.8, 1.0] {\n      for g: CGFloat in [0.3, 0.7, 0.6, 0.8] {\n        for b: CGFloat in [0.4, 0.8, 0.6, 1.0] {\n          let color = UIColor(red: r, green: g, blue: b, alpha: 1)\n          colors.append(color)\n        }\n      }\n    }\n  }\n\n  func setUpCoreImage() {\n    let status = CVPixelBufferCreate(nil, YOLO.inputWidth, YOLO.inputHeight,\n                                     kCVPixelFormatType_32BGRA, nil,\n                                     &resizedPixelBuffer)\n    if status != kCVReturnSuccess {\n      print(\"Error: could not create resized pixel buffer\", status)\n    }\n  }\n\n  func setUpVision() {\n    guard let visionModel = try? VNCoreMLModel(for: yolo.model.model) else {\n      print(\"Error: could not create Vision model\")\n      return\n    }\n\n    request = VNCoreMLRequest(model: visionModel, completionHandler: visionRequestDidComplete)\n\n    // NOTE: If you choose another crop/scale option, then you must also\n    // change how the BoundingBox objects get scaled when they are drawn.\n    // Currently they assume the full input image is used.\n    request.imageCropAndScaleOption = .scaleFill\n  }\n\n  func setUpCamera() {\n    videoCapture = VideoCapture()\n    videoCapture.delegate = self\n    videoCapture.fps = 50\n    videoCapture.setUp(sessionPreset: AVCaptureSession.Preset.vga640x480) { success in\n      if success {\n        // Add the video preview into the UI.\n        if let previewLayer = self.videoCapture.previewLayer {\n          self.videoPreview.layer.addSublayer(previewLayer)\n          self.resizePreviewLayer()\n        }\n\n        // Add the bounding box layers to the UI, on top of the video preview.\n        for box in self.boundingBoxes {\n          box.addToLayer(self.videoPreview.layer)\n        }\n\n        // Once everything is set up, we can start capturing live video.\n        self.videoCapture.start()\n      }\n    }\n  }\n\n  // MARK: - UI stuff\n\n  override func viewWillLayoutSubviews() {\n    super.viewWillLayoutSubviews()\n    resizePreviewLayer()\n  }\n\n  override var preferredStatusBarStyle: UIStatusBarStyle {\n    return .lightContent\n  }\n\n  func resizePreviewLayer() {\n    videoCapture.previewLayer?.frame = videoPreview.bounds\n  }\n\n  // MARK: - Doing inference\n\n  func predict(image: UIImage) {\n    if let pixelBuffer = image.pixelBuffer(width: YOLO.inputWidth, height: YOLO.inputHeight) {\n      predict(pixelBuffer: pixelBuffer)\n    }\n  }\n\n  func predict(pixelBuffer: CVPixelBuffer) {\n    // Measure how long it takes to predict a single video frame.\n    let startTime = CACurrentMediaTime()\n\n    // Resize the input with Core Image to 416x416.\n    guard let resizedPixelBuffer = resizedPixelBuffer else { return }\n    let ciImage = CIImage(cvPixelBuffer: pixelBuffer)\n    let sx = CGFloat(YOLO.inputWidth) / CGFloat(CVPixelBufferGetWidth(pixelBuffer))\n    let sy = CGFloat(YOLO.inputHeight) / CGFloat(CVPixelBufferGetHeight(pixelBuffer))\n    let scaleTransform = CGAffineTransform(scaleX: sx, y: sy)\n    let scaledImage = ciImage.transformed(by: scaleTransform)\n    ciContext.render(scaledImage, to: resizedPixelBuffer)\n\n    // This is an alternative way to resize the image (using vImage):\n    //if let resizedPixelBuffer = resizePixelBuffer(pixelBuffer,\n    //                                              width: YOLO.inputWidth,\n    //                                              height: YOLO.inputHeight)\n\n    // Resize the input to 416x416 and give it to our model.\n    if let boundingBoxes = try? yolo.predict(image: resizedPixelBuffer) {\n      let elapsed = CACurrentMediaTime() - startTime\n      showOnMainThread(boundingBoxes, elapsed)\n    }\n  }\n\n  func predictUsingVision(pixelBuffer: CVPixelBuffer) {\n    // Measure how long it takes to predict a single video frame. Note that\n    // predict() can be called on the next frame while the previous one is\n    // still being processed. Hence the need to queue up the start times.\n    startTimes.append(CACurrentMediaTime())\n\n    // Vision will automatically resize the input image.\n    let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer)\n    try? handler.perform([request])\n  }\n\n  func visionRequestDidComplete(request: VNRequest, error: Error?) {\n    if let observations = request.results as? [VNCoreMLFeatureValueObservation],\n       let features = observations.first?.featureValue.multiArrayValue {\n\n        let boundingBoxes = yolo.computeBoundingBoxes(features: [features, features, features])\n      let elapsed = CACurrentMediaTime() - startTimes.remove(at: 0)\n      showOnMainThread(boundingBoxes, elapsed)\n    }\n  }\n\n  func showOnMainThread(_ boundingBoxes: [YOLO.Prediction], _ elapsed: CFTimeInterval) {\n    DispatchQueue.main.async {\n      // For debugging, to make sure the resized CVPixelBuffer is correct.\n      //var debugImage: CGImage?\n      //VTCreateCGImageFromCVPixelBuffer(resizedPixelBuffer, nil, &debugImage)\n      //self.debugImageView.image = UIImage(cgImage: debugImage!)\n\n      self.show(predictions: boundingBoxes)\n\n      let fps = self.measureFPS()\n      self.timeLabel.text = String(format: \"Elapsed %.5f seconds - %.2f FPS\", elapsed, fps)\n\n      self.semaphore.signal()\n    }\n  }\n\n  func measureFPS() -> Double {\n    // Measure how many frames were actually delivered per second.\n    framesDone += 1\n    let frameCapturingElapsed = CACurrentMediaTime() - frameCapturingStartTime\n    let currentFPSDelivered = Double(framesDone) / frameCapturingElapsed\n    if frameCapturingElapsed > 1 {\n      framesDone = 0\n      frameCapturingStartTime = CACurrentMediaTime()\n    }\n    return currentFPSDelivered\n  }\n\n  func show(predictions: [YOLO.Prediction]) {\n    for i in 0..<boundingBoxes.count {\n      if i < predictions.count {\n        let prediction = predictions[i]\n\n        // The predicted bounding box is in the coordinate space of the input\n        // image, which is a square image of 416x416 pixels. We want to show it\n        // on the video preview, which is as wide as the screen and has a 4:3\n        // aspect ratio. The video preview also may be letterboxed at the top\n        // and bottom.\n        let width = view.bounds.width\n        let height = width * 4 / 3\n        let scaleX = width / CGFloat(YOLO.inputWidth)\n        let scaleY = height / CGFloat(YOLO.inputHeight)\n        let top = (view.bounds.height - height) / 2\n\n        // Translate and scale the rectangle to our own coordinate system.\n        var rect = prediction.rect\n        rect.origin.x *= scaleX\n        rect.origin.y *= scaleY\n        rect.origin.y += top\n        rect.size.width *= scaleX\n        rect.size.height *= scaleY\n\n        // Show the bounding box.\n        let label = String(format: \"%@ %.1f\", labels[prediction.classIndex], prediction.score * 100)\n        let color = colors[prediction.classIndex]\n        boundingBoxes[i].show(frame: rect, label: label, color: color)\n      } else {\n        boundingBoxes[i].hide()\n      }\n    }\n  }\n}\n\nextension ViewController: VideoCaptureDelegate {\n  func videoCapture(_ capture: VideoCapture, didCaptureVideoFrame pixelBuffer: CVPixelBuffer?, timestamp: CMTime) {\n    // For debugging.\n    //predict(image: UIImage(named: \"dog416\")!); return\n\n    semaphore.wait()\n\n    if let pixelBuffer = pixelBuffer {\n      // For better throughput, perform the prediction on a background queue\n      // instead of on the VideoCapture queue. We use the semaphore to block\n      // the capture queue and drop frames when Core ML can't keep up.\n      DispatchQueue.global().async {\n        self.predict(pixelBuffer: pixelBuffer)\n        //self.predictUsingVision(pixelBuffer: pixelBuffer)\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML/YOLO.swift",
    "content": "import Foundation\nimport UIKit\nimport CoreML\n\nclass YOLO {\n  public static let inputWidth = 416\n  public static let inputHeight = 416\n  public static let maxBoundingBoxes = 10\n\n  // Tweak these values to get more or fewer predictions.\n  let confidenceThreshold: Float = 0.6\n  let iouThreshold: Float = 0.5\n\n  struct Prediction {\n    let classIndex: Int\n    let score: Float\n    let rect: CGRect\n  }\n\n  let model = YOLOv3()\n\n  public init() { }\n\n  public func predict(image: CVPixelBuffer) throws -> [Prediction] {\n    if let output = try? model.prediction(input1: image) {\n      return computeBoundingBoxes(features: [output.output1, output.output2, output.output3])\n    } else {\n      return []\n    }\n  }\n\n  public func computeBoundingBoxes(features: [MLMultiArray]) -> [Prediction] {\n    assert(features[0].count == 255*13*13)\n    assert(features[1].count == 255*26*26)\n    assert(features[2].count == 255*52*52)\n\n    var predictions = [Prediction]()\n\n    let blockSize: Float = 32\n    let boxesPerCell = 3\n    let numClasses = 80\n\n    // The 416x416 image is divided into a 13x13 grid. Each of these grid cells\n    // will predict 5 bounding boxes (boxesPerCell). A bounding box consists of\n    // five data items: x, y, width, height, and a confidence score. Each grid\n    // cell also predicts which class each bounding box belongs to.\n    //\n    // The \"features\" array therefore contains (numClasses + 5)*boxesPerCell\n    // values for each grid cell, i.e. 125 channels. The total features array\n    // contains 255x13x13 elements.\n\n    // NOTE: It turns out that accessing the elements in the multi-array as\n    // `features[[channel, cy, cx] as [NSNumber]].floatValue` is kinda slow.\n    // It's much faster to use direct memory access to the features.\n    var gridHeight = [13, 26, 52]\n    var gridWidth = [13, 26, 52]\n    \n    var featurePointer = UnsafeMutablePointer<Double>(OpaquePointer(features[0].dataPointer))\n    var channelStride = features[0].strides[0].intValue\n    var yStride = features[0].strides[1].intValue\n    var xStride = features[0].strides[2].intValue\n\n    func offset(_ channel: Int, _ x: Int, _ y: Int) -> Int {\n      return channel*channelStride + y*yStride + x*xStride\n    }\n\n    for i in 0..<3 {\n        featurePointer = UnsafeMutablePointer<Double>(OpaquePointer(features[i].dataPointer))\n        channelStride = features[i].strides[0].intValue\n        yStride = features[i].strides[1].intValue\n        xStride = features[i].strides[2].intValue\n        for cy in 0..<gridHeight[i] {\n            for cx in 0..<gridWidth[i] {\n                for b in 0..<boxesPerCell {\n                    // For the first bounding box (b=0) we have to read channels 0-24,\n                    // for b=1 we have to read channels 25-49, and so on.\n                    let channel = b*(numClasses + 5)\n                    \n                    // The fast way:\n                    let tx = Float(featurePointer[offset(channel    , cx, cy)])\n                    let ty = Float(featurePointer[offset(channel + 1, cx, cy)])\n                    let tw = Float(featurePointer[offset(channel + 2, cx, cy)])\n                    let th = Float(featurePointer[offset(channel + 3, cx, cy)])\n                    let tc = Float(featurePointer[offset(channel + 4, cx, cy)])\n                    \n                    // The predicted tx and ty coordinates are relative to the location\n                    // of the grid cell; we use the logistic sigmoid to constrain these\n                    // coordinates to the range 0 - 1. Then we add the cell coordinates\n                    // (0-12) and multiply by the number of pixels per grid cell (32).\n                    // Now x and y represent center of the bounding box in the original\n                    // 416x416 image space.\n                    let scale = powf(2.0,Float(i)) // scale pos by 2^i where i is the scale pyramid level\n                    let x = (Float(cx) * blockSize + sigmoid(tx))/scale\n                    let y = (Float(cy) * blockSize + sigmoid(ty))/scale\n                    \n                    // The size of the bounding box, tw and th, is predicted relative to\n                    // the size of an \"anchor\" box. Here we also transform the width and\n                    // height into the original 416x416 image space.\n                    let w = exp(tw) * anchors[i][2*b    ]\n                    let h = exp(th) * anchors[i][2*b + 1]\n                    \n                    // The confidence value for the bounding box is given by tc. We use\n                    // the logistic sigmoid to turn this into a percentage.\n                    let confidence = sigmoid(tc)\n                    \n                    // Gather the predicted classes for this anchor box and softmax them,\n                    // so we can interpret these numbers as percentages.\n                    var classes = [Float](repeating: 0, count: numClasses)\n                    for c in 0..<numClasses {\n                        // The slow way:\n                        //classes[c] = features[[channel + 5 + c, cy, cx] as [NSNumber]].floatValue\n                        \n                        // The fast way:\n                        classes[c] = Float(featurePointer[offset(channel + 5 + c, cx, cy)])\n                    }\n                    classes = softmax(classes)\n                    \n                    // Find the index of the class with the largest score.\n                    let (detectedClass, bestClassScore) = classes.argmax()\n                    \n                    // Combine the confidence score for the bounding box, which tells us\n                    // how likely it is that there is an object in this box (but not what\n                    // kind of object it is), with the largest class prediction, which\n                    // tells us what kind of object it detected (but not where).\n                    let confidenceInClass = bestClassScore * confidence\n                    \n                    // Since we compute 13x13x3 = 507 bounding boxes, we only want to\n                    // keep the ones whose combined score is over a certain threshold.\n                    if confidenceInClass > confidenceThreshold {\n                        let rect = CGRect(x: CGFloat(x - w/2), y: CGFloat(y - h/2),\n                                          width: CGFloat(w), height: CGFloat(h))\n                        \n                        let prediction = Prediction(classIndex: detectedClass,\n                                                    score: confidenceInClass,\n                                                    rect: rect)\n                        predictions.append(prediction)\n                    }\n                }\n            }\n        }\n    }\n\n    // We already filtered out any bounding boxes that have very low scores,\n    // but there still may be boxes that overlap too much with others. We'll\n    // use \"non-maximum suppression\" to prune those duplicate bounding boxes.\n    return nonMaxSuppression(boxes: predictions, limit: YOLO.maxBoundingBoxes, threshold: iouThreshold)\n  }\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 48;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t372CB262209C9B0F00F501E3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372CB261209C9B0F00F501E3 /* AppDelegate.swift */; };\n\t\t372CB265209C9B2600F501E3 /* BoundingBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372CB263209C9B2600F501E3 /* BoundingBox.swift */; };\n\t\t372CB266209C9B2600F501E3 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372CB264209C9B2600F501E3 /* Helpers.swift */; };\n\t\t7BA1C6D01EF27DA000BB25EF /* VideoCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC25FB51EF27C0D002ECBBA /* VideoCapture.swift */; };\n\t\t7BA1C6D21EF2827800BB25EF /* UIImage+CVPixelBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA1C6D11EF2827500BB25EF /* UIImage+CVPixelBuffer.swift */; };\n\t\t7BA1C6D81EF2871600BB25EF /* YOLO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA1C6D71EF2871600BB25EF /* YOLO.swift */; };\n\t\t7BA1C6DA1EF2B30200BB25EF /* CVPixelBuffer+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA1C6D91EF2B30200BB25EF /* CVPixelBuffer+Helpers.swift */; };\n\t\t7BC25FA41EF1B7D1002ECBBA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC25FA31EF1B7D1002ECBBA /* ViewController.swift */; };\n\t\t7BC25FA71EF1B7D1002ECBBA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7BC25FA51EF1B7D1002ECBBA /* Main.storyboard */; };\n\t\t7BC25FA91EF1B7D1002ECBBA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7BC25FA81EF1B7D1002ECBBA /* Assets.xcassets */; };\n\t\t7BC25FB41EF1CEB0002ECBBA /* YOLOv3.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = 7BC25FB31EF1CEAE002ECBBA /* YOLOv3.mlmodel */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXFileReference section */\n\t\t372CB261209C9B0F00F501E3 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = \"<group>\"; };\n\t\t372CB263209C9B2600F501E3 /* BoundingBox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoundingBox.swift; sourceTree = \"<group>\"; };\n\t\t372CB264209C9B2600F501E3 /* Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = \"<group>\"; };\n\t\t7BA1C6D11EF2827500BB25EF /* UIImage+CVPixelBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"UIImage+CVPixelBuffer.swift\"; sourceTree = \"<group>\"; };\n\t\t7BA1C6D71EF2871600BB25EF /* YOLO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YOLO.swift; sourceTree = \"<group>\"; };\n\t\t7BA1C6D91EF2B30200BB25EF /* CVPixelBuffer+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"CVPixelBuffer+Helpers.swift\"; sourceTree = \"<group>\"; };\n\t\t7BC25F9E1EF1B7D1002ECBBA /* YOLOv3-CoreML.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"YOLOv3-CoreML.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t7BC25FA31EF1B7D1002ECBBA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = \"<group>\"; };\n\t\t7BC25FA61EF1B7D1002ECBBA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = \"<group>\"; };\n\t\t7BC25FA81EF1B7D1002ECBBA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = \"<group>\"; };\n\t\t7BC25FAD1EF1B7D1002ECBBA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t7BC25FB31EF1CEAE002ECBBA /* YOLOv3.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; path = YOLOv3.mlmodel; sourceTree = \"<group>\"; };\n\t\t7BC25FB51EF27C0D002ECBBA /* VideoCapture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoCapture.swift; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t7BC25F9B1EF1B7D1002ECBBA /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t7BC25F951EF1B7D1002ECBBA = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7BC25FA01EF1B7D1002ECBBA /* YOLOv3-CoreML */,\n\t\t\t\t7BC25F9F1EF1B7D1002ECBBA /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7BC25F9F1EF1B7D1002ECBBA /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7BC25F9E1EF1B7D1002ECBBA /* YOLOv3-CoreML.app */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7BC25FA01EF1B7D1002ECBBA /* YOLOv3-CoreML */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t372CB263209C9B2600F501E3 /* BoundingBox.swift */,\n\t\t\t\t372CB264209C9B2600F501E3 /* Helpers.swift */,\n\t\t\t\t372CB261209C9B0F00F501E3 /* AppDelegate.swift */,\n\t\t\t\t7BC25FA81EF1B7D1002ECBBA /* Assets.xcassets */,\n\t\t\t\t7BA1C6D91EF2B30200BB25EF /* CVPixelBuffer+Helpers.swift */,\n\t\t\t\t7BC25FAD1EF1B7D1002ECBBA /* Info.plist */,\n\t\t\t\t7BC25FA51EF1B7D1002ECBBA /* Main.storyboard */,\n\t\t\t\t7BC25FB31EF1CEAE002ECBBA /* YOLOv3.mlmodel */,\n\t\t\t\t7BA1C6D11EF2827500BB25EF /* UIImage+CVPixelBuffer.swift */,\n\t\t\t\t7BC25FB51EF27C0D002ECBBA /* VideoCapture.swift */,\n\t\t\t\t7BC25FA31EF1B7D1002ECBBA /* ViewController.swift */,\n\t\t\t\t7BA1C6D71EF2871600BB25EF /* YOLO.swift */,\n\t\t\t);\n\t\t\tpath = \"YOLOv3-CoreML\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\t7BC25F9D1EF1B7D1002ECBBA /* YOLOv3-CoreML */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 7BC25FB01EF1B7D1002ECBBA /* Build configuration list for PBXNativeTarget \"YOLOv3-CoreML\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t7BC25F9A1EF1B7D1002ECBBA /* Sources */,\n\t\t\t\t7BC25F9B1EF1B7D1002ECBBA /* Frameworks */,\n\t\t\t\t7BC25F9C1EF1B7D1002ECBBA /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"YOLOv3-CoreML\";\n\t\t\tproductName = \"YOLOv3-CoreML\";\n\t\t\tproductReference = 7BC25F9E1EF1B7D1002ECBBA /* YOLOv3-CoreML.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t7BC25F961EF1B7D1002ECBBA /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastSwiftUpdateCheck = 0900;\n\t\t\t\tLastUpgradeCheck = 0900;\n\t\t\t\tORGANIZATIONNAME = MachineThink;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t7BC25F9D1EF1B7D1002ECBBA = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 9.0;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 7BC25F991EF1B7D1002ECBBA /* Build configuration list for PBXProject \"YOLOv3-CoreML\" */;\n\t\t\tcompatibilityVersion = \"Xcode 8.0\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 7BC25F951EF1B7D1002ECBBA;\n\t\t\tproductRefGroup = 7BC25F9F1EF1B7D1002ECBBA /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t7BC25F9D1EF1B7D1002ECBBA /* YOLOv3-CoreML */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t7BC25F9C1EF1B7D1002ECBBA /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7BC25FA91EF1B7D1002ECBBA /* Assets.xcassets in Resources */,\n\t\t\t\t7BC25FA71EF1B7D1002ECBBA /* Main.storyboard in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t7BC25F9A1EF1B7D1002ECBBA /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7BA1C6D01EF27DA000BB25EF /* VideoCapture.swift in Sources */,\n\t\t\t\t7BA1C6DA1EF2B30200BB25EF /* CVPixelBuffer+Helpers.swift in Sources */,\n\t\t\t\t7BC25FB41EF1CEB0002ECBBA /* YOLOv3.mlmodel in Sources */,\n\t\t\t\t372CB265209C9B2600F501E3 /* BoundingBox.swift in Sources */,\n\t\t\t\t372CB266209C9B2600F501E3 /* Helpers.swift in Sources */,\n\t\t\t\t372CB262209C9B0F00F501E3 /* AppDelegate.swift in Sources */,\n\t\t\t\t7BA1C6D21EF2827800BB25EF /* UIImage+CVPixelBuffer.swift in Sources */,\n\t\t\t\t7BC25FA41EF1B7D1002ECBBA /* ViewController.swift in Sources */,\n\t\t\t\t7BA1C6D81EF2871600BB25EF /* YOLO.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXVariantGroup section */\n\t\t7BC25FA51EF1B7D1002ECBBA /* Main.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\t7BC25FA61EF1B7D1002ECBBA /* Base */,\n\t\t\t);\n\t\t\tname = Main.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXVariantGroup section */\n\n/* Begin XCBuildConfiguration section */\n\t\t7BC25FAE1EF1B7D1002ECBBA /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 11.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7BC25FAF1EF1B7D1002ECBBA /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 11.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t7BC25FB11EF1B7D1002ECBBA /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer: 1067837450@qq.com (EA34W5QFTF)\";\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = LXGRKDMEQU;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = s;\n\t\t\t\tINFOPLIST_FILE = \"YOLOv3-CoreML/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"net.machinethink.YOLOv3-CoreML\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7BC25FB21EF1B7D1002ECBBA /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer: 1067837450@qq.com (EA34W5QFTF)\";\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = LXGRKDMEQU;\n\t\t\t\tINFOPLIST_FILE = \"YOLOv3-CoreML/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"net.machinethink.YOLOv3-CoreML\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t7BC25F991EF1B7D1002ECBBA /* Build configuration list for PBXProject \"YOLOv3-CoreML\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7BC25FAE1EF1B7D1002ECBBA /* Debug */,\n\t\t\t\t7BC25FAF1EF1B7D1002ECBBA /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t7BC25FB01EF1B7D1002ECBBA /* Build configuration list for PBXNativeTarget \"YOLOv3-CoreML\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7BC25FB11EF1B7D1002ECBBA /* Debug */,\n\t\t\t\t7BC25FB21EF1B7D1002ECBBA /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 7BC25F961EF1B7D1002ECBBA /* Project object */;\n}\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:YOLOv3-CoreML.xcodeproj\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "YOLOv3-CoreML/YOLOv3-CoreML.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDEDidComputeMac32BitWarning</key>\n\t<true/>\n</dict>\n</plist>\n"
  }
]