diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js
index 8bcd3bada..70b82dcc4 100644
--- a/public/scripts/extensions/stable-diffusion/index.js
+++ b/public/scripts/extensions/stable-diffusion/index.js
@@ -930,6 +930,10 @@ const resolutionOptions = {
sd_res_768x1344: { width: 768, height: 1344, name: '768x1344 (3:4, SDXL)' },
sd_res_1536x640: { width: 1536, height: 640, name: '1536x640 (24:10, SDXL)' },
sd_res_640x1536: { width: 640, height: 1536, name: '640x1536 (10:24, SDXL)' },
+ sd_res_1536x1024: { width: 1536, height: 1024, name: '1536x1024 (3:2, ChatGPT)' },
+ sd_res_1024x1536: { width: 1024, height: 1536, name: '1024x1536 (2:3, ChatGPT)' },
+ sd_res_1024x1792: { width: 1024, height: 1792, name: '1024x1792 (4:7, DALL-E)' },
+ sd_res_1792x1024: { width: 1792, height: 1024, name: '1792x1024 (7:4, DALL-E)' },
};
function onResolutionChange() {
@@ -1947,8 +1951,9 @@ async function loadDrawthingsModels() {
async function loadOpenAiModels() {
return [
- { value: 'dall-e-3', text: 'DALL-E 3' },
- { value: 'dall-e-2', text: 'DALL-E 2' },
+ { value: 'gpt-image-1', text: 'gpt-image-1' },
+ { value: 'dall-e-3', text: 'dall-e-3' },
+ { value: 'dall-e-2', text: 'dall-e-2' },
];
}
@@ -3250,9 +3255,11 @@ function getNovelParams() {
async function generateOpenAiImage(prompt, signal) {
const dalle2PromptLimit = 1000;
const dalle3PromptLimit = 4000;
+ const gptImgPromptLimit = 32000;
const isDalle2 = extension_settings.sd.model === 'dall-e-2';
const isDalle3 = extension_settings.sd.model === 'dall-e-3';
+ const isGptImg = extension_settings.sd.model === 'gpt-image-1';
if (isDalle2 && prompt.length > dalle2PromptLimit) {
prompt = prompt.substring(0, dalle2PromptLimit);
@@ -3262,6 +3269,10 @@ async function generateOpenAiImage(prompt, signal) {
prompt = prompt.substring(0, dalle3PromptLimit);
}
+ if (isGptImg && prompt.length > gptImgPromptLimit) {
+ prompt = prompt.substring(0, gptImgPromptLimit);
+ }
+
let width = 1024;
let height = 1024;
let aspectRatio = extension_settings.sd.width / extension_settings.sd.height;
@@ -3274,6 +3285,14 @@ async function generateOpenAiImage(prompt, signal) {
width = 1792;
}
+ if (isGptImg && aspectRatio < 1) {
+ height = 1536;
+ }
+
+ if (isGptImg && aspectRatio > 1) {
+ width = 1536;
+ }
+
if (isDalle2 && (extension_settings.sd.width <= 512 && extension_settings.sd.height <= 512)) {
width = 512;
height = 512;
@@ -3290,7 +3309,8 @@ async function generateOpenAiImage(prompt, signal) {
n: 1,
quality: isDalle3 ? extension_settings.sd.openai_quality : undefined,
style: isDalle3 ? extension_settings.sd.openai_style : undefined,
- response_format: 'b64_json',
+ response_format: isDalle2 || isDalle3 ? 'b64_json' : undefined,
+ moderation: isGptImg ? 'low' : undefined,
}),
});
diff --git a/public/scripts/extensions/stable-diffusion/settings.html b/public/scripts/extensions/stable-diffusion/settings.html
index b98c87cd8..5f7174c63 100644
--- a/public/scripts/extensions/stable-diffusion/settings.html
+++ b/public/scripts/extensions/stable-diffusion/settings.html
@@ -45,7 +45,7 @@
-
+