Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS UI #12

Merged
merged 27 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d028c43
Added macOS UI skeleton
cyrilzakka Jan 13, 2023
61df7c7
Added early macOS UI support (#11)
pcuenca Jan 14, 2023
584943c
Ignore user data.
pcuenca Jan 14, 2023
332739a
Compile common code in macOS target.
pcuenca Jan 14, 2023
b986fd4
Change product name to Diffusion (instead of TARGET_NAME)
pcuenca Jan 14, 2023
a51e3d8
Populate model picker.
pcuenca Jan 14, 2023
97935c1
macOS: download model on startup.
pcuenca Jan 17, 2023
d1c63da
Download: display progress, hide Generate button.
pcuenca Jan 17, 2023
47ce76e
Download model selected in picker.
pcuenca Jan 17, 2023
e0214ec
Temporarily remove v1.4 model (malformed, I think).
pcuenca Jan 17, 2023
6910a3f
Replace personal bundle IDs
pcuenca Jan 17, 2023
a551cab
Disable code signing only in Debug mode
pcuenca Jan 17, 2023
6e20e00
Adjust some defaults.
pcuenca Jan 18, 2023
79e98f4
Refactor DiffusionGlobals to GenerationContext, includes generation
pcuenca Jan 18, 2023
e14e011
Make Generate button work.
pcuenca Jan 18, 2023
f92d53a
Make iOS/Catalyst generation use GenerationContext.
pcuenca Jan 18, 2023
507d769
Simplify code
pcuenca Jan 18, 2023
82cea4f
Make Mac faster, lol.
pcuenca Jan 18, 2023
e6d725d
Rename context -> generation
pcuenca Jan 18, 2023
5cda9b1
Use UI values for generation.
pcuenca Jan 18, 2023
ee244e5
Rename PromptView -> ControlsView
pcuenca Jan 18, 2023
01b6411
Disable num images, make -1 mean random.
pcuenca Jan 18, 2023
172995d
Use negative prompts.
pcuenca Jan 18, 2023
8af1276
Make Share work.
pcuenca Jan 18, 2023
72f946e
Add Save button.
pcuenca Jan 18, 2023
61e2064
Update icon and app name.
pcuenca Jan 23, 2023
6e6ab20
Reference LICENSE in all files.
pcuenca Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Download: display progress, hide Generate button.
  • Loading branch information
pcuenca committed Jan 17, 2023
commit d1c63dafbc476ae903dddbe5ee82b3b1ab55e9f4
34 changes: 15 additions & 19 deletions Diffusion-macOS/PromptView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import Combine
import SwiftUI
import CompactSlider

enum PipelineState {
case downloading(Double)
case uncompressing
case loading
case ready
case failed(Error)
}

struct PromptView: View {
@StateObject var context = DiffusionGlobals()
Expand All @@ -24,9 +31,8 @@ struct PromptView: View {
@State private var seed = 386.0

// TODO: refactor download with similar code in Loading.swift (iOS)
@State private var preparationPhase = "Downloading…"
@State private var downloadProgress: Double = 0
@State private var stateSubscriber: Cancellable?
@State private var pipelineState: PipelineState = .downloading(0)

func modelDidChange(model: ModelInfo) {
Task.init {
Expand All @@ -35,24 +41,22 @@ struct PromptView: View {
DispatchQueue.main.async {
switch state {
case .downloading(let progress):
preparationPhase = "Downloading"
downloadProgress = progress
pipelineState = .downloading(progress)
case .uncompressing:
preparationPhase = "Uncompressing"
downloadProgress = 1
pipelineState = .uncompressing
case .readyOnDisk:
preparationPhase = "Loading"
downloadProgress = 1
pipelineState = .loading
default:
break
}
}
}
do {
context.pipeline = try await loader.prepare()
pipelineState = .ready
} catch {
// TODO: expose to user
print("Could not load model, error: \(error)")
pipelineState = .failed(error)
}
}
}
Expand Down Expand Up @@ -129,17 +133,9 @@ struct PromptView: View {
Label("Random Seed", systemImage: "leaf").foregroundColor(.secondary)
}
}

}
Button {
// Generate image here
} label: {
Text("Generate")
.frame(maxWidth: .infinity)
.frame(height: 50)
}
.buttonStyle(.borderedProminent)
// StatusView()

StatusView(pipelineState: $pipelineState)
}
.padding()
.onAppear {
Expand Down
24 changes: 22 additions & 2 deletions Diffusion-macOS/StatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,33 @@
import SwiftUI

struct StatusView: View {
var pipelineState: Binding<PipelineState>

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
switch pipelineState.wrappedValue {
case .downloading(let progress):
ProgressView("Downloading…", value: progress*100, total: 110).padding()
case .uncompressing:
ProgressView("Uncompressing…", value: 100, total: 110).padding()
case .loading:
ProgressView("Loading…", value: 105, total: 110).padding()
case .ready:
Button {
// Generate image here
} label: {
Text("Generate")
.frame(maxWidth: .infinity)
.frame(height: 50)
}
.buttonStyle(.borderedProminent)
case .failed:
Text("Pipeline loading error")
}
}
}

struct StatusView_Previews: PreviewProvider {
static var previews: some View {
StatusView()
StatusView(pipelineState: .constant(.downloading(0.2)))
}
}