Spaces:
Running
Running
File size: 1,104 Bytes
a29b19f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
const { createApp, ref, setup } = Vue;
import { HfInference } from "https://cdn.skypack.dev/@huggingface/inference@latest";
const app = createApp({
setup() {
const models = ref(["stabilityai/stable-diffusion-xl-base-1.0","runwayml/stable-diffusion-v1-5"]);
const selectedModel = ref(models.value[0]);
const token = ref("");
const prompt = ref("Mughal cyberpunk city");
const generatedImageUrl = ref("");
const generateImage = async () => {
console.log("Generating image...");
const hf = new HfInference(token.value);
const generatedImageBlob = await hf.textToImage({
inputs: prompt.value,
model: selectedModel.value,
});
console.log(generatedImage);
generatedImageUrl.value = URL.createObjectURL(generatedImageBlob);
}
return {
models,
selectedModel,
token,
prompt,
generateImage,
generatedImageUrl
}
}
});
app.mount("#text-to-image-app");
|