Giter Club home page Giter Club logo

segmind-npm's Introduction

SEGMIND NPM - Generate Images with Ease

Overview

Segmind NPM is a powerful package that allows you to effortlessly generate images using state-of-the-art models from Segmind's cloud platform. With this package, you can easily integrate image generation capabilities into your applications, websites, or projects. This markdown provides you with a step-by-step guide on how to use Segmind NPM to create stunning images.

Installation

To get started, you need to import the segmind-npm package into your project. You can do this using npm or yarn:

npm install segmind-npm
# or
yarn add segmind-npm

Initializing the API Key

Before you can generate images, you'll need an API key from cloud.segmind.com. This key will grant you access to Segmind's powerful image generation models. Replace "YOUR API-KEY" with your actual API key in the code below:

import { SDXL, SDXLType } from "segmind-npm"

const apiKey = "YOUR API-KEY";
const sdxl = new SDXL(apiKey);

Generating Images

Now that you have initialized the API key, you can generate images with just a few lines of code. Specify your desired image by providing a prompt, and you can also customize various parameters to control the image generation process:

sdxl.generate({
  prompt: "a panda on a chair",
  style: "base", // Style of the image
  samples: 1, // Number of samples to generate
  scheduler: "UniPC", // Type of scheduler
  num_inference_steps: 25, // Number of denoising steps
  guidance_scale: 8, // Scale for classifier-free guidance
  strength: 0.2, // Transformation strength
  high_noise_fraction: 0.8, // Fraction of inference steps to run on each expert
  seed: "468685", // Seed for image generation
  img_width: 1024, // Image width
  img_height: 1024, // Image height
  refiner: true, // Improve image quality
  base64: false, // Base64 encoding of the output image
}).then((response) => {
    // Handle the generated image here
    console.log(response.data);
});

Exported Models

Segmind NPM provides a wide range of exported models that you can use for various image generation tasks. Here is a list of some of the available models:

  • SDXL
  • Flat2D
  • Mix526
  • AllInOnePixel
  • BgRemoval
  • Cartoon
  • Codeformer
  • Colorful
  • Controlnet
  • CuteRichStyle
  • CyberRealistic
  • DeepSpacedDiffusion
  • Dreamshaper
  • DvArch
  • EdgeOfRealism
  • EpicRealism
  • Esrgan
  • Faceswap
  • FantassifiedIcons
  • FruitFusion
  • Icbinp
  • Img2Img
  • Inpainting
  • Juggernaut
  • Kandinsky
  • Majicmix
  • Manmarumix
  • Paragon
  • PotraitSD
  • QRGenerator
  • RCNZ
  • RPG
  • RealisticVision
  • Reliberate
  • Revanimated
  • SDOutpaint
  • Samaritan
  • SciFi
  • SegmentAnything
  • SmallSD
  • TinySD
  • Word2Img

You can choose the model that best suits your specific image generation needs.

Additional Information

For a comprehensive list of API parameters and their descriptions, you can refer to the API documentation on the Segmind website. This will provide you with detailed information on each parameter and how to use them effectively.

With Segmind NPM, you can easily harness the power of Segmind's image generation models to create stunning and customized images for your projects.

Feel free to explore and experiment with different prompts and parameters to achieve the desired results for your image generation tasks. Happy coding!

segmind-npm's People

Contributors

agauravdev avatar pratyush-udhani avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cruxcoder7

segmind-npm's Issues

Vega & VegaRT Clents

When can we expect Vega & VegaRT Clients to be added to this SDK?

Thanks in advance

Add `responseType: "stream"` to the POST request of the EsrGan API

return axios({
  url: this.url,
  data: JSON.stringify(data),
  method: "post",
  responseType: "stream",
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Content-Type": "application/json",
    "x-api-key": `${this.apiKey}`,
   },
})

The data returned by the API is in a binary string format.

Adding responseType: "stream" makes the return type as an object. This helps in parsing the response and downloading the image returned by the API by calling the pipe().

export const EnhanceImage = async (image: string) => {
  esr.generate({
      image,
    })
    .then((response) => {
      if (response.status === 200) {
        const saveDirectory = "./enhanced_images"
        const fileName = 'downloaded_image.jpg'

        if (!fs.existsSync(saveDirectory)) {
          fs.mkdirSync(saveDirectory, { recursive: true })
        }

        const filePath = path.join(saveDirectory, fileName)

        const writer = fs.createWriteStream(filePath)
        response.data.pipe(writer)

        return new Promise((resolve, reject) => {
          writer.on("finish", resolve)
          writer.on("error", reject)
        })
      }
    })
    .catch((err) => console.log(err))
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.