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

Sd images fix 003 #324

Merged
merged 3 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/modules/sd-images/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ export const getParamsFromPrompt = (originalPrompt: string, model?: IModel): IPa
prompt = prompt.replace(/--model (.*)/, '')
}

if (!modelAlias) {
const modelMatch = prompt.match(/--model (.*) /)

if (modelMatch) {
modelAlias = modelMatch[1]

prompt = prompt.replace(/--model (.*) /, '')
}
}

// Add 'leogirl' to trigger /leo model
if (model && model.name === 'leosams_helloworld' && !prompt.includes('leogirl')) {
prompt = 'leogirl ' + prompt
Expand Down
5 changes: 4 additions & 1 deletion src/modules/sd-images/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class SDNodeApi {
}

if (options.format === MEDIA_FORMAT.GIF) {
const modelFromParams = params.modelAlias ? getModelByParam(params.modelAlias) : null
const modelPath = (modelFromParams ?? options.model).path

const { images } = await this.client.txt2img({
prompt: params.promptWithoutParams,
negativePrompt: params.negativePrompt,
Expand All @@ -75,7 +78,7 @@ export class SDNodeApi {
loraName: params.loraName,
loraStrength,
seed: options.seed ?? params.seed,
model: (params.modelAlias && getModelByParam(params.modelAlias)?.path) ?? options.model.path,
model: modelPath,
batchSize: 16,
format: options.format
}, server)
Expand Down