mirror of
https://github.com/GayPizzaSpecifications/stable-diffusion-rpc.git
synced 2025-08-04 14:01:32 +00:00
Document API, make the implementation match the API, and update the same.
This commit is contained in:
@ -9,23 +9,25 @@ let client = try StableDiffusionClient(connectionTarget: .host("127.0.0.1", port
|
||||
Task { @MainActor in
|
||||
do {
|
||||
let modelListResponse = try await client.modelService.listModels(.init())
|
||||
print("Loading model...")
|
||||
let modelInfo = modelListResponse.models.first { $0.name == "anything-4.5" }!
|
||||
print("Loading random model...")
|
||||
let modelInfo = modelListResponse.availableModels.randomElement()!
|
||||
_ = try await client.modelService.loadModel(.with { request in
|
||||
request.modelName = modelInfo.name
|
||||
})
|
||||
print("Loaded model.")
|
||||
print("Loaded random model.")
|
||||
|
||||
print("Generating image...")
|
||||
let request = SdGenerateImagesRequest.with {
|
||||
$0.modelName = modelInfo.name
|
||||
$0.outputImageFormat = .png
|
||||
$0.prompt = "cat"
|
||||
$0.imageCount = 1
|
||||
$0.batchCount = 1
|
||||
$0.batchSize = 1
|
||||
}
|
||||
|
||||
let response = try await client.imageGenerationService.generateImage(request)
|
||||
let response = try await client.imageGenerationService.generateImages(request)
|
||||
let image = response.images.first!
|
||||
try image.content.write(to: URL(filePath: "output.png"))
|
||||
try image.data.write(to: URL(filePath: "output.png"))
|
||||
print("Generated image to output.png")
|
||||
exit(0)
|
||||
} catch {
|
||||
|
Reference in New Issue
Block a user