Posts

Post not yet marked as solved
1 Replies
1.5k Views
Hi, ich habe nach folgender Anleitung versucht ein Text classifier model zu machen.Allerdings scheitert dies daran, das die evaluation() Funktion nicht funktioniert.Den Error den ich (in SwiftPlayground) bekomme ist: No exact matches in call to instance method 'evaluation' Hier ist der Code, den ich verwende: if #available(iOSApplicationExtension 15.0, *) {         let data = try! MLDataTable(contentsOf:  fileLiteral(resourceName: "TestData.json"))          let (trainingData, testingData) = data.randomSplit(by: 0.8, seed: 5)                  let sentimentClassifier = try! MLTextClassifier(trainingData: trainingData,                                                        textColumn: "text",                                                        labelColumn: "label")         // Training accuracy as a percentage         let trainingAccuracy = (1.0 - sentimentClassifier.trainingMetrics.classificationError) * 100         // Validation accuracy as a percentage         let validationAccuracy = (1.0 - sentimentClassifier.validationMetrics.classificationError) * 100         let evaluationMetrics = sentimentClassifier.evaluation(on: testingData)//Error hier         let evaluationAccuracy = (1.0 - evaluationMetrics.classificationError) * 100                  let metadata = MLModelMetadata(author: "No One",                                        shortDescription: "A model trained to classify movie review sentiment",                                        version: "1.0")         try! sentimentClassifier.write(to: URL(fileURLWithPath: Bundle.main.path(forResource: "MODEL", ofType: "mlmodel")!),                                       metadata: metadata)     } else {         print("dein Gerät erfüllt nicht die Bedingungen für dieses Programm")     } vielen Dank im Voraus (:
Posted
by NaimadDev.
Last updated
.
Post not yet marked as solved
1 Replies
683 Views
Ich habe folgende Funktion: func plot(a: Double,b: Double,c: Double,d: Double,cam: [Double]) -> CGPoint{     var dim: [Double] = []     var new_dim = [a,b,c,d]     var mul: Double = 0          for _ in 1...new_dim.count-2 {         dim = new_dim         new_dim = []         mul = 80/dim.last!                  for i in 0...dim.count-2 {             new_dim.append((dim[i]-cam[i])*mul+cam[i])             //new_dim.append(dim[i]*mul)         }     }               return CGPoint(x:  new_dim[0],y: new_dim[1]) } Aber wenn ich d verändere, verendert sich der Output nicht.Ich weiß nicht woran das liegt.Wenn ich es selbst rechne, verändert sich das Ergebnis.Was ich Rechen will ist: A = (a-cam[0])*(80/d)+cam[0] B = (b-cam[1])*(80/d)+cam[1] C = (c-cam[2])*(80/d)+cam[2] und dann(dafür die erste for Schleife): a_ = (A-cam[0])*(80/C)+cam[0] b_ = (B-cam[1])*(80/C)+cam[1] Zumindest glaube ich, dass 4D perspective projection so funktioniert.Eventuell darf ich aber auch den Kamera Offset nicht 2x Berechnen. Ich hoffe man kann meine Frage verstehen (:
Posted
by NaimadDev.
Last updated
.
Post not yet marked as solved
1 Replies
691 Views
Hi.Ich habe folgendes festgestellt.Wenn ich in shortcuts ein Bild mit Base64 encode erhalte ich nicht das selbe, wie wenn ich in Swift img.pngData().base64EncodedString() verwende.Habe ich das Prinzip von Base64 nicht verstanden oder kann/muss man da noch Dinge einstellen?Danke Schonmal im Voraus(:
Posted
by NaimadDev.
Last updated
.
Post marked as solved
2 Replies
800 Views
Hallo, ich möchte just4fun WFC(Wave Function Collapse) in SwiftUI implementieren.Ich habe nur ein komisches Problem.Der Output von der Funktion collapseTile() ist immer false ): Hier ist mein Code: struct tile: View {     @State var MapSize: CGFloat     @State var DIM: CGFloat     @State var tiles = [0,1,2]     @State public var collapse = false     var body: some View {         ZStack {             RoundedRectangle(cornerRadius: 1.0)                 .frame(width: MapSize/DIM,height: MapSize/DIM)                 .foregroundStyle(collapse ? LinearGradient(Color.red,Color.green) : LinearGradient(Color.black,Color.gray))                 .aspectRatio(1.0,contentMode: ContentMode.fit)             Text("\(String(collapse))")                 .font(.custom("ehhh", size: 5.0))         }     }          func collapseTile() {         collapse = true         print("Toggle collaps: \(collapse)")     } } Ich verstehe nicht wieso und freue mich über Rückmeldung wie man das fixt oder schlauer macht. Außerdem wollte ich fragen ob jemand weiß wie man aus .json files in swift playground liest.Das wäre nicht essenziell aber doch gut.Sonst müsste ich ein paar Umwege nehmen…
Posted
by NaimadDev.
Last updated
.
Post not yet marked as solved
0 Replies
743 Views
Hi, I work on an App, that can generate videos.(or it should)I don’t know which Frameworks/library’s you can use to do this.I have input(image,pos,…) from this information(s) I want generate a video.The code should be compatible with SwiftUI, so that I can have sth. Like a live preview in iMovi or clips.(My current code is flexible, so it don’t matters if I have to restructure some small thinks) Thanks in advance
Posted
by NaimadDev.
Last updated
.
Post not yet marked as solved
0 Replies
631 Views
I want to make a Dropdown-Menü like in pages(I mean the brush button).I use SwiftUI but at first my menu looks not like this and it don‘t work.If I press any button the menu closes.I want that the menu looks like the menu in pages/keynote and also works without that you have to open the menu every time u press a button.My current code looks like this: import UniformTypeIdentifiers struct ContentView: View {     var body: some View {         NavigationView {             Text("")             .toolbar {                 ToolbarItem(placement: ToolbarItemPlacement.navigationBarTrailing) {                     Menu {                         Button("button"){                             print("Pressed")                         }                     } label: {                         Label(                             title: { Text("Settings") },                             icon: { Image(systemName: "gearshape.fill") }                         )                     }                 }             }         }.navigationViewStyle(StackNavigationViewStyle())     } } Tanks in advance(if u say it so in English) Edit: I work on a iPad(Because of that I have this style at the NavigationView)
Posted
by NaimadDev.
Last updated
.