Public
HTTP
Forked from substrate/imageGeneration
stevekrouse-imagegeneration.web.val.run
July 22, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
import { ComputeText, GenerateImage, Substrate, UpscaleImage } from "npm:substrate";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const prompt = "futuristic city of atlants";
const description = new ComputeText({ prompt: `create a description of an image of ${prompt}. we'll use this description to generate an image. be concise and terse focusing on the subject.` }); description.cache_age = 60; description.id = "description";
const image = new GenerateImage({ prompt: description.future.text }); image.cache_age = 60; image.id = "image";
const upscale = new UpscaleImage({ prompt: description.future.text, image_uri: image.future.image_uri, output_resolution: 2048 }); upscale.cache_age = 60; upscale.id = "upscale";
const stream = substrate.stream(upscale);
export default async function render(req: Request): Promise<Response> {
const renderNodeResults = (await import("https://esm.town/v/substrate/renderNodeResults")).default;
return renderNodeResults(stream);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 22, 2024