Spaces:
Sleeping
Sleeping
File size: 1,390 Bytes
ad4fcaa f05e9cf ad4fcaa f05e9cf ad4fcaa f05e9cf ad4fcaa |
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 36 37 38 39 40 41 42 43 44 45 46 47 |
const textGenForm = document.querySelector('.text-gen-form');
/*
const translateText = async (text) => {
const inferResponse = await fetch(`infer_t5?input=${text}`);
const inferJson = await inferResponse.json();
return inferJson.output;
};
textGenForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textGenInput = document.getElementById('text-gen-input');
const textGenParagraph = document.querySelector('.text-gen-output');
try {
textGenParagraph.textContent = await translateText(textGenInput.value);
} catch (err) {
console.error(err);
}
});
*/
const generateImage = async (text, inference_steps, model) => {
const inferResponse = await fetch(`generate?prompt=${text}&inference_steps=${inference_steps}&model=${model}`);
const inferJson = await inferResponse.json();
return inferJson.output;
};
textGenForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textGenInput = document.getElementById('text-gen-input');
const inferenceSteps = document.getElementById('inference_steps');
const model = document.getElementById('model');
try {
const resp = await generateImage(textGenInput.value, inferenceSteps.value, model.value);
document.getElementById("redirect-form").submit();
} catch (err) {
console.error(err);
}
}); |