Crash fixed
This commit is contained in:
parent
79c9b2abfb
commit
9c52c0c988
|
@ -7,6 +7,7 @@ import UIKit
|
||||||
final class HuggingFace: ObservableObject {
|
final class HuggingFace: ObservableObject {
|
||||||
static var token: String = ""
|
static var token: String = ""
|
||||||
static let altGenUrl: URL = URL(string: "https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large")!
|
static let altGenUrl: URL = URL(string: "https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large")!
|
||||||
|
static let textGenURL: URL = URL(string: "https://api-inference.huggingface.co/models/grammarly/coedit-large")!
|
||||||
|
|
||||||
var lastImgGeneration: String? = nil
|
var lastImgGeneration: String? = nil
|
||||||
|
|
||||||
|
@ -41,12 +42,11 @@ final class HuggingFace: ObservableObject {
|
||||||
defer { semaphore.signal() }
|
defer { semaphore.signal() }
|
||||||
if let data = data {
|
if let data = data {
|
||||||
jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [[String: Any]]
|
jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [[String: Any]]
|
||||||
print(jsonResponse?[0]["generated_text"] ?? "idfk")
|
|
||||||
}
|
}
|
||||||
}.resume()
|
}.resume()
|
||||||
|
|
||||||
semaphore.wait()
|
semaphore.wait()
|
||||||
return (jsonResponse?[0]["generated_text"] as! String)
|
return jsonResponse?[0]["generated_text"] as? String
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue