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

feat: compatible with nai-v3 #241

Merged
merged 3 commits into from
Mar 11, 2024
Merged

feat: compatible with nai-v3 #241

merged 3 commits into from
Mar 11, 2024

Conversation

dragon-fish
Copy link
Member

No description provided.

@dragon-fish
Copy link
Member Author

这个 PR 解决了以下问题:

  1. 即使 model 配置为 nai-v3 也会返回 nai1 的结果
  • 猜测导致该结果的核心问题应该是预设的 base prompt 过旧以及 scale 值超过 nai3 的上限 (max 10)
  1. 拿到 API 返回的结果后报错 startsWith does not exist on url,NovelAI 的 content-type 返回头的值现在是binary/octet-stream,不可作为唯一的判断依据

@dragon-fish
Copy link
Member Author

dragon-fish commented Mar 10, 2024

FYI

request payload with default settings

{
    "input": "<user-input>, best quality, amazing quality, very aesthetic, absurdres",
    "model": "nai-diffusion-3",
    "action": "generate",
    "parameters": {
        "params_version": 1,
        "width": 832,
        "height": 1216,
        "scale": 5,
        "sampler": "k_euler_ancestral",
        "steps": 28,
        "n_samples": 1,
        "ucPreset": 0,
        "qualityToggle": true,
        "sm": false,
        "sm_dyn": false,
        "dynamic_thresholding": false,
        "controlnet_strength": 1,
        "legacy": false,
        "add_original_image": true,
        "uncond_scale": 1,
        "cfg_rescale": 0,
        "noise_schedule": "native",
        "legacy_v3_extend": false,
        "reference_information_extracted": 1,
        "reference_strength": 0.6,
        "seed": 1234567890,
        "negative_prompt": "lowres, {bad}, error, fewer, extra, missing, worst quality, jpeg artifacts, bad quality, watermark, unfinished, displeasing, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]"
    }
}

response headers

Access-Control-Allow-Origin: *
Cf-Cache-Status: DYNAMIC
Cf-Ray: ...
Content-Disposition: attachment; filename=images.zip
Content-Type: binary/octet-stream
Date: ...
Server: cloudflare
Vary: Origin

@dragon-fish
Copy link
Member Author

另外发现现在生图的接口为 https://image.novelai.net/ai/generate-image
但即便继续使用 api.novelai.net 也不影响生成结果

@@ -146,7 +146,7 @@ export interface PromptConfig {
}

export const PromptConfig: Schema<PromptConfig> = Schema.object({
basePrompt: Schema.computed(Schema.string().role('textarea'), options).description('默认附加的标签。').default('masterpiece, best quality'),
basePrompt: Schema.computed(Schema.string().role('textarea'), options).description('默认附加的标签。').default('best quality, amazing quality, very aesthetic, absurdres'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change affects every backend not only nai-v3, would it make nai-v1 or other backends generate worse images? If no, it is okay for me.

这个改动影响了所有的后端不仅仅是 nai-v3,它会让 nai-v1 或其他后端生成更糟的图片吗?如否,它对我来说是可以的。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有测试过,我过会儿测试一下
或者也可以把预设 model 改为 nai-v3,因为 v1 已经被官方标记为不推荐了

Copy link
Member

@MaikoTan MaikoTan Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者也可以把预设 model 改为 nai-v3,因为 v1 已经被官方标记为不推荐了

This is okay to me, can you change the default model to nai-v3 as well?

这听起来可以,你能顺便改默认模型到 nai-v3 吗?

After this, I will merge the PR.

之后,我会合并 PR。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果修改默认 model 为 nai-v3,我们是否应该将 scale 的预设值同步修改为 5?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果修改默认 model 为 nai-v3,我们是否应该将 scale 的预设值同步修改为 5?

Sure, will you double-check and change all relative parameters to match the nai v3 afterwards?

当然,您会仔细检查并更改所有相关参数以匹配 nai v3 吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will you double-check and change all relative parameters to match the nai v3 afterwards?

当然,您会仔细检查并更改所有相关参数以匹配 nai v3 吗?

done

src/index.ts Show resolved Hide resolved
@MaikoTan
Copy link
Member

Looks good to me, thanks for your help!

@dragon-fish
Copy link
Member Author

@MaikoTan 你合吧,我没有权限

@shigma shigma changed the title fix: compatible with nai-v3 feat: compatible with nai-v3 Mar 11, 2024
@shigma shigma merged commit 4ec0af5 into main Mar 11, 2024
3 of 4 checks passed
@shigma shigma deleted the dragon-fish/patch-nai3 branch March 11, 2024 12:33
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

Successfully merging this pull request may close these issues.

4 participants