import React, { ReactNode } from 'react' import { useRecoilState } from 'recoil' import { settingState } from '../../store/Atoms' import Selector from '../shared/Selector' import NumberInputSetting from './NumberInputSetting' import SettingBlock from './SettingBlock' export enum AIModel { LAMA = 'lama', LDM = 'ldm', } function ModelSettingBlock() { const [setting, setSettingState] = useRecoilState(settingState) const onModelChange = (value: AIModel) => { setSettingState(old => { return { ...old, model: value } }) } const renderModelDesc = ( name: string, paperUrl: string, githubUrl: string ) => { return (
{name} {githubUrl}
) } const renderLDMModelDesc = () => { return (
{renderModelDesc( 'High-Resolution Image Synthesis with Latent Diffusion Models', 'https://arxiv.org/abs/2112.10752', 'https://github.com/CompVis/latent-diffusion' )} { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, ldmSteps: val } }) }} />
) } const renderOptionDesc = (): ReactNode => { switch (setting.model) { case AIModel.LAMA: return renderModelDesc( 'Resolution-robust Large Mask Inpainting with Fourier Convolutions', 'https://arxiv.org/abs/2109.07161', 'https://github.com/saic-mdal/lama' ) case AIModel.LDM: return renderLDMModelDesc() default: return <> } } return ( onModelChange(val as AIModel)} /> } optionDesc={renderOptionDesc()} /> ) } export default ModelSettingBlock