Spaces:
Runtime error
Runtime error
Julian Bilcke commited on
Commit ·
6b27fdb
1
Parent(s): 0f203e8
wait.. what?
Browse filesFiles changed (3)
309 unmodified lines310311312313314315316309 unmodified lines"painting","3D render"],}}export type PresetName = keyof typeof presets309 unmodified lines310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386309 unmodified lines"painting","3D render"],},render: {label: "3D Render",family: "european",color: "color",font: "actionman",llmPrompt: "new movie",imagePrompt: (prompt: string) => [`3D render`,`Blender`,`3D animation`,`Unreal engine`,`${prompt}`,],negativePrompt: () => ["manga","anime","american comic","grayscale","monochrome","painting"],},/*psx: {label: "PSX",family: "european",color: "color",font: "actionman",llmPrompt: "new movie",imagePrompt: (prompt: string) => [`videogame screenshot`,`3dfx`,`3D dos game`,`software rendering`,`${prompt}`,],negativePrompt: () => ["manga","anime","american comic","grayscale","monochrome","painting"],},*//*pixel: {label: "Pixel",family: "european",color: "color",font: "actionman",llmPrompt: "new movie",imagePrompt: (prompt: string) => [`pixelart`,`isometric`,`pixelated`,`low res`,`${prompt}`,],negativePrompt: () => ["manga","anime","american comic","grayscale","monochrome","painting"],},*/}export type PresetName = keyof typeof presets
19 unmodified lines2021222324252627282930313214 unmodified lines47484950515245 unmodified lines989910010110210310411 unmodified lines11611711811912012112212312412512612712812919 unmodified linesclassName = "",width = 1,height = 1,delay = 0,}: {panel: numberclassName?: stringwidth?: numberheight?: numberdelay?: number}) {const font = useStore(state => state.font)const preset = useStore(state => state.preset)14 unmodified linesconst timeoutRef = useRef<any>(null)// since this run in its own loop, we need to use references everywhere// but perhaps this could be refactoreduseEffect(() => {45 unmodified linesclearTimeout(timeoutRef.current)if (!renderedRef.current?.renderId || renderedRef.current?.status !== "pending") {timeoutRef.current = setTimeout(checkStatus, 2500)return}try {11 unmodified linesif (newRendered.status === "pending") {// console.log("job not finished")timeoutRef.current = setTimeout(checkStatus, 2500)} else {console.log("panel finished!")setGeneratingImages(panel, false)}} catch (err) {console.error(err)timeoutRef.current = setTimeout(checkStatus, 2500)}})}19 unmodified lines202122232425262728293014 unmodified lines454647484950515245 unmodified lines989910010110210310411 unmodified lines11611711811912012112212312412512612712812913013113213313413513613713819 unmodified linesclassName = "",width = 1,height = 1,}: {panel: numberclassName?: stringwidth?: numberheight?: number}) {const font = useStore(state => state.font)const preset = useStore(state => state.preset)14 unmodified linesconst timeoutRef = useRef<any>(null)const delay = 3000 + (1000 * panel)// since this run in its own loop, we need to use references everywhere// but perhaps this could be refactoreduseEffect(() => {45 unmodified linesclearTimeout(timeoutRef.current)if (!renderedRef.current?.renderId || renderedRef.current?.status !== "pending") {timeoutRef.current = setTimeout(checkStatus, delay)return}try {11 unmodified linesif (newRendered.status === "pending") {// console.log("job not finished")timeoutRef.current = setTimeout(checkStatus, delay)} else if (newRendered.status === "error") {console.log(`panel got an error :/ "${newRendered.error}", but let's try to recover..`)try {const newAttempt = await newRender({ prompt, width, height })setRendered(renderedRef.current = newAttempt)} catch (err) {console.error("yeah sorry, something is wrong.. aborting")setGeneratingImages(panel, false)}} else {console.log("panel finished!")setGeneratingImages(panel, false)}} catch (err) {console.error(err)timeoutRef.current = setTimeout(checkStatus, delay)}})}
23 unmodified lines2425262728293023 unmodified lines// normally it takes 45, and we will try to go below,// but to be safe let's set the counter a 1 minconst nbSeconds = 60 // 1 minconst amountInPercent = 100 / (nbUpdatesPerSec * nbSeconds) // 0.333progressRef.current = Math.min(100, progressRef.current + amountInPercent)23 unmodified lines2425262728293023 unmodified lines// normally it takes 45, and we will try to go below,// but to be safe let's set the counter a 1 minconst nbSeconds = 80 // 1 minconst amountInPercent = 100 / (nbUpdatesPerSec * nbSeconds) // 0.333progressRef.current = Math.min(100, progressRef.current + amountInPercent)
src/app/engine/presets.ts+71-1
src/app/interface/panel/index.tsx+14-5
src/app/interface/progress/index.tsx+1-1