mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 16:23:28 +01:00
Support upscaling by 2x or 4x (previously only supported 4x)
This commit is contained in:
parent
6eb2d800fa
commit
852e129f9c
@ -76,7 +76,7 @@ def filter_images(task_data: TaskData, images: list, user_stopped):
|
||||
if task_data.use_face_correction and 'gfpgan' in task_data.use_face_correction.lower(): filters_to_apply.append('gfpgan')
|
||||
if task_data.use_upscale and 'realesrgan' in task_data.use_upscale.lower(): filters_to_apply.append('realesrgan')
|
||||
|
||||
return apply_filters(context, filters_to_apply, images)
|
||||
return apply_filters(context, filters_to_apply, images, scale=task_data.upscale_amount)
|
||||
|
||||
def construct_response(images: list, task_data: TaskData, base_seed: int):
|
||||
return [
|
||||
|
@ -29,6 +29,7 @@ class TaskData(BaseModel):
|
||||
|
||||
use_face_correction: str = None # or "GFPGANv1.3"
|
||||
use_upscale: str = None # or "RealESRGAN_x4plus" or "RealESRGAN_x4plus_anime_6B"
|
||||
upscale_amount: int = 4 # or 2
|
||||
use_stable_diffusion_model: str = "sd-v1-4"
|
||||
# use_stable_diffusion_config: str = "v1-inference"
|
||||
use_vae_model: str = None
|
||||
|
@ -20,6 +20,7 @@ TASK_TEXT_MAPPING = {
|
||||
'prompt_strength': 'Prompt Strength',
|
||||
'use_face_correction': 'Use Face Correction',
|
||||
'use_upscale': 'Use Upscaling',
|
||||
'upscale_amount': 'Upscale By',
|
||||
'sampler_name': 'Sampler',
|
||||
'negative_prompt': 'Negative Prompt',
|
||||
'use_stable_diffusion_model': 'Stable Diffusion model',
|
||||
@ -48,6 +49,8 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
|
||||
'use_face_correction': task_data.use_face_correction,
|
||||
'use_upscale': task_data.use_upscale,
|
||||
})
|
||||
if metadata['use_upscale'] is not None:
|
||||
metadata['upscale_amount'] = task_data.upscale_amount
|
||||
|
||||
# if text, format it in the text format expected by the UI
|
||||
is_txt_format = (task_data.metadata_output_format.lower() == 'txt')
|
||||
|
@ -234,7 +234,12 @@
|
||||
<li class="pl-5"><input id="stream_image_progress" name="stream_image_progress" type="checkbox"> <label for="stream_image_progress">Show a live preview <small>(uses more VRAM, slower images)</small></label></li>
|
||||
<li class="pl-5"><input id="use_face_correction" name="use_face_correction" type="checkbox"> <label for="use_face_correction">Fix incorrect faces and eyes <small>(uses GFPGAN)</small></label></li>
|
||||
<li class="pl-5">
|
||||
<input id="use_upscale" name="use_upscale" type="checkbox"> <label for="use_upscale">Upscale image by 4x with </label>
|
||||
<input id="use_upscale" name="use_upscale" type="checkbox"> <label for="use_upscale">Scale up by</label>
|
||||
<select id="upscale_amount" name="upscale_amount">
|
||||
<option value="2">2x</option>
|
||||
<option value="4" selected>4x</option>
|
||||
</select>
|
||||
with
|
||||
<select id="upscale_model" name="upscale_model">
|
||||
<option value="RealESRGAN_x4plus" selected>RealESRGAN_x4plus</option>
|
||||
<option value="RealESRGAN_x4plus_anime_6B">RealESRGAN_x4plus_anime_6B</option>
|
||||
|
@ -28,6 +28,7 @@ const SETTINGS_IDS_LIST = [
|
||||
"stream_image_progress",
|
||||
"use_face_correction",
|
||||
"use_upscale",
|
||||
"upscale_amount",
|
||||
"show_only_filtered_image",
|
||||
"upscale_model",
|
||||
"preview-image",
|
||||
|
@ -148,12 +148,14 @@ const TASK_MAPPING = {
|
||||
use_upscale: { name: 'Use Upscaling',
|
||||
setUI: (use_upscale) => {
|
||||
const oldVal = upscaleModelField.value
|
||||
upscaleModelField.value = use_upscale
|
||||
upscaleModelField.value = getModelPath(use_upscale, ['.pth'])
|
||||
if (upscaleModelField.value) { // Is a valid value for the field.
|
||||
useUpscalingField.checked = true
|
||||
upscaleModelField.disabled = false
|
||||
upscaleAmountField.disabled = false
|
||||
} else { // Not a valid value, restore the old value and disable the filter.
|
||||
upscaleModelField.disabled = true
|
||||
upscaleAmountField.disabled = true
|
||||
upscaleModelField.value = oldVal
|
||||
useUpscalingField.checked = false
|
||||
}
|
||||
@ -161,6 +163,13 @@ const TASK_MAPPING = {
|
||||
readUI: () => (useUpscalingField.checked ? upscaleModelField.value : undefined),
|
||||
parse: (val) => val
|
||||
},
|
||||
upscale_amount: { name: 'Upscale By',
|
||||
setUI: (upscale_amount) => {
|
||||
upscaleAmountField.value = upscale_amount
|
||||
},
|
||||
readUI: () => upscaleAmountField.value,
|
||||
parse: (val) => val
|
||||
},
|
||||
sampler_name: { name: 'Sampler',
|
||||
setUI: (sampler_name) => {
|
||||
samplerField.value = sampler_name
|
||||
@ -299,6 +308,7 @@ function restoreTaskToUI(task, fieldsToSkip) {
|
||||
maskSetting.checked = false
|
||||
}
|
||||
upscaleModelField.disabled = !useUpscalingField.checked
|
||||
upscaleAmountField.disabled = !useUpscalingField.checked
|
||||
|
||||
// Show the source picture if present
|
||||
initImagePreview.src = (task.reqBody.init_image == undefined ? '' : task.reqBody.init_image)
|
||||
@ -348,6 +358,7 @@ const TASK_TEXT_MAPPING = {
|
||||
prompt_strength: 'Prompt Strength',
|
||||
use_face_correction: 'Use Face Correction',
|
||||
use_upscale: 'Use Upscaling',
|
||||
upscale_amount: 'Upscale By',
|
||||
sampler_name: 'Sampler',
|
||||
negative_prompt: 'Negative Prompt',
|
||||
use_stable_diffusion_model: 'Stable Diffusion model',
|
||||
|
@ -35,6 +35,7 @@ let samplerSelectionContainer = document.querySelector("#samplerSelection")
|
||||
let useFaceCorrectionField = document.querySelector("#use_face_correction")
|
||||
let useUpscalingField = document.querySelector("#use_upscale")
|
||||
let upscaleModelField = document.querySelector("#upscale_model")
|
||||
let upscaleAmountField = document.querySelector("#upscale_amount")
|
||||
let stableDiffusionModelField = document.querySelector('#stable_diffusion_model')
|
||||
let vaeModelField = document.querySelector('#vae_model')
|
||||
let hypernetworkModelField = document.querySelector('#hypernetwork_model')
|
||||
@ -814,7 +815,7 @@ function createTask(task) {
|
||||
taskConfig += `, <b>Fix Faces:</b> ${task.reqBody.use_face_correction}`
|
||||
}
|
||||
if (task.reqBody.use_upscale) {
|
||||
taskConfig += `, <b>Upscale:</b> ${task.reqBody.use_upscale}`
|
||||
taskConfig += `, <b>Upscale:</b> ${task.reqBody.use_upscale} (${task.reqBody.upscale_amount}x)`
|
||||
}
|
||||
if (task.reqBody.use_hypernetwork_model) {
|
||||
taskConfig += `, <b>Hypernetwork:</b> ${task.reqBody.use_hypernetwork_model}`
|
||||
@ -965,6 +966,7 @@ function getCurrentUserRequest() {
|
||||
}
|
||||
if (useUpscalingField.checked) {
|
||||
newTask.reqBody.use_upscale = upscaleModelField.value
|
||||
newTask.reqBody.upscale_amount = upscaleAmountField.value
|
||||
}
|
||||
if (hypernetworkModelField.value) {
|
||||
newTask.reqBody.use_hypernetwork_model = hypernetworkModelField.value
|
||||
@ -1160,8 +1162,10 @@ function onDimensionChange() {
|
||||
diskPathField.disabled = !saveToDiskField.checked
|
||||
|
||||
upscaleModelField.disabled = !useUpscalingField.checked
|
||||
upscaleAmountField.disabled = !useUpscalingField.checked
|
||||
useUpscalingField.addEventListener('change', function(e) {
|
||||
upscaleModelField.disabled = !this.checked
|
||||
upscaleAmountField.disabled = !this.checked
|
||||
})
|
||||
|
||||
makeImageBtn.addEventListener('click', makeImage)
|
||||
|
Loading…
Reference in New Issue
Block a user