/* eslint-disable react-hooks/exhaustive-deps */ /* eslint-disable jsx-a11y/control-has-associated-label */ import { ArrowLeftIcon, InformationCircleIcon } from '@heroicons/react/outline' import { useEffect, useRef, useState } from 'react' import { useClickAway } from 'react-use' import Button from './components/Button' import FileSelect from './components/FileSelect' import Modal from './components/Modal' import Editor from './Editor' import { resizeImageFile } from './utils' import Progress from './components/Progress' import { downloadModel } from './adapters/cache' import * as m from './paraglide/messages' import { languageTag, onSetLanguageTag, setLanguageTag, } from './paraglide/runtime' function App() { const [file, setFile] = useState() const [stateLanguageTag, setStateLanguageTag] = useState<'en' | 'zh'>('zh') onSetLanguageTag(() => setStateLanguageTag(languageTag())) const [showAbout, setShowAbout] = useState(false) const modalRef = useRef(null) const [downloadProgress, setDownloadProgress] = useState(100) useEffect(() => { downloadModel('inpaint', setDownloadProgress) }, []) useClickAway(modalRef, () => { setShowAbout(false) }) async function startWithDemoImage(img: string) { const imgBlob = await fetch(`/examples/${img}.jpeg`).then(r => r.blob()) setFile(new File([imgBlob], `${img}.jpeg`, { type: 'image/jpeg' })) } return (
Inpaint-web
{file ? ( ) : ( <>
{ const { file: resizedFile } = await resizeImageFile( f, 1024 * 4 ) setFile(resizedFile) }} />
{m.try_it_images()}
{['bag', 'dog', 'car', 'bird', 'jacket', 'shoe', 'paris'].map( image => (
startWithDemoImage(image)} role="button" onKeyDown={() => startWithDemoImage(image)} tabIndex={-1} > {image}
) )}
)}
{showAbout && (

{' '} 任何问题到:{' '} Inpaint-web {' '} 反馈

{' '} For any questions, please go to:{' '} Inpaint-web {' '} to provide feedback.

)} {!(downloadProgress === 100) && (

{m.inpaint_model_download_message()}

)}
) } export default App