mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 03:17:54 +01:00
Add upscale amount control to DrawThings
This commit is contained in:
parent
24b6f99abf
commit
110d343eea
@ -1152,6 +1152,27 @@ async function getVladRemoteUpscalers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getDrawthingsRemoteUpscalers() {
|
||||||
|
try {
|
||||||
|
const result = await fetch('/api/sd/drawthings/get-upscaler', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: getRequestHeaders(),
|
||||||
|
body: JSON.stringify(getSdRequestBody()),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.ok) {
|
||||||
|
throw new Error('SD DrawThings API returned an error.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await result.text();
|
||||||
|
|
||||||
|
return data ? [data] : ['N/A'];
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return ['N/A'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function updateAutoRemoteModel() {
|
async function updateAutoRemoteModel() {
|
||||||
try {
|
try {
|
||||||
const result = await fetch('/api/sd/set-model', {
|
const result = await fetch('/api/sd/set-model', {
|
||||||
@ -1586,6 +1607,21 @@ async function loadDrawthingsModels() {
|
|||||||
|
|
||||||
const data = [{ value: currentModel, text: currentModel }];
|
const data = [{ value: currentModel, text: currentModel }];
|
||||||
|
|
||||||
|
|
||||||
|
const upscalers = await getDrawthingsRemoteUpscalers();
|
||||||
|
|
||||||
|
if (Array.isArray(upscalers) && upscalers.length > 0) {
|
||||||
|
$('#sd_hr_upscaler').empty();
|
||||||
|
|
||||||
|
for (const upscaler of upscalers) {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.innerText = upscaler;
|
||||||
|
option.value = upscaler;
|
||||||
|
option.selected = upscaler === extension_settings.sd.hr_upscaler;
|
||||||
|
$('#sd_hr_upscaler').append(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Error loading DrawThings API models:', error);
|
console.log('Error loading DrawThings API models:', error);
|
||||||
@ -2469,6 +2505,7 @@ async function generateDrawthingsImage(prompt, negativePrompt) {
|
|||||||
enable_hr: !!extension_settings.sd.enable_hr,
|
enable_hr: !!extension_settings.sd.enable_hr,
|
||||||
denoising_strength: extension_settings.sd.denoising_strength,
|
denoising_strength: extension_settings.sd.denoising_strength,
|
||||||
clip_skip: extension_settings.sd.clip_skip,
|
clip_skip: extension_settings.sd.clip_skip,
|
||||||
|
upscaler_scale: extension_settings.sd.hr_scale,
|
||||||
// TODO: advanced API parameters: hr, upscaler
|
// TODO: advanced API parameters: hr, upscaler
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -236,11 +236,13 @@
|
|||||||
<label for="sd_clip_skip">CLIP Skip (<span id="sd_clip_skip_value"></span>)</label>
|
<label for="sd_clip_skip">CLIP Skip (<span id="sd_clip_skip_value"></span>)</label>
|
||||||
<input type="range" id="sd_clip_skip" min="{{clip_skip_min}}" max="{{clip_skip_max}}" step="{{clip_skip_step}}" value="{{clip_skip}}" />
|
<input type="range" id="sd_clip_skip" min="{{clip_skip_min}}" max="{{clip_skip_max}}" step="{{clip_skip_step}}" value="{{clip_skip}}" />
|
||||||
</div>
|
</div>
|
||||||
<div data-sd-source="auto,vlad">
|
<div data-sd-source="auto,vlad,drawthings">
|
||||||
<label for="sd_hr_upscaler" data-i18n="Upscaler">Upscaler</label>
|
<label for="sd_hr_upscaler" data-i18n="Upscaler">Upscaler</label>
|
||||||
<select id="sd_hr_upscaler"></select>
|
<select id="sd_hr_upscaler"></select>
|
||||||
<label for="sd_hr_scale"><span data-i18n="Upscale by">Upscale by</span> (<span id="sd_hr_scale_value"></span>)</label>
|
<label for="sd_hr_scale"><span data-i18n="Upscale by">Upscale by</span> (<span id="sd_hr_scale_value"></span>)</label>
|
||||||
<input id="sd_hr_scale" type="range" min="{{hr_scale_min}}" max="{{hr_scale_max}}" step="{{hr_scale_step}}" value="{{hr_scale}}" />
|
<input id="sd_hr_scale" type="range" min="{{hr_scale_min}}" max="{{hr_scale_max}}" step="{{hr_scale_step}}" value="{{hr_scale}}" />
|
||||||
|
</div>
|
||||||
|
<div data-sd-source="auto,vlad">
|
||||||
<label for="sd_denoising_strength"><span data-i18n="Denoising strength">Denoising strength</span> (<span id="sd_denoising_strength_value"></span>)</label>
|
<label for="sd_denoising_strength"><span data-i18n="Denoising strength">Denoising strength</span> (<span id="sd_denoising_strength_value"></span>)</label>
|
||||||
<input id="sd_denoising_strength" type="range" min="{{denoising_strength_min}}" max="{{denoising_strength_max}}" step="{{denoising_strength_step}}" value="{{denoising_strength}}" />
|
<input id="sd_denoising_strength" type="range" min="{{denoising_strength_min}}" max="{{denoising_strength_max}}" step="{{denoising_strength_step}}" value="{{denoising_strength}}" />
|
||||||
<label for="sd_hr_second_pass_steps"><span data-i18n="Hires steps (2nd pass)">Hires steps (2nd pass)</span> (<span id="sd_hr_second_pass_steps_value"></span>)</label>
|
<label for="sd_hr_second_pass_steps"><span data-i18n="Hires steps (2nd pass)">Hires steps (2nd pass)</span> (<span id="sd_hr_second_pass_steps_value"></span>)</label>
|
||||||
|
@ -676,6 +676,23 @@ drawthings.post('/get-model', jsonParser, async (request, response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
drawthings.post('/get-upscaler', jsonParser, async (request, response) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(request.body.url);
|
||||||
|
url.pathname = '/';
|
||||||
|
|
||||||
|
const result = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
const data = await result.json();
|
||||||
|
|
||||||
|
return response.send(data['upscaler']);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
drawthings.post('/generate', jsonParser, async (request, response) => {
|
drawthings.post('/generate', jsonParser, async (request, response) => {
|
||||||
try {
|
try {
|
||||||
console.log('SD DrawThings API request:', request.body);
|
console.log('SD DrawThings API request:', request.body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user