import React, { ReactNode } from 'react' import { useRecoilState } from 'recoil' import { hdSettingsState, settingState } from '../../store/Atoms' import Selector from '../shared/Selector' import NumberInputSetting from './NumberInputSetting' import SettingBlock from './SettingBlock' export enum HDStrategy { ORIGINAL = 'Original', RESIZE = 'Resize', CROP = 'Crop', } export enum LDMSampler { ddim = 'ddim', plms = 'plms', } function HDSettingBlock() { const [hdSettings, setHDSettings] = useRecoilState(hdSettingsState) if (!hdSettings?.enabled) { return <> } const onStrategyChange = (value: HDStrategy) => { setHDSettings({ hdStrategy: value }) } const onResizeLimitChange = (value: string) => { const val = value.length === 0 ? 0 : parseInt(value, 10) setHDSettings({ hdStrategyResizeLimit: val }) } const onCropTriggerSizeChange = (value: string) => { const val = value.length === 0 ? 0 : parseInt(value, 10) setHDSettings({ hdStrategyCropTrigerSize: val }) } const onCropMarginChange = (value: string) => { const val = value.length === 0 ? 0 : parseInt(value, 10) setHDSettings({ hdStrategyCropMargin: val }) } const renderOriginalOptionDesc = () => { return (
Use original picture, suitable for picture size below 2K. Try{' '}
onStrategyChange(HDStrategy.RESIZE)} > Resize
{' or '}
onStrategyChange(HDStrategy.CROP)} > Crop
{' '} if you didn't get good results or have GPU memory issue.
) } const renderResizeOptionDesc = () => { return ( <>
Resize the longer side of the image to a specific size, then do inpainting on the resized image.
) } const renderCropOptionDesc = () => { return ( <>
Crop masking area from the original image to do inpainting.
) } const renderHDStrategyOptionDesc = (): ReactNode => { switch (hdSettings.hdStrategy) { case HDStrategy.ORIGINAL: return renderOriginalOptionDesc() case HDStrategy.CROP: return renderCropOptionDesc() case HDStrategy.RESIZE: return renderResizeOptionDesc() default: return renderOriginalOptionDesc() } } return ( onStrategyChange(val as HDStrategy)} /> } optionDesc={renderHDStrategyOptionDesc()} /> ) } export default HDSettingBlock