mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
start building out node translations from frontend state and add notes about missing features
This commit is contained in:
parent
ca41a52174
commit
660e665cf3
150
invokeai/frontend/web/src/common/util/buildNodes.ts
Normal file
150
invokeai/frontend/web/src/common/util/buildNodes.ts
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import { RootState } from 'app/store';
|
||||||
|
import {
|
||||||
|
ImageToImageInvocation,
|
||||||
|
RestoreFaceInvocation,
|
||||||
|
TextToImageInvocation,
|
||||||
|
UpscaleInvocation,
|
||||||
|
} from 'services/api';
|
||||||
|
|
||||||
|
// fe todo export sampler types
|
||||||
|
// fe todo fix model type (frontend uses null, backend uses undefined)
|
||||||
|
// fe todo update front end to store to have whole image field (vs just name)
|
||||||
|
// be todo add symmetry fields
|
||||||
|
// be todo variations....
|
||||||
|
|
||||||
|
export function buildTxt2ImgNode(state: RootState): TextToImageInvocation {
|
||||||
|
const { generation, system } = state;
|
||||||
|
|
||||||
|
const { shouldDisplayInProgressType, openModel } = system;
|
||||||
|
|
||||||
|
const {
|
||||||
|
prompt,
|
||||||
|
seed,
|
||||||
|
steps,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
cfgScale: cfg_scale,
|
||||||
|
sampler,
|
||||||
|
seamless,
|
||||||
|
} = generation;
|
||||||
|
|
||||||
|
// missing fields in TextToImageInvocation: strength, hires_fix
|
||||||
|
return {
|
||||||
|
id: uuidv4(),
|
||||||
|
type: 'txt2img',
|
||||||
|
prompt,
|
||||||
|
seed,
|
||||||
|
steps,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
cfg_scale,
|
||||||
|
sampler_name: sampler as
|
||||||
|
| 'ddim'
|
||||||
|
| 'dpmpp_2'
|
||||||
|
| 'k_dpm_2'
|
||||||
|
| 'k_dpm_2_a'
|
||||||
|
| 'k_dpmpp_2'
|
||||||
|
| 'k_euler'
|
||||||
|
| 'k_euler_a'
|
||||||
|
| 'k_heun'
|
||||||
|
| 'k_lms'
|
||||||
|
| 'plms'
|
||||||
|
| undefined,
|
||||||
|
seamless,
|
||||||
|
model: openModel as string | undefined,
|
||||||
|
progress_images: shouldDisplayInProgressType === 'full-res',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildImg2ImgNode(state: RootState): ImageToImageInvocation {
|
||||||
|
const { generation, system } = state;
|
||||||
|
|
||||||
|
const { shouldDisplayInProgressType, openModel: model } = system;
|
||||||
|
|
||||||
|
const {
|
||||||
|
prompt,
|
||||||
|
seed,
|
||||||
|
steps,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
cfgScale,
|
||||||
|
sampler,
|
||||||
|
seamless,
|
||||||
|
img2imgStrength: strength,
|
||||||
|
shouldFitToWidthHeight: fit,
|
||||||
|
initialImage,
|
||||||
|
} = generation;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: 'a',
|
||||||
|
type: 'img2img',
|
||||||
|
prompt,
|
||||||
|
seed,
|
||||||
|
steps,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
cfg_scale: cfgScale,
|
||||||
|
sampler_name: sampler as
|
||||||
|
| 'ddim'
|
||||||
|
| 'dpmpp_2'
|
||||||
|
| 'k_dpm_2'
|
||||||
|
| 'k_dpm_2_a'
|
||||||
|
| 'k_dpmpp_2'
|
||||||
|
| 'k_euler'
|
||||||
|
| 'k_euler_a'
|
||||||
|
| 'k_heun'
|
||||||
|
| 'k_lms'
|
||||||
|
| 'plms'
|
||||||
|
| undefined,
|
||||||
|
seamless,
|
||||||
|
model: model as string | undefined,
|
||||||
|
progress_images: shouldDisplayInProgressType === 'full-res',
|
||||||
|
image: {
|
||||||
|
image_name:
|
||||||
|
typeof initialImage === 'string' ? initialImage : initialImage?.url,
|
||||||
|
},
|
||||||
|
strength,
|
||||||
|
fit,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildFacetoolNode(state: RootState): RestoreFaceInvocation {
|
||||||
|
const { generation, postprocessing } = state;
|
||||||
|
|
||||||
|
const { initialImage } = generation;
|
||||||
|
|
||||||
|
const { facetoolStrength: strength } = postprocessing;
|
||||||
|
|
||||||
|
// missing fields in RestoreFaceInvocation: type, codeformer_fidelity
|
||||||
|
return {
|
||||||
|
id: uuidv4(),
|
||||||
|
type: 'restore_face',
|
||||||
|
image: {
|
||||||
|
image_name:
|
||||||
|
typeof initialImage === 'string' ? initialImage : initialImage?.url,
|
||||||
|
},
|
||||||
|
strength,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// is this ESRGAN??
|
||||||
|
export function buildUpscaleNode(state: RootState): UpscaleInvocation {
|
||||||
|
const { generation, postprocessing } = state;
|
||||||
|
|
||||||
|
const { initialImage } = generation;
|
||||||
|
|
||||||
|
const { upscalingLevel: level, upscalingStrength: strength } = postprocessing;
|
||||||
|
|
||||||
|
// missing fields in UpscaleInvocation: denoise_str
|
||||||
|
return {
|
||||||
|
id: uuidv4(),
|
||||||
|
type: 'upscale',
|
||||||
|
image: {
|
||||||
|
image_name:
|
||||||
|
typeof initialImage === 'string' ? initialImage : initialImage?.url,
|
||||||
|
},
|
||||||
|
strength,
|
||||||
|
level,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user