0.0.5 • Published 1 year ago

dreamstudio.js v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Installation

npm i dreamstudio.js

pnpm add dreamstudio.js

yarn add dreamstudio.js

Usage

Generate images:

Text to image

It would log an object with the property artifacts that contains an array of the images. Every image object have the base64 property which is the image.

import { textToImg } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var images = await textToImg({
    apiKey,
    engineId: 'stable-diffusion-v1-5',
    text_prompts: [
      {
        text: 'a cat in the moon with a space suit, photorealistic, 4k',
        weight: 1,
      },
    ],
  });
  console.log(images.artifacts);
})();
Engines list:
IdNameType
stable-diffusion-v1Stable Diffusion v1.4PICTURE
stable-diffusion-v1-5Stable Diffusion v1.5PICTURE
stable-diffusion-512-v2-0Stable Diffusion v2.0PICTURE
stable-diffusion-768-v2-0Stable Diffusion v2.0-768PICTURE
stable-diffusion-512-v2-1'Stable Diffusion v2.1PICTURE
stable-diffusion-768-v2-1Stable Diffusion v2.1-768PICTURE
stable-inpainting-v1-0Stable Inpainting v1.0PICTURE
stable-inpainting-512-v2-0Stable Inpainting v2.0PICTURE
Options:
Option NameTypeDefaultRequired
apiKeystringnonetrue
engineIdstringnonetrue
cfg_scalenumber7false
clip_guidance_presetstringNONEfalse
widthnumber512false
heightnumber512false
samplesnumber1false
seednumberrandomfalse
stepsnumber50false
text_promptsArraynonetrue

Image to image

It would log an object with the property artifacts that contains an array of the images. Every image object have the base64 property which is the image.

import { imgToimg } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  const initImage = fs.readFileSync('./examples/init_image.png'); // the initial image path
  var images = await imgToimg({
    apiKey,
    initImage,
    engineId: 'stable-inpainting-512-v2-0',
    text_prompts: [
      {
        text: 'add a picture of van gogh to the wall',
        weight: 1,
      },
    ],
  });
  fs.writeFile('./examples/out.png', images.artifacts[0].base64, 'base64'); // save the result
})();
Engines list:
IdNameType
stable-diffusion-v1Stable Diffusion v1.4PICTURE
stable-diffusion-v1-5Stable Diffusion v1.5PICTURE
stable-diffusion-512-v2-0Stable Diffusion v2.0PICTURE
stable-diffusion-768-v2-0Stable Diffusion v2.0-768PICTURE
stable-diffusion-512-v2-1'Stable Diffusion v2.1PICTURE
stable-diffusion-768-v2-1Stable Diffusion v2.1-768PICTURE
stable-inpainting-v1-0Stable Inpainting v1.0PICTURE
stable-inpainting-512-v2-0Stable Inpainting v2.0PICTURE
Options:
Option NameTypeDefaultRequired
apiKeystringnonetrue
engineIdstringnonetrue
cfg_scalenumber7false
clip_guidance_presetstringNONEfalse
widthnumber512false
heightnumber512false
samplesnumber1false
seednumberrandomfalse
stepsnumber50false
text_promptsArraynonetrue

Image to image/Masking

Under development

User information:

import { getUser, getBalance } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var user = await getUser(apiKey);
  console.log(user);
  var balance = await getBalance(apiKey);
  console.log(balance);
})();

Get engines list:

import { getEngines } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var engines = await getEngines(apiKey);
  console.log(engines);
})();

To do list:

  • User data
  • Engines list
  • Text to image
  • Image to image
  • Image to image/masking
  • Improve error messages