Skip to content

Commit 75f9588

Browse files
committed
Initial commit
0 parents  commit 75f9588

40 files changed

+911
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OS X
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
Icon
6+
._*
7+
.Spotlight-V100
8+
.Trashes
9+
10+
# Xcode
11+
#
12+
build/
13+
*.pbxuser
14+
!default.pbxuser
15+
*.mode1v3
16+
!default.mode1v3
17+
*.mode2v3
18+
!default.mode2v3
19+
*.perspectivev3
20+
!default.perspectivev3
21+
xcuserdata
22+
*.xccheckout
23+
*.moved-aside
24+
DerivedData
25+
*.hmap
26+
*.ipa
27+
*.xcuserstate
28+
.idea/
29+
*.xcworkspace/xcshareddata/*.xcscmblueprint
30+
31+
# CocoaPods
32+
Pods
33+
34+
# Carthage
35+
Carthage
36+
37+
# SPM
38+
.build/
39+
40+
## CoreML models
41+
*.mlmodel

Convert/convert.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import coremltools
2+
3+
coreml_model = coremltools.converters.caffe.convert(('twitter_finetuned_test4_iter_180.caffemodel', 'sentiment_deploy.prototxt'), image_input_names = 'data', class_labels='labels.txt')
4+
coreml_model.author = 'Campos, V., Jou, B., & Giro-i-Nieto, X.'
5+
coreml_model.license = 'MIT'
6+
coreml_model.short_description = 'Fine-tuned CNN for Visual Sentiment Prediction'
7+
coreml_model.input_description['data'] = 'An image.'
8+
coreml_model.output_description['prob'] = 'The probabilities for each sentiment, for the given input.'
9+
coreml_model.output_description['classLabel'] = 'The most likely sentiment, for the given input.'
10+
coreml_model.save('VisualSentimentCNN.mlmodel')

Convert/download.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
wget https://imatge.upc.edu/web/sites/default/files/projects/affective/public_html/2017-imavis/twitter_finetuned_test4_iter_180.caffemodel
2+
wget https://github.com/imatge-upc/sentiment-2017-imavis/blob/master/sentiment_deploy.prototxt

Convert/labels.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Negative
2+
Positive

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Vadym Markov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Podfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use_frameworks!
2+
platform :ios, '11.0'
3+
pod 'VisionLab', git: 'https://github.com/cocoa-ai/VisionLab'
4+
target 'SentimentVision'

Podfile.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PODS:
2+
- VisionLab (0.1.0)
3+
4+
DEPENDENCIES:
5+
- VisionLab (from `https://github.com/cocoa-ai/VisionLab`)
6+
7+
EXTERNAL SOURCES:
8+
VisionLab:
9+
:git: https://github.com/cocoa-ai/VisionLab
10+
11+
CHECKOUT OPTIONS:
12+
VisionLab:
13+
:commit: 330e6baeb63246fe8e58b5c4601bac1a63a84ea4
14+
:git: https://github.com/cocoa-ai/VisionLab
15+
16+
SPEC CHECKSUMS:
17+
VisionLab: 5be1c3c327a521a510d3407792f1b3103f4f7d14
18+
19+
PODFILE CHECKSUM: b3731e7bdb17f1171592448b19fcf17042c1166d
20+
21+
COCOAPODS: 1.2.1

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Styles Vision Demo
2+
3+
A Demo application using `Vision` and `CoreML` frameworks to detect the most
4+
likely sentiment of the given image.
5+
6+
<div align="center">
7+
<img src="https://github.com/cocoa-ml/SentimentVisionDemo/blob/master/Screenshot.png" alt="StylesVisionDemo" width="300" height="416" />
8+
</div>
9+
10+
## Model
11+
12+
This demo is based on the "Fine-tuning CNNs for Visual Sentiment Prediction"
13+
neural network classifier, which was converted from original [Caffe model](https://github.com/imatge-upc/sentiment-2017-imavis)
14+
to [CoreML model](https://drive.google.com/open?id=0B1ghKa_MYL6meTZRT3U5b0o5amc)
15+
using [coremltools](https://pypi.python.org/pypi/coremltools) python package.
16+
17+
## Requirements
18+
19+
- Xcode 9
20+
- iOS 11
21+
22+
## Installation
23+
24+
```sh
25+
git clone https://github.com/cocoa-ml/SentimentVisionDemo.git
26+
cd SentimentVisionDemo
27+
pod install
28+
open StylesVision.xcworkspace/
29+
```
30+
31+
Download the [CoreMl model](https://drive.google.com/open?id=0B1ghKa_MYL6meTZRT3U5b0o5amc)
32+
and drag the file into your project.
33+
34+
Build the project and run it on a simulator or a device with iOS 11.
35+
36+
## Conversion
37+
38+
```sh
39+
$ cd Convert
40+
$ ./download.sh
41+
$ python convert.py
42+
```
43+
44+
## Author
45+
46+
Vadym Markov, [email protected]
47+
48+
## Credits
49+
50+
[From Pixels to Sentiment: Fine-tuning CNNs for Visual Sentiment Prediction](https://github.com/imatge-upc/sentiment-2017-imavis)
51+
52+
## References
53+
- [Caffe](http://caffe.berkeleyvision.org)
54+
- [Apple Machine Learning](https://developer.apple.com/machine-learning/)
55+
- [Vision Framework](https://developer.apple.com/documentation/vision)
56+
- [CoreML Framework](https://developer.apple.com/documentation/coreml)
57+
- [coremltools](https://pypi.python.org/pypi/coremltools)

Screenshot.png

813 KB
Loading

0 commit comments

Comments
 (0)