diff --git a/apps/demo-nextjs-app-router/app/page.tsx b/apps/demo-nextjs-app-router/app/page.tsx index 2313dd1..56cf998 100644 --- a/apps/demo-nextjs-app-router/app/page.tsx +++ b/apps/demo-nextjs-app-router/app/page.tsx @@ -19,7 +19,7 @@ type Image = { file_size: number; }; type Result = { - images: Image[]; + image: Image; }; // @snippet:end @@ -42,12 +42,13 @@ function Error(props: ErrorProps) { } const DEFAULT_PROMPT = - 'a city landscape of a cyberpunk metropolis, raining, purple, pink and teal neon lights, highly detailed, uhd'; + '(masterpiece:1.4), (best quality), (detailed), Medieval village scene with busy streets and castle in the distance'; export default function Home() { // @snippet:start("client.ui.state") // Input state const [prompt, setPrompt] = useState(DEFAULT_PROMPT); + const [imageFile, setImageFile] = useState(null); // Result state const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -59,7 +60,10 @@ export default function Home() { if (!result) { return null; } - return result.images[0]; + if (result.image) { + return result.image; + } + return null; }, [result]); const reset = () => { @@ -76,24 +80,27 @@ export default function Home() { setLoading(true); const start = Date.now(); try { - const result: Result = await fal.subscribe('110602490-lora', { - input: { - prompt, - model_name: 'stabilityai/stable-diffusion-xl-base-1.0', - image_size: 'square_hd', - }, - pollInterval: 5000, // Default is 1000 (every 1s) - logs: true, - onQueueUpdate(update) { - setElapsedTime(Date.now() - start); - if ( - update.status === 'IN_PROGRESS' || - update.status === 'COMPLETED' - ) { - setLogs((update.logs || []).map((log) => log.message)); - } - }, - }); + const result: Result = await fal.subscribe( + '54285744-illusion-diffusion', + { + input: { + prompt, + image_url: imageFile, + image_size: 'square_hd', + }, + pollInterval: 5000, // Default is 1000 (every 1s) + logs: true, + onQueueUpdate(update) { + setElapsedTime(Date.now() - start); + if ( + update.status === 'IN_PROGRESS' || + update.status === 'COMPLETED' + ) { + setLogs((update.logs || []).map((log) => log.message)); + } + }, + } + ); setResult(result); } catch (error: any) { setError(error); @@ -109,6 +116,20 @@ export default function Home() {

Hello fal

+
+ + setImageFile(e.target.files?.[0] ?? null)} + /> +