Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require("axios")
- async function easypic(prompt) {
- const postRes = await axios.post(
- 'https://api.aieasypic.com/api/inference_jobs/',
- {
- model: 694648,
- can_split: false,
- parameters: {
- batch_size: 2,
- prompt: prompt,
- controlnet_parameters: [],
- width: 768,
- height: 768,
- cfg_scale: "1.0",
- steps: 6,
- sampler_name: "Euler",
- lora_models: [774008],
- extra_json: {
- loras: [
- {
- id: 774008,
- weight: 0.125,
- },
- ],
- },
- },
- },
- {
- headers: {
- 'Accept': 'application/json, text/plain, */*',
- 'Content-Type': 'application/json',
- 'x-current-url': 'https://aieasypic.com/inspire/models/detail/aodai_sd_chiasedamme_v02-full-v20-121093',
- },
- }
- );
- const jobId = postRes.data.id;
- let result = null;
- for (let i = 0; i < 20; i++) {
- await new Promise(res => setTimeout(res, 3000));
- const getRes = await axios.get(
- `https://api.aieasypic.com/api/inference_jobs/${jobId}/success_detail/`,
- {
- headers: {
- 'Accept': 'application/json, text/plain, */*',
- 'x-current-url': 'https://aieasypic.com/inspire/models/detail/aodai_sd_chiasedamme_v02-full-v20-121093',
- },
- }
- );
- if (getRes.data.status === 'S' && getRes.data.prediction_images.length > 0) {
- result = getRes.data.prediction_images.map(img => img.image);
- break;
- }
- }
- return result;
- }
- //use
- const xxx = await easypic("a cute girl")
- console.log(JSON.stringify(xxx, null, 2));
Advertisement
Add Comment
Please, Sign In to add comment