Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
enebin committed Jun 14, 2024
1 parent 5cb6e52 commit 84ae52a
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

.DS_Store
**/.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>classNames</key>
<dict>
<key>MentalistTests</key>
<dict>
<key>testAnalyzeTime()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>6.540000</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>runDestinationsByUUID</key>
<dict>
<key>16945756-61C2-4E9B-B3DD-A87D97D8D455</key>
<dict>
<key>localComputer</key>
<dict>
<key>busSpeedInMHz</key>
<integer>0</integer>
<key>cpuCount</key>
<integer>1</integer>
<key>cpuKind</key>
<string>Apple M2 Pro</string>
<key>cpuSpeedInMHz</key>
<integer>0</integer>
<key>logicalCPUCoresPerPackage</key>
<integer>12</integer>
<key>modelCode</key>
<string>Mac14,10</string>
<key>physicalCPUCoresPerPackage</key>
<integer>12</integer>
<key>platformIdentifier</key>
<string>com.apple.platform.macosx</string>
</dict>
<key>targetArchitecture</key>
<string>arm64</string>
<key>targetDevice</key>
<dict>
<key>modelCode</key>
<string>iPhone16,1</string>
<key>platformIdentifier</key>
<string>com.apple.platform.iphonesimulator</string>
</dict>
</dict>
</dict>
</dict>
</plist>
Binary file added Assets/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# Mentalist

[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)

![banner](Assets/banner.jpg)

<div align="center">
<h3> Read face with a line of code </h3>
</div>

```swift
let analysis = try Mentalist.analyze(image: Image("my_face")).first!

print("The emotion on your face is... '\(analysis.dominantEmotion)!'")
// "The emotion on your face is... 'happy'!
```

## Features

**Mentalist** is a Swift-based library designed for analyzing and identifying emotions within a picture.

### 1. Seven Emotion Categories

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'.

### 2. Optimized for Mobile Environment

Mentalist has an optimal size for mobile environments. It also takes approximately **0.06 seconds per analysis** with an **accuracy rate of about 57%**.

### 3. Supports Multi-Face Analysis

Mentalist can detect multiple faces. If multiple faces are detected, it returns a list of multiple analysis results.

## Installation

### Swift Package Manager (SPM)

Follow these steps to install Mentalist using SPM:

1. From within Xcode 13 or later, choose File > Swift Packages > Add Package Dependency.
2. At the next screen, enter the URL for the Mentalist repository(https://github.com/enebin/Mentalist) in the search bar then click Next.
3. For the version rule, select 'Up to Next Minor' and specify the current Mentalist version then click 'Next'.
4. On the final screen, select the Mentalist library and then click 'Finish'.

Mentalist should now be integrated into your project 🚀.

## Usage

```swift
import Mentalist

let analysis = try Mentalist.analyze(image: Image("my_face"))
```

Done!

## Contributing

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.

## License

Mentalist is released under the MIT License. See [LICENSE](LICENSE) for details.

## Contact

For any questions or suggestions, please feel free to contact me. My email's on my Github profile.
Binary file modified Sources/.DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions Tests/MentalistTests/MentalistTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ final class MentalistTests: XCTestCase {
XCTAssertEqual(result.dominantEmotion, emotion)
}
}

func testAnalyzeTime() throws {
let image = try XCTUnwrap(UIImage(named: "happy", in: .module, with: nil))
let cgImage = try XCTUnwrap(image.cgImage)

measure {
(1...100).forEach { _ in
do {
_ = try Mentalist.analyze(cgImage: cgImage)
} catch {
return
}
}
}
}
}

0 comments on commit 84ae52a

Please sign in to comment.