You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Client } from "@gradio/client";
import path from 'path'
import fs from 'fs/promises'
// const response_0 = await fetch("https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png");
// const exampleImage = await response_0.blob();
// const response_1 = await fetch("https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png");
// const exampleImage2 = await response_1.blob();
// Read the image file from the local file system
const imagePath = path.join(process.cwd(), 'imgs/users/OIP.HtnbVUj5aYlTxYh8-eV2eQHaJ3.jpeg');
const imageBuffer = await fs.readFile(imagePath);
const userImg = new Blob([imageBuffer]);
// Repeat for the second image if necessary
const imagePath2 = path.join(process.cwd(), 'imgs/styles/1ac930a169eab44e709b78f7009cc98b.jpeg');
const imageBuffer2 = await fs.readFile(imagePath2);
const refImg = new Blob([imageBuffer2]);
const app = await Client.connect("https://instantx-instantid.hf.space/--replicas/5s9fg/");
try {
const result = await app.predict("/generate_image", [
userImg, // blob in 'Upload a photo of your face' Image component
refImg, // blob in 'Upload a reference pose image (Optional)' Image component
"a nice photo", // string in 'Prompt' Textbox component
"", // string in 'Negative Prompt' Textbox component
"(No style)", // string in 'Style template' Dropdown component
30, // number (numeric value between 1 and 100) in 'Number of sample steps' Slider component
0.6, // number (numeric value between 0 and 1.5) in 'IdentityNet strength (for fidelity)' Slider component
0.3, // number (numeric value between 0 and 1.5) in 'Image adapter strength (for detail)' Slider component
0.4, // number (numeric value between 0 and 1.5) in 'Pose strength' Slider component
0.4, // number (numeric value between 0 and 1.5) in 'Canny strength' Slider component
0.4, // number (numeric value between 0 and 1.5) in 'Depth strength' Slider component
["pose", 'canny'], // undefined in 'Controlnet' Checkboxgroup component
5, // number (numeric value between 0.1 and 20.0) in 'Guidance scale' Slider component
42, // number (numeric value between 0 and 2147483647) in 'Seed' Slider component
"EulerDiscreteScheduler", // string in 'Schedulers' Dropdown component
false, // boolean in 'Enable Fast Inference with LCM' Checkbox component
false, // boolean in 'Enhance non-face region' Checkbox component
]);
console.log(result.data);
}
catch (e) {
console.error('error;', e)
}
The text was updated successfully, but these errors were encountered:
According to the the sample code in 'Use via API' link down at the bottom of the huggingface app page, I kept getting error:
Here is the source code to invoke the endpoint:
The text was updated successfully, but these errors were encountered: