Allow safety checker to be disabled.

pull/28/head
Pedro Cuenca 2 years ago
parent 1839453f3d
commit b873c4b708

@ -62,6 +62,13 @@ struct ControlsView: View {
@State private var stateSubscriber: Cancellable?
@State private var pipelineState: PipelineState = .downloading(0)
// TODO: make this computed, and observable, and easy to read
@State private var mustShowSafetyCheckerDisclaimer = false
func updateSafetyCheckerState() {
mustShowSafetyCheckerDisclaimer = generation.disableSafety && !Settings.shared.safetyCheckerDisclaimerShown
}
func modelDidChange(model: ModelInfo) {
print("Loading model \(model)")
Settings.shared.currentModel = model
@ -182,6 +189,32 @@ struct ControlsView: View {
}
.disclosureGroupStyle(LabelToggleDisclosureGroupStyle())
Toggle("Disable Safety Checker", isOn: $generation.disableSafety).onChange(of: generation.disableSafety) { value in
updateSafetyCheckerState()
}
.popover(isPresented: $mustShowSafetyCheckerDisclaimer) {
VStack {
Text("You have disabled the safety checker").font(.title).padding(.top)
Text("""
Please, ensure that you abide \
by the conditions of the Stable Diffusion license and do not expose \
unfiltered results to the public.
""")
.lineLimit(nil)
.padding(.all, 5)
Button {
Settings.shared.safetyCheckerDisclaimerShown = true
updateSafetyCheckerState()
} label: {
Text("I Accept").frame(maxWidth: 200)
}
.padding(.bottom)
}
.frame(minWidth: 400, idealWidth: 400, maxWidth: 400)
.fixedSize()
}
Divider()
StatusView(pipelineState: $pipelineState)
}
.padding()

@ -71,11 +71,13 @@ class Settings {
enum Keys: String {
case model
case safetyCheckerDisclaimer
}
private init() {
defaults.register(defaults: [
Keys.model.rawValue: ModelInfo.v2Base.modelId
Keys.model.rawValue: ModelInfo.v2Base.modelId,
Keys.safetyCheckerDisclaimer.rawValue: false
])
}
@ -88,4 +90,13 @@ class Settings {
return ModelInfo.from(modelId: modelId) ?? DEFAULT_MODEL
}
}
var safetyCheckerDisclaimerShown: Bool {
set {
defaults.set(newValue, forKey: Keys.safetyCheckerDisclaimer.rawValue)
}
get {
return defaults.bool(forKey: Keys.safetyCheckerDisclaimer.rawValue)
}
}
}

Loading…
Cancel
Save