Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Make some empty class and struct for interpretor #3

Merged
merged 4 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions PoseEstimation-TFLiteSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
7105C91D241CE9B6001A4325 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7105C91B241CE9B6001A4325 /* Main.storyboard */; };
7105C91F241CE9B7001A4325 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7105C91E241CE9B7001A4325 /* Assets.xcassets */; };
7105C922241CE9B7001A4325 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7105C920241CE9B7001A4325 /* LaunchScreen.storyboard */; };
7105C92F241D0235001A4325 /* PoseEstimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7105C92E241D0235001A4325 /* PoseEstimator.swift */; };
7105C933241D0651001A4325 /* TFLiteImageInterpretor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7105C932241D0651001A4325 /* TFLiteImageInterpretor.swift */; };
7105C935241D0821001A4325 /* PoseNetPoseEstimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7105C934241D0821001A4325 /* PoseNetPoseEstimator.swift */; };
E0C93A920161DEF82C2B75E0 /* Pods_PoseEstimation_TFLiteSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D99304E5824CB3ABF8752B4 /* Pods_PoseEstimation_TFLiteSwift.framework */; };
/* End PBXBuildFile section */

Expand All @@ -25,6 +28,9 @@
7105C91E241CE9B7001A4325 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7105C921241CE9B7001A4325 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7105C923241CE9B7001A4325 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7105C92E241D0235001A4325 /* PoseEstimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PoseEstimator.swift; sourceTree = "<group>"; };
7105C932241D0651001A4325 /* TFLiteImageInterpretor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TFLiteImageInterpretor.swift; sourceTree = "<group>"; };
7105C934241D0821001A4325 /* PoseNetPoseEstimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PoseNetPoseEstimator.swift; sourceTree = "<group>"; };
8C8112449130BEE4072F1385 /* Pods-PoseEstimation-TFLiteSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PoseEstimation-TFLiteSwift.release.xcconfig"; path = "Target Support Files/Pods-PoseEstimation-TFLiteSwift/Pods-PoseEstimation-TFLiteSwift.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -63,6 +69,12 @@
children = (
7105C915241CE9B5001A4325 /* AppDelegate.swift */,
7105C919241CE9B6001A4325 /* ViewController.swift */,
7105C934241D0821001A4325 /* PoseNetPoseEstimator.swift */,
7105C92E241D0235001A4325 /* PoseEstimator.swift */,
7105C932241D0651001A4325 /* TFLiteImageInterpretor.swift */,
7105C92B241D0150001A4325 /* MLModel */,
7105C92A241D0144001A4325 /* Extension */,
7105C929241D011F001A4325 /* View */,
7105C91B241CE9B6001A4325 /* Main.storyboard */,
7105C91E241CE9B7001A4325 /* Assets.xcassets */,
7105C920241CE9B7001A4325 /* LaunchScreen.storyboard */,
Expand All @@ -71,6 +83,27 @@
path = "PoseEstimation-TFLiteSwift";
sourceTree = "<group>";
};
7105C929241D011F001A4325 /* View */ = {
isa = PBXGroup;
children = (
);
name = View;
sourceTree = "<group>";
};
7105C92A241D0144001A4325 /* Extension */ = {
isa = PBXGroup;
children = (
);
name = Extension;
sourceTree = "<group>";
};
7105C92B241D0150001A4325 /* MLModel */ = {
isa = PBXGroup;
children = (
);
name = MLModel;
sourceTree = "<group>";
};
C0C61619494007101B3B8411 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -185,8 +218,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7105C933241D0651001A4325 /* TFLiteImageInterpretor.swift in Sources */,
7105C91A241CE9B6001A4325 /* ViewController.swift in Sources */,
7105C916241CE9B5001A4325 /* AppDelegate.swift in Sources */,
7105C92F241D0235001A4325 /* PoseEstimator.swift in Sources */,
7105C935241D0821001A4325 /* PoseNetPoseEstimator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
31 changes: 31 additions & 0 deletions PoseEstimation-TFLiteSwift/PoseEstimator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// PoseEstimator.swift
// PoseEstimation-TFLiteSwift
//
// Created by Doyoung Gwak on 2020/03/14.
// Copyright © 2020 Doyoung Gwak. All rights reserved.
//

import CoreVideo

struct PoseEstimationKeypoint {
let position: CGPoint
let score: CGFloat
}

struct PoseEstimationHeatmaps {
let keypoints: [PoseEstimationKeypoint]

init(tfliteResult: TFLiteResult) {
// <#TODO#>
keypoints = []
}
}

enum PoseEstimationError: Error {
case commonFail
}

protocol PoseEstimator {
func inference(with pixelBuffer: CVPixelBuffer) -> Result<PoseEstimationHeatmaps, PoseEstimationError>
}
18 changes: 18 additions & 0 deletions PoseEstimation-TFLiteSwift/PoseNetPoseEstimator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// PoseNetPoseEstimator.swift
// PoseEstimation-TFLiteSwift
//
// Created by Doyoung Gwak on 2020/03/14.
// Copyright © 2020 Doyoung Gwak. All rights reserved.
//

import CoreVideo

class PoseNetPoseEstimator: PoseEstimator {
let poseInterpretor = TFLiteImageInterpretor()

func inference(with pixelBuffer: CVPixelBuffer) -> Result<PoseEstimationHeatmaps, PoseEstimationError> {
guard let tfliteResult = poseInterpretor.predict(with: pixelBuffer) else { return .failure(.commonFail) }
return .success(PoseEstimationHeatmaps(tfliteResult: tfliteResult))
}
}
22 changes: 22 additions & 0 deletions PoseEstimation-TFLiteSwift/TFLiteImageInterpretor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// TFLiteImageInterpretor.swift
// PoseEstimation-TFLiteSwift
//
// Created by Doyoung Gwak on 2020/03/14.
// Copyright © 2020 Doyoung Gwak. All rights reserved.
//

import TensorFlowLite

struct TFLiteResult {
// <#TODO#>
}

class TFLiteImageInterpretor {
// <#TODO#>

func predict(with pixelBuffer: CVPixelBuffer) -> TFLiteResult? {
// <#TODO#>
return nil
}
}
5 changes: 2 additions & 3 deletions PoseEstimation-TFLiteSwift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import UIKit

class ViewController: UIViewController {

let poseEstimator: PoseEstimator = PoseNetPoseEstimator()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the mean of NetPose?

Copy link
Owner Author

@tucan9389 tucan9389 Mar 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PoseNet is the paper for pose estimation distributed in 2015. PoseNetPoseEstimator stand for PoseNet + PoseEstimator which means that the pose estimator implementing PoseNet tflite model.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank, I undetstood.


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}


}