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

enum Predictable #91

Open
tonyljx opened this issue Oct 13, 2024 · 0 comments
Open

enum Predictable #91

tonyljx opened this issue Oct 13, 2024 · 0 comments

Comments

@tonyljx
Copy link

tonyljx commented Oct 13, 2024

Hi there

I am reading https://replicate.com/docs/guides/swiftui to use swiftui replicate sdk to call the model.

And i find out that some models do not have the version on web page.

Question1

  1. Which method do you recommend if I need to use different replicate models?

seems like in getModel Method, I will use multiple if else because different models need different input

enum StableDiffusion: Predictable {
  static var modelID = "stability-ai/stable-diffusion"
  static let versionID = "db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf"
 
  struct Input: Codable {
      let prompt: String
  }
 
  typealias Output = [URL]
}

or

let model = try await replicate.getModel("stability-ai/stable-diffusion-3")
if let latestVersion = model.latestVersion {
    let prompt = "a 19th century portrait of a gentleman otter"
    let prediction = try await replicate.createPrediction(version: latestVersion.id,
                                                       input: ["prompt": "\(prompt)"],
                                                       wait: true)
    print(prediction.id)
    // "s654jhww3hrm60ch11v8t3zpkg"
    print(prediction.output)
    // ["https://replicate.delivery/yhqm/bh9SsjWXY3pGKJyQzYjQlsZPzcNZ4EYOeEsPjFytc5TjYeNTA/R8_SD3_00001_.webp"]
}

Question2

In enum Predictable, how can I receive input image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant