mirror of
https://github.com/GayPizzaSpecifications/stable-diffusion-rpc.git
synced 2025-08-04 05:51:32 +00:00
Initial Commit
This commit is contained in:
18
Sources/StableDiffusionServer/ImageGenerationService.swift
Normal file
18
Sources/StableDiffusionServer/ImageGenerationService.swift
Normal file
@ -0,0 +1,18 @@
|
||||
import Foundation
|
||||
import GRPC
|
||||
import StableDiffusionProtos
|
||||
|
||||
class ImageGenerationServiceProvider: SdImageGenerationServiceAsyncProvider {
|
||||
private let modelManager: ModelManager
|
||||
|
||||
init(modelManager: ModelManager) {
|
||||
self.modelManager = modelManager
|
||||
}
|
||||
|
||||
func generateImage(request: SdGenerateImagesRequest, context: GRPCAsyncServerCallContext) async throws -> SdGenerateImagesResponse {
|
||||
guard let state = await modelManager.getModelState(name: request.modelName) else {
|
||||
throw SdServerError.modelNotFound
|
||||
}
|
||||
return try await state.generate(request)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user