Skip to content

Commit 3f4d8e8

Browse files
Atif ImranAtif Imran
authored andcommitted
ML sample using Inceptionv3.mlmodel
1 parent 4c3529f commit 3f4d8e8

File tree

7 files changed

+251
-14
lines changed

7 files changed

+251
-14
lines changed

MachineLearningSample-ObjC.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
BE2E22DB1F0F4FB400D92AA5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE2E22DA1F0F4FB400D92AA5 /* Assets.xcassets */; };
1414
BE2E22DE1F0F4FB400D92AA5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE2E22DC1F0F4FB400D92AA5 /* LaunchScreen.storyboard */; };
1515
BE2E22E11F0F4FB400D92AA5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE2E22E01F0F4FB400D92AA5 /* main.m */; };
16+
BE2E22E91F0F503E00D92AA5 /* Inceptionv3.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = BE2E22E81F0F503E00D92AA5 /* Inceptionv3.mlmodel */; };
17+
BE2E22EB1F0F505700D92AA5 /* camera.png in Resources */ = {isa = PBXBuildFile; fileRef = BE2E22EA1F0F505700D92AA5 /* camera.png */; };
1618
/* End PBXBuildFile section */
1719

1820
/* Begin PBXFileReference section */
@@ -26,6 +28,8 @@
2628
BE2E22DD1F0F4FB400D92AA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2729
BE2E22DF1F0F4FB400D92AA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2830
BE2E22E01F0F4FB400D92AA5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
31+
BE2E22E81F0F503E00D92AA5 /* Inceptionv3.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; name = Inceptionv3.mlmodel; path = ../../../../Downloads/Inceptionv3.mlmodel; sourceTree = "<group>"; };
32+
BE2E22EA1F0F505700D92AA5 /* camera.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = camera.png; path = "../../../../Downloads/SimpleInceptionV3-ObjC-master/Resources/camera.png"; sourceTree = "<group>"; };
2933
/* End PBXFileReference section */
3034

3135
/* Begin PBXFrameworksBuildPhase section */
@@ -58,6 +62,7 @@
5862
BE2E22D01F0F4FB300D92AA5 /* MachineLearningSample-ObjC */ = {
5963
isa = PBXGroup;
6064
children = (
65+
BE2E22E71F0F4FDC00D92AA5 /* Resources */,
6166
BE2E22D11F0F4FB300D92AA5 /* AppDelegate.h */,
6267
BE2E22D21F0F4FB400D92AA5 /* AppDelegate.m */,
6368
BE2E22D41F0F4FB400D92AA5 /* ViewController.h */,
@@ -71,6 +76,15 @@
7176
path = "MachineLearningSample-ObjC";
7277
sourceTree = "<group>";
7378
};
79+
BE2E22E71F0F4FDC00D92AA5 /* Resources */ = {
80+
isa = PBXGroup;
81+
children = (
82+
BE2E22EA1F0F505700D92AA5 /* camera.png */,
83+
BE2E22E81F0F503E00D92AA5 /* Inceptionv3.mlmodel */,
84+
);
85+
path = Resources;
86+
sourceTree = "<group>";
87+
};
7488
/* End PBXGroup section */
7589

7690
/* Begin PBXNativeTarget section */
@@ -130,6 +144,7 @@
130144
files = (
131145
BE2E22DE1F0F4FB400D92AA5 /* LaunchScreen.storyboard in Resources */,
132146
BE2E22DB1F0F4FB400D92AA5 /* Assets.xcassets in Resources */,
147+
BE2E22EB1F0F505700D92AA5 /* camera.png in Resources */,
133148
BE2E22D91F0F4FB400D92AA5 /* Main.storyboard in Resources */,
134149
);
135150
runOnlyForDeploymentPostprocessing = 0;
@@ -142,6 +157,7 @@
142157
buildActionMask = 2147483647;
143158
files = (
144159
BE2E22D61F0F4FB400D92AA5 /* ViewController.m in Sources */,
160+
BE2E22E91F0F503E00D92AA5 /* Inceptionv3.mlmodel in Sources */,
145161
BE2E22E11F0F4FB400D92AA5 /* main.m in Sources */,
146162
BE2E22D31F0F4FB400D92AA5 /* AppDelegate.m in Sources */,
147163
);
Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,97 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.19" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="mP4-pi-mGo">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.16"/>
58
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
69
</dependencies>
710
<scenes>
811
<!--View Controller-->
9-
<scene sceneID="tne-QT-ifu">
12+
<scene sceneID="aV4-dq-qBY">
1013
<objects>
11-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
14+
<viewController storyboardIdentifier="View" id="mP4-pi-mGo" customClass="ViewController" sceneMemberID="viewController">
1215
<layoutGuides>
13-
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
14-
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
16+
<viewControllerLayoutGuide type="top" id="Lbg-W7-AqD"/>
17+
<viewControllerLayoutGuide type="bottom" id="B4q-wq-cdu"/>
1518
</layoutGuides>
16-
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
19+
<view key="view" contentMode="scaleToFill" id="Oz2-a2-aCs">
1720
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1821
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
22+
<subviews>
23+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="A8A-FB-Ozy">
24+
<rect key="frame" x="16" y="99" width="343" height="283"/>
25+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
26+
</imageView>
27+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vNG-fv-eZI">
28+
<rect key="frame" x="67" y="20" width="240" height="37"/>
29+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
30+
<string key="text" base64-UTF8="YES">
31+
EBBNYWNoaW5lIExlYXJuaW5nIFNhbXBsZSBVc2luZyBJbmNlcHRpb252My5tbG1vZGVsA
32+
</string>
33+
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="12"/>
34+
<color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
35+
<nil key="highlightedColor"/>
36+
</label>
37+
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="N36-qw-4cr">
38+
<rect key="frame" x="16" y="390" width="343" height="200"/>
39+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
40+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
41+
<connections>
42+
<outlet property="dataSource" destination="mP4-pi-mGo" id="xIa-cM-oMX"/>
43+
<outlet property="delegate" destination="mP4-pi-mGo" id="bFw-hs-y73"/>
44+
</connections>
45+
</tableView>
46+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ker-cG-xSl">
47+
<rect key="frame" x="16" y="617" width="30" height="30"/>
48+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
49+
<state key="normal" image="camera.png"/>
50+
<connections>
51+
<action selector="useCamera:" destination="mP4-pi-mGo" eventType="touchUpInside" id="e3b-ED-rAR"/>
52+
</connections>
53+
</button>
54+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZKe-Pz-GTa">
55+
<rect key="frame" x="288" y="617" width="71" height="30"/>
56+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
57+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
58+
<state key="normal" title="GALLERY">
59+
<color key="titleColor" red="1" green="0.0" blue="0.36078431370000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
60+
</state>
61+
<connections>
62+
<action selector="useGallery:" destination="mP4-pi-mGo" eventType="touchUpInside" id="QhR-A6-3cn"/>
63+
</connections>
64+
</button>
65+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Result will appear here" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NVs-Fw-qS8">
66+
<rect key="frame" x="16" y="70" width="343" height="21"/>
67+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
68+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
69+
<color key="textColor" red="1" green="0.0" blue="0.13422691989999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
70+
<nil key="highlightedColor"/>
71+
</label>
72+
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" hidesWhenStopped="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Ng9-VQ-AHJ">
73+
<rect key="frame" x="177" y="622" width="20" height="20"/>
74+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
75+
<color key="color" red="1" green="0.0" blue="0.13422691989999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
76+
</activityIndicatorView>
77+
</subviews>
78+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2079
</view>
80+
<toolbarItems/>
81+
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
82+
<connections>
83+
<outlet property="progressView" destination="Ng9-VQ-AHJ" id="y34-uN-eJk"/>
84+
<outlet property="resultLabel" destination="NVs-Fw-qS8" id="FQk-0P-7wX"/>
85+
<outlet property="resultsTableView" destination="N36-qw-4cr" id="8Lu-Nr-7mf"/>
86+
<outlet property="sourceImgView" destination="A8A-FB-Ozy" id="fu0-ca-xbm"/>
87+
</connections>
2188
</viewController>
22-
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
89+
<placeholder placeholderIdentifier="IBFirstResponder" id="63X-ju-ksZ" userLabel="First Responder" sceneMemberID="firstResponder"/>
2390
</objects>
91+
<point key="canvasLocation" x="4" y="124"/>
2492
</scene>
2593
</scenes>
94+
<resources>
95+
<image name="camera.png" width="64" height="64"/>
96+
</resources>
2697
</document>

MachineLearningSample-ObjC/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<string>LaunchScreen</string>
2525
<key>UIMainStoryboardFile</key>
2626
<string>Main</string>
27+
<key>NSCameraUsageDescription</key>
28+
<string>capture image for processing</string>
2729
<key>UIRequiredDeviceCapabilities</key>
2830
<array>
2931
<string>armv7</string>
90.3 MB
Binary file not shown.
1.6 KB
Loading

MachineLearningSample-ObjC/ViewController.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88

99
#import <UIKit/UIKit.h>
1010

11-
@interface ViewController : UIViewController
11+
@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource>
12+
@property (nonatomic) unsigned long resultsCount;
13+
@property (retain, nonatomic) NSArray *results;
1214

15+
@property (weak, nonatomic) IBOutlet UIImageView *sourceImgView;
16+
@property (weak, nonatomic) IBOutlet UILabel *resultLabel;
17+
@property (weak, nonatomic) IBOutlet UITableView *resultsTableView;
18+
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *progressView;
19+
20+
- (IBAction)useCamera:(id)sender;
21+
- (IBAction)useGallery:(id)sender;
1322

1423
@end
1524

0 commit comments

Comments
 (0)