Skip to content

Commit 84ae52a

Browse files
committed
Update readme
1 parent 5cb6e52 commit 84ae52a

File tree

8 files changed

+146
-0
lines changed

8 files changed

+146
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ fastlane/test_output
8080
# https://github.com/johnno1962/injectionforxcode
8181

8282
iOSInjectionProject/
83+
84+
.DS_Store
85+
**/.DS_Store
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>classNames</key>
6+
<dict>
7+
<key>MentalistTests</key>
8+
<dict>
9+
<key>testAnalyzeTime()</key>
10+
<dict>
11+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
12+
<dict>
13+
<key>baselineAverage</key>
14+
<real>6.540000</real>
15+
<key>baselineIntegrationDisplayName</key>
16+
<string>Local Baseline</string>
17+
</dict>
18+
</dict>
19+
</dict>
20+
</dict>
21+
</dict>
22+
</plist>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>runDestinationsByUUID</key>
6+
<dict>
7+
<key>16945756-61C2-4E9B-B3DD-A87D97D8D455</key>
8+
<dict>
9+
<key>localComputer</key>
10+
<dict>
11+
<key>busSpeedInMHz</key>
12+
<integer>0</integer>
13+
<key>cpuCount</key>
14+
<integer>1</integer>
15+
<key>cpuKind</key>
16+
<string>Apple M2 Pro</string>
17+
<key>cpuSpeedInMHz</key>
18+
<integer>0</integer>
19+
<key>logicalCPUCoresPerPackage</key>
20+
<integer>12</integer>
21+
<key>modelCode</key>
22+
<string>Mac14,10</string>
23+
<key>physicalCPUCoresPerPackage</key>
24+
<integer>12</integer>
25+
<key>platformIdentifier</key>
26+
<string>com.apple.platform.macosx</string>
27+
</dict>
28+
<key>targetArchitecture</key>
29+
<string>arm64</string>
30+
<key>targetDevice</key>
31+
<dict>
32+
<key>modelCode</key>
33+
<string>iPhone16,1</string>
34+
<key>platformIdentifier</key>
35+
<string>com.apple.platform.iphonesimulator</string>
36+
</dict>
37+
</dict>
38+
</dict>
39+
</dict>
40+
</plist>

Assets/banner.jpg

69.9 KB
Loading

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,67 @@
11
# Mentalist
2+
3+
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
4+
5+
![banner](Assets/banner.jpg)
6+
7+
<div align="center">
8+
<h3> Read face with a line of code </h3>
9+
</div>
10+
11+
```swift
12+
let analysis = try Mentalist.analyze(image: Image("my_face")).first!
13+
14+
print("The emotion on your face is... '\(analysis.dominantEmotion)!'")
15+
// "The emotion on your face is... 'happy'!
16+
```
17+
18+
## Features
19+
20+
**Mentalist** is a Swift-based library designed for analyzing and identifying emotions within a picture.
21+
22+
### 1. Seven Emotion Categories
23+
24+
Mentalist classifies the emotions on faces in a photo into **one of seven categories**. Internally, it utilizes a CoreML model based on FER2013 to analyze emotions displayed in a picture into seven categories: 'happy', 'angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', and 'neutral'.
25+
26+
### 2. Optimized for Mobile Environment
27+
28+
Mentalist has an optimal size for mobile environments. It also takes approximately **0.06 seconds per analysis** with an **accuracy rate of about 57%**.
29+
30+
### 3. Supports Multi-Face Analysis
31+
32+
Mentalist can detect multiple faces. If multiple faces are detected, it returns a list of multiple analysis results.
33+
34+
## Installation
35+
36+
### Swift Package Manager (SPM)
37+
38+
Follow these steps to install Mentalist using SPM:
39+
40+
1. From within Xcode 13 or later, choose File > Swift Packages > Add Package Dependency.
41+
2. At the next screen, enter the URL for the Mentalist repository(https://github.com/enebin/Mentalist) in the search bar then click Next.
42+
3. For the version rule, select 'Up to Next Minor' and specify the current Mentalist version then click 'Next'.
43+
4. On the final screen, select the Mentalist library and then click 'Finish'.
44+
45+
Mentalist should now be integrated into your project 🚀.
46+
47+
## Usage
48+
49+
```swift
50+
import Mentalist
51+
52+
let analysis = try Mentalist.analyze(image: Image("my_face"))
53+
```
54+
55+
Done!
56+
57+
## Contributing
58+
59+
We welcome contributions to Mentalist! If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
60+
61+
## License
62+
63+
Mentalist is released under the MIT License. See [LICENSE](LICENSE) for details.
64+
65+
## Contact
66+
67+
For any questions or suggestions, please feel free to contact me. My email's on my Github profile.

Sources/.DS_Store

0 Bytes
Binary file not shown.

Tests/MentalistTests/MentalistTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,19 @@ final class MentalistTests: XCTestCase {
2222
XCTAssertEqual(result.dominantEmotion, emotion)
2323
}
2424
}
25+
26+
func testAnalyzeTime() throws {
27+
let image = try XCTUnwrap(UIImage(named: "happy", in: .module, with: nil))
28+
let cgImage = try XCTUnwrap(image.cgImage)
29+
30+
measure {
31+
(1...100).forEach { _ in
32+
do {
33+
_ = try Mentalist.analyze(cgImage: cgImage)
34+
} catch {
35+
return
36+
}
37+
}
38+
}
39+
}
2540
}

0 commit comments

Comments
 (0)