Skip to content

Commit 0370bd2

Browse files
authored
Add saliency functionality to performance [SwiftUI] (#1257)
* Fix upload bug * Add saliency map functionality * Add saliency map UI tests * Clarify process status * Create ProcessDerivatives * Use ProcessDerivatives within UI tests * Update README.md
1 parent cedd972 commit 0370bd2

File tree

10 files changed

+425
-123
lines changed

10 files changed

+425
-123
lines changed

performance/SwiftUIPerformanceQuickstart/PerformanceExample/PerformanceExample.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
41BFA1EC26B1D3730013EB90 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4102055826A631F5004B24B3 /* Assets.xcassets */; };
3232
41BFA1F026B1D8B80013EB90 /* Process.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41BFA1EF26B1D8B80013EB90 /* Process.swift */; };
3333
41BFA1F326B1D8B80013EB90 /* Process.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41BFA1EF26B1D8B80013EB90 /* Process.swift */; };
34+
41C3EC0D26D0100F009DCA8B /* SaliencyMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC0C26D0100F009DCA8B /* SaliencyMapView.swift */; };
35+
41C3EC0E26D0100F009DCA8B /* SaliencyMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC0C26D0100F009DCA8B /* SaliencyMapView.swift */; };
36+
41C3EC1226D05538009DCA8B /* ProcessDerivatives.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */; };
37+
41C3EC1326D05538009DCA8B /* ProcessDerivatives.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */; };
38+
41C3EC1426D05538009DCA8B /* ProcessDerivatives.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */; };
39+
41C3EC1526D05538009DCA8B /* ProcessDerivatives.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */; };
3440
/* End PBXBuildFile section */
3541

3642
/* Begin PBXContainerItemProxy section */
@@ -66,6 +72,8 @@
6672
419700EC26C30DA500F186C3 /* UITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITests.swift; sourceTree = "<group>"; };
6773
419AADCD26B86A94005C4817 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../GoogleService-Info.plist"; sourceTree = "<group>"; };
6874
41BFA1EF26B1D8B80013EB90 /* Process.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Process.swift; sourceTree = "<group>"; };
75+
41C3EC0C26D0100F009DCA8B /* SaliencyMapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SaliencyMapView.swift; path = Shared/Views/SaliencyMapView.swift; sourceTree = "<group>"; };
76+
41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessDerivatives.swift; sourceTree = "<group>"; };
6977
/* End PBXFileReference section */
7078

7179
/* Begin PBXFrameworksBuildPhase section */
@@ -124,6 +132,7 @@
124132
41292EA426CB624000747458 /* Views */,
125133
4102055626A631F4004B24B3 /* PerformanceExampleApp.swift */,
126134
41BFA1EF26B1D8B80013EB90 /* Process.swift */,
135+
41C3EC1126D05538009DCA8B /* ProcessDerivatives.swift */,
127136
419700EC26C30DA500F186C3 /* UITests.swift */,
128137
4102055826A631F5004B24B3 /* Assets.xcassets */,
129138
);
@@ -145,6 +154,7 @@
145154
isa = PBXGroup;
146155
children = (
147156
41292E9A26CB623B00747458 /* ClassifyView.swift */,
157+
41C3EC0C26D0100F009DCA8B /* SaliencyMapView.swift */,
148158
41292E9B26CB623B00747458 /* DownloadView.swift */,
149159
41292E9826CB623B00747458 /* MainView.swift */,
150160
41292E9926CB623B00747458 /* UploadView.swift */,
@@ -335,8 +345,10 @@
335345
isa = PBXSourcesBuildPhase;
336346
buildActionMask = 2147483647;
337347
files = (
348+
41C3EC1226D05538009DCA8B /* ProcessDerivatives.swift in Sources */,
338349
41292E9E26CB623B00747458 /* UploadView.swift in Sources */,
339350
41292EA026CB623B00747458 /* ClassifyView.swift in Sources */,
351+
41C3EC0D26D0100F009DCA8B /* SaliencyMapView.swift in Sources */,
340352
41292E9C26CB623B00747458 /* MainView.swift in Sources */,
341353
41292EA226CB623B00747458 /* DownloadView.swift in Sources */,
342354
4102056426A631F5004B24B3 /* PerformanceExampleApp.swift in Sources */,
@@ -349,15 +361,18 @@
349361
buildActionMask = 2147483647;
350362
files = (
351363
419700ED26C30DA500F186C3 /* UITests.swift in Sources */,
364+
41C3EC1326D05538009DCA8B /* ProcessDerivatives.swift in Sources */,
352365
);
353366
runOnlyForDeploymentPostprocessing = 0;
354367
};
355368
410FF76526B1CEB500CA084F /* Sources */ = {
356369
isa = PBXSourcesBuildPhase;
357370
buildActionMask = 2147483647;
358371
files = (
372+
41C3EC1426D05538009DCA8B /* ProcessDerivatives.swift in Sources */,
359373
41292E9F26CB623B00747458 /* UploadView.swift in Sources */,
360374
41292EA126CB623B00747458 /* ClassifyView.swift in Sources */,
375+
41C3EC0E26D0100F009DCA8B /* SaliencyMapView.swift in Sources */,
361376
41292E9D26CB623B00747458 /* MainView.swift in Sources */,
362377
41292EA326CB623B00747458 /* DownloadView.swift in Sources */,
363378
41BFA1EA26B1D36C0013EB90 /* PerformanceExampleApp.swift in Sources */,
@@ -370,6 +385,7 @@
370385
buildActionMask = 2147483647;
371386
files = (
372387
419700EE26C30DA500F186C3 /* UITests.swift in Sources */,
388+
41C3EC1526D05538009DCA8B /* ProcessDerivatives.swift in Sources */,
373389
);
374390
runOnlyForDeploymentPostprocessing = 0;
375391
};

performance/SwiftUIPerformanceQuickstart/PerformanceExample/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ while also allowing you to measure the performance of any piece of code in your
99

1010
Introduction
1111
------------
12+
The app is centered around image tasks: download, classify, saliency map, and upload. Downloading
13+
and uploading images is a common developer task. Classifying the image and generating a saliency map
14+
are tasks that might be more popular now with the success of computer vision algorithms. Classifying
15+
the image consists of providing categories to which the image belongs. A saliency map identifies the
16+
parts of an image most likely to draw attention.
17+
18+
Network requests are automatically traced by Performance Monitoring, while custom traces are used to
19+
measure the classification task.
20+
21+
The typical usage flow consists of downloading the image, classifying the image, generating the
22+
saliency map, and lastly uploading the saliency map. The status of the task (idle, running, success,
23+
failure) is displayed for the user’s convenience.
1224

1325
- [Read more about Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon/)
26+
- [Read more about Vision](https://developer.apple.com/documentation/vision)
27+
- [See code samples for classifying images](https://developer.apple.com/documentation/vision/classifying_images_for_categorization_and_search)
28+
- [See code samples for saliency maps](https://developer.apple.com/documentation/vision/highlighting_areas_of_interest_in_an_image_using_saliency)
1429

1530
Getting Started
1631
---------------
@@ -22,7 +37,7 @@ Getting Started
2237
rules_version = '2';
2338
service firebase.storage {
2439
match /b/{bucket}/o {
25-
match /image.jpg {
40+
match /saliency_map.jpg {
2641
allow create: if request.resource.contentType == 'image/jpeg'
2742
}
2843
}

0 commit comments

Comments
 (0)