merge
Esse commit está contido em:
-39
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "aff-song/ResultsViewController.swift"
|
||||
timestampString = "536669970.691498"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "6"
|
||||
endingLineNumber = "6"
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "aff-song/UserStudy/USEmojiViewController.swift"
|
||||
timestampString = "536182084.662864"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "162"
|
||||
endingLineNumber = "162"
|
||||
landmarkName = "detectFaces(image:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB870371FDAA373004557D9"
|
||||
BuildableName = "aff-song.app"
|
||||
BlueprintName = "aff-song"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB8704B1FDAA373004557D9"
|
||||
BuildableName = "aff-songTests.xctest"
|
||||
BlueprintName = "aff-songTests"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB870561FDAA373004557D9"
|
||||
BuildableName = "aff-songUITests.xctest"
|
||||
BlueprintName = "aff-songUITests"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB870371FDAA373004557D9"
|
||||
BuildableName = "aff-song.app"
|
||||
BlueprintName = "aff-song"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB870371FDAA373004557D9"
|
||||
BuildableName = "aff-song.app"
|
||||
BlueprintName = "aff-song"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CBB870371FDAA373004557D9"
|
||||
BuildableName = "aff-song.app"
|
||||
BlueprintName = "aff-song"
|
||||
ReferencedContainer = "container:aff-song.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
<?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>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>aff-song.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>CBB870371FDAA373004557D9</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>CBB8704B1FDAA373004557D9</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>CBB870561FDAA373004557D9</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -21,7 +21,7 @@ class ResultsViewController: AffUIViewController, UITableViewDataSource, UITable
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
ImageView.image = faceImage
|
||||
let (valence, arousal, emotion) = getAffect(image: faceImage)
|
||||
let (valence, arousal, emotion, _) = getAffect(image: faceImage)
|
||||
getSongs(valence: valence, arousal: arousal, emotion: emotion, callback: {tracks in
|
||||
self.tracks = tracks
|
||||
DispatchQueue.main.async {
|
||||
@@ -110,7 +110,7 @@ class ResultsViewController: AffUIViewController, UITableViewDataSource, UITable
|
||||
}
|
||||
|
||||
|
||||
func getAffect(image: UIImage?) -> (Double, Double, Int) {
|
||||
func getAffect(image: UIImage?) -> (Double, Double, Int, [String:Double]) {
|
||||
// 0: Neutral, 1: Happiness, 2: Sadness, 3: Surprise, 4: Fear, 5: Disgust, 6: Anger, 7: Contempt, 8: None, 9: Uncertain, 10: No-Face
|
||||
let pixelBuffer = image?.pixelBuffer(width: 128, height: 128)
|
||||
let classifier = MobAffNetC()
|
||||
@@ -122,6 +122,7 @@ class ResultsViewController: AffUIViewController, UITableViewDataSource, UITable
|
||||
var valence = predictedValArr.valence_arousal[0].doubleValue
|
||||
var arousal = predictedValArr.valence_arousal[1].doubleValue
|
||||
let emotion = Int(predictedEmotion.emotion)!
|
||||
let emotion_p = predictedEmotion.emotion_p
|
||||
var emotionText : String?
|
||||
switch emotion {
|
||||
case 0:
|
||||
@@ -156,7 +157,7 @@ class ResultsViewController: AffUIViewController, UITableViewDataSource, UITable
|
||||
}
|
||||
valence = max(-1, min(1, valence))
|
||||
arousal = max(-1, min(1, arousal))
|
||||
return (valence, arousal, emotion)
|
||||
return (valence, arousal, emotion, emotion_p)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
|
||||
@@ -44,8 +44,9 @@ class USAnnotateViewController : AffUIViewController {
|
||||
let url = URL(fileURLWithPath: path).appendingPathComponent("user_study_data.csv")
|
||||
if let fileHandle = try? FileHandle(forWritingTo: url) {
|
||||
fileHandle.seekToEndOfFile()
|
||||
for item in data! {
|
||||
if item == data!.last {
|
||||
for i in 0..<data!.count {
|
||||
let item = data![i]
|
||||
if i == data!.count - 1 {
|
||||
fileHandle.write((item).data(using: .utf8)!)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -40,12 +40,15 @@ class USResultsViewController: ResultsViewController, UINavigationControllerDele
|
||||
}
|
||||
}
|
||||
|
||||
override func getAffect(image: UIImage?) -> (Double, Double, Int) {
|
||||
let (valence, arousal, emotion) : (Double, Double, Int) = super.getAffect(image: image)
|
||||
override func getAffect(image: UIImage?) -> (Double, Double, Int, [String:Double]) {
|
||||
let (valence, arousal, emotion, emotion_p) = super.getAffect(image: image)
|
||||
data!.append("\(valence)")
|
||||
data!.append("\(arousal)")
|
||||
data!.append("\(emotion)")
|
||||
return (valence, arousal, emotion)
|
||||
for i in 0 ... 7 {
|
||||
data!.append("\(emotion_p["\(i)"] ?? 0)")
|
||||
}
|
||||
return (valence, arousal, emotion, emotion_p)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class USStartViewController : AffUIViewController, MFMailComposeViewControllerDe
|
||||
let filePath = url.path
|
||||
if !FileManager.default.fileExists(atPath: filePath) {
|
||||
do {
|
||||
try "id, us_emotion, emotion_label, predicted_valence, predicted_arousal, predicted_emotion_label, rating, annotated_valence, annotated_arousal\n".write(toFile: filePath, atomically: false, encoding: .utf8)
|
||||
try "id, us_emotion, emotion_label, predicted_valence, predicted_arousal, predicted_emotion_label, em0prob, em1prob, em2prob, em3prob, em4prob, em5prob, em6prob, em7prob, rating, annotated_valence, annotated_arousal\n".write(toFile: filePath, atomically: false, encoding: .utf8)
|
||||
}
|
||||
catch {
|
||||
print("ERROR WRITING FILE")
|
||||
@@ -58,7 +58,7 @@ class USStartViewController : AffUIViewController, MFMailComposeViewControllerDe
|
||||
let alert = UIAlertController(title: "Delete Data", message: "Are you sure you would like to delete all user study data?", preferredStyle: UIAlertControllerStyle.alert)
|
||||
alert.addAction(UIAlertAction(title: "Delete", style: UIAlertActionStyle.destructive, handler: { action in
|
||||
do {
|
||||
try FileManager.default.moveItem(atPath: filePath, toPath: filePath+".bak")
|
||||
try FileManager.default.removeItem(atPath: filePath)
|
||||
self.makeDataFile()
|
||||
}
|
||||
catch {
|
||||
|
||||
+62
-53
@@ -2,6 +2,7 @@
|
||||
|
||||
import csv
|
||||
import os
|
||||
import sys
|
||||
from math import sqrt
|
||||
|
||||
import numpy as np
|
||||
@@ -152,76 +153,84 @@ def eval(c_path=None, r_path=None):
|
||||
print('CCC'.ljust(20), str(CCC(valence_t, valence_p)).ljust(20), CCC(arousal_t, arousal_p))
|
||||
|
||||
|
||||
def eval_from_files(path):
|
||||
def eval_from_file(path):
|
||||
true_l = []
|
||||
pred_l = []
|
||||
pred_r = []
|
||||
with open(path + '/Emotion.csv', 'r') as csvfile:
|
||||
valence_t = []
|
||||
valence_p = []
|
||||
arousal_t = []
|
||||
arousal_p = []
|
||||
ratings = [[], [], [], [], [], [], [], []]
|
||||
|
||||
with open(path, 'r') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=',')
|
||||
for row in reader:
|
||||
if row[0] == '':
|
||||
if row[0] == '' or row[0] == 'id':
|
||||
continue
|
||||
true_l.append(int(row[0]))
|
||||
pred_l.append(int(row[1]))
|
||||
probs = []
|
||||
for i in range(2, len(row)):
|
||||
probs.append(float(row[i]))
|
||||
pred_r.append(probs)
|
||||
|
||||
if int(row[1]) != 1 and int(row[1]) != 3:
|
||||
true_l.append(int(row[2]))
|
||||
pred_l.append(int(row[5]))
|
||||
probs = []
|
||||
for i in range(6, 13):
|
||||
probs.append(float(row[i]))
|
||||
pred_r.append(probs)
|
||||
|
||||
if row[15] == ' 0.00.0' or row[15] == '':
|
||||
valence_t.append(0)
|
||||
else:
|
||||
valence_t.append(float(row[15]))
|
||||
valence_p.append(float(row[3]))
|
||||
|
||||
if len(row) < 17 or (row[16] == ' 0.00.0' or row[16] == ''):
|
||||
arousal_t.append(0)
|
||||
else:
|
||||
arousal_t.append(float(row[16]))
|
||||
arousal_p.append(float(row[4]))
|
||||
|
||||
ratings[int(row[2])].append(int(float(row[14])))
|
||||
true_r = to_categorical(true_l, num_classes=8)
|
||||
|
||||
print('ACC'.ljust(20), ACC(true_l, pred_l))
|
||||
print('F1'.ljust(20), F1(true_l, pred_l))
|
||||
print('KAPPA'.ljust(20), KAPPA(true_l, pred_l))
|
||||
print('ALPHA'.ljust(20), ALPHA(true_l, pred_l))
|
||||
print('AUCPR'.ljust(20), AUCPR(true_r, pred_r))
|
||||
print('AUC'.ljust(20), AUC(true_r, pred_r))
|
||||
valence_t = []
|
||||
valence_p = []
|
||||
with open(path + '/Valence.csv', 'r') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=',')
|
||||
for row in reader:
|
||||
if row[0] == '':
|
||||
continue
|
||||
if row[0] == '0.00.0':
|
||||
valence_t.append(0)
|
||||
else:
|
||||
valence_t.append(float(row[0]))
|
||||
valence_p.append(float(row[1]))
|
||||
arousal_t = []
|
||||
arousal_p = []
|
||||
with open(path + '/Arousal.csv', 'r') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=',')
|
||||
for row in reader:
|
||||
if row[0] == '':
|
||||
continue
|
||||
if row[0] == '0.00.0':
|
||||
arousal_t.append(0)
|
||||
else:
|
||||
arousal_t.append(float(row[0]))
|
||||
arousal_p.append(float(row[1]))
|
||||
print(confusion_matrix(true_l, pred_l))
|
||||
print('')
|
||||
print(''.ljust(20), 'VALENCE'.ljust(20), 'AROUSAL')
|
||||
print('RMSE'.ljust(20), str(RMSE(valence_t, valence_p)).ljust(20), RMSE(arousal_t, arousal_p))
|
||||
print('CORR'.ljust(20), str(CORR(valence_t, valence_p)).ljust(20), CORR(arousal_t, arousal_p))
|
||||
print('SAGR'.ljust(20), str(SAGR(valence_t, valence_p)).ljust(20), SAGR(arousal_t, arousal_p))
|
||||
print('CCC'.ljust(20), str(CCC(valence_t, valence_p)).ljust(20), CCC(arousal_t, arousal_p))
|
||||
print('')
|
||||
t = (0, 0)
|
||||
for i, r in enumerate(ratings):
|
||||
print(str(i).ljust(5), np.mean(r))
|
||||
t = (t[0] + np.sum(r), t[1] + len(r))
|
||||
print('Total', t[0] / t[1])
|
||||
|
||||
|
||||
eval_from_files('/Users/charlie/Desktop/us_results')
|
||||
# if __name__ == '__main__':
|
||||
# if len(sys.argv) == 3:
|
||||
# if sys.argv[1] == '-c':
|
||||
# eval(c_path=sys.argv[2])
|
||||
# elif sys.argv[1] == '-r':
|
||||
# eval(r_path=sys.argv[2])
|
||||
# else:
|
||||
# raise Exception()
|
||||
# elif len(sys.argv) == 5:
|
||||
# c_path = None
|
||||
# r_path = None
|
||||
# if sys.argv[1] == '-c':
|
||||
# eval(c_path=sys.argv[2], r_path=sys.argv[4])
|
||||
# elif sys.argv[1] == '-r':
|
||||
# eval(r_path=sys.argv[2], c_path=sys.argv[4])
|
||||
# else:
|
||||
# raise Exception()
|
||||
# else:
|
||||
# raise Exception()
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 3:
|
||||
if sys.argv[1] == '-c':
|
||||
eval(c_path=sys.argv[2])
|
||||
elif sys.argv[1] == '-r':
|
||||
eval(r_path=sys.argv[2])
|
||||
elif sys.argv[1] == '-f':
|
||||
eval_from_file(sys.argv[2])
|
||||
else:
|
||||
raise Exception()
|
||||
elif len(sys.argv) == 5:
|
||||
c_path = None
|
||||
r_path = None
|
||||
if sys.argv[1] == '-c':
|
||||
eval(c_path=sys.argv[2], r_path=sys.argv[4])
|
||||
elif sys.argv[1] == '-r':
|
||||
eval(r_path=sys.argv[2], c_path=sys.argv[4])
|
||||
else:
|
||||
raise Exception()
|
||||
else:
|
||||
raise Exception()
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário