Spaces:
Running
Running
File size: 1,015 Bytes
8b93025 6940eac 2ba9156 8b93025 182f6b6 8b93025 182f6b6 cd2dc20 8b93025 182f6b6 8b93025 182f6b6 8b93025 d8af515 8b93025 f15a573 8b93025 182f6b6 a30c07d 8b93025 |
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 |
import axios from "axios";
import FormData from "form-data";
async function processImageUpscaler({ buffer, method, filenames, mimetype }) {
return new Promise(async (resolve, reject) => {
let Methods = ["enhance"];
Methods.includes(method) ? (method = method) : (method = Methods[0]);
let formData = new FormData();
formData.append("model_version", 1);
formData.append("image", Buffer.from(buffer), {
filename: filenames,
contentType: mimetype,
});
const headers = {
"User-Agent": "okhttp/4.9.3",
Connection: "Keep-Alive",
"Accept-Encoding": "gzip",
"Content-Type": "multipart/form-data",
};
const instance = axios.create({
transformRequest: [],
});
instance.post(`https://inferenceengine.vyro.ai/${method}`, formData, { headers })
.then(response => {
resolve(Buffer.from(response.data), "binary");
})
.catch(error => {
reject(error);
});
});
};
export { processImageUpscaler }; |