Saturday, January 18, 2025
API KEY
HomeGoogle Apps Scriptสร้าง Text to Image (modelslab) ด้วย Google App Script

สร้าง Text to Image (modelslab) ด้วย Google App Script

วิธีการสร้าง Text to Image (modelslab) ด้วย Google App Script

function sendRequest() {
  var url = 'https://modelslab.com/api/v6/images/text2img';

  var payload = {
    "key": "API KEY",
    "model_id": "midjourney",
     "prompt": "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
  "negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
    "width": "1024",
    "height": "1024",
    "samples": "1",
    "num_inference_steps": "30",
    "safety_checker": "no",
    "enhance_prompt": "yes",
    "seed": null,
    "guidance_scale": 7.5,
    "panorama": "no",
    "self_attention": "no",
    "upscale": "no",
    "embeddings_model": null,
    "lora_model": null,
    "tomesd": "yes",
    "use_karras_sigmas": "yes",
    "vae": null,
    "lora_strength": null,
    "scheduler": "UniPCMultistepScheduler",
    "webhook": null,
    "track_id": null
  };

  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'payload': JSON.stringify(payload)
  };

  try {
    var response = UrlFetchApp.fetch(url, options);
    var result = response.getContentText();
    Logger.log(result);
    // แปลง JSON เป็น Object

    var jsonData = JSON.parse(result);

    // ดึง URL ของภาพจากฟิลด์ "output"
    var imageUrl = jsonData.output[0];

    // ลบ backslashes
    var cleanImageUrl = imageUrl.replace(/\\/g, '');

    Logger.log('Image URL: ' + cleanImageUrl);
  } catch (error) {
    Logger.log('Error: ' + error.message);
  }

}
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
คอร์สเรียนออนไลน์

Most Popular

Recent Comments