npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

omniinfer-sdk

v1.0.6

Published

omniinfer api sdk

Downloads

33

Readme

Omniinfer Js SDK

this SDK is based on the official API documentation

join our discord server for help

Installation, via npm

npm i omniinfer-sdk

Quick Start

Get api key refer to https://docs.omniinfer.io/get-started

We offer two ways to use the sdk

1.Called as a function

import { txt2ImgSync, setOmniinferKey } from "omniinfer-sdk";

setOmniinferKey("your api key");

txt2ImgSync({
  model_name: "",
  prompt: "a girl",
})
  .then((res) => {
    console.log("imgs", res);
  })
  .catch((err) => {
    console.log(err);
  });

2.Use by way of class

import { OmniinferSDK } from "omniinfer-sdk";

const sdk = new OmniinferSDK("your api key");

sdk
  .txt2ImgSync(params)
  .then((res) => {
    console.log("imgs", res);
  })
  .catch((err) => {
    alert(err);
  });

Examples SDK Online DEMO

function list

  • setOmniinferKey
  • getModels
  • img2img
  • txt2Img
  • txt2ImgSync
  • img2imgSync
  • upscale
  • upscaleSync

Usage in React

import * as React from 'react';
import { txt2ImgSync } from 'omniinfer-sdk';
import './style.css';

const { useState, useCallback } = React;

export default function App() {
  const [imgs, setImgs] = useState<string[]>([]);
  const [loading, setLoading] = useState(false);
  const generateImg = useCallback(() => {
    setLoading(true);
    txt2ImgSync({
      model_name: '',
      prompt: 'a girl',
    })
      .then((res) => {
        setImgs(res);
        setLoading(false);
      })
      .catch((err) => {
        console.log(err);
        setLoading(false);
      });
  }, []);
  return (
    <div>
      <h1>Text to image</h1>
      <button onClick={generateImg} disabled={loading}>
        {loading ? 'progressing' : 'click to generate image'}
      </button>
      <div
        style={{
          marginTop: '20px',
        }}
      >
        {imgs.map((one) => (
          <img
            src={one}
            crossOrigin="anonymous"
            referrerPolicy="origin-when-cross-origin"
            style={{
              objectFit: 'cover',
            }}
          />
        ))}
      </div>
    </div>
  );
}

Model Search

When you use this model interface, keep an eye on dependency_status and download_status, which are only considered to be available if they are both 1

We recommend that you keep the interface data in memory, e.g. redux.

getModels().then((res) => {
  console.log(res.models.slice(0, 100));
});

Lora Usage

txt2ImgSync({
  model_name: "majicmixRealistic_v2.safetensors",
  prompt:
    "Best quality, masterpiece, ultra high res, (photorealistic:1.4), raw photo, 1girl, offshoulder, in the dark, deep shadow, low key, cold light",
  negative_prompt:
    "ng_deepnegative_v1_75t, badhandv4 (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, normal quality, ((monochrome)), ((grayscale))",
  sampler_name: "DPM++ 2M Karras",
  lora: [
    {
      sd_name: "film",
      weight: 0.4,
    },
  ],
}).then((res) => {
  console.log(res);
});

ControlNet QRCode

txt2ImgSync({
  prompt:
    "a beautify butterfly in the colorful flowers, best quality, best details, masterpiece",
  model_name: "",
  steps: 30,
  controlnet_units: [
    {
      input_image: imgbase64,
      module: ControlNetPreprocessor.NULL,
      control_mode: ControlNetMode.BALANCED,
      model: "control_v1p_sd15_qrcode_monster_v2",
      weight: 2.0,
    },
  ],
}).then((res) => {
  console.log(res);
});

Upscalse

.upscaleSync({
  image: base64String,
  resize_mode: 0,
  upscaling_resize: 2,
})
.then((res) => {
  if (res) {
    setImg(res[0]);
  }
  setLoading(false);
})
.catch((err) => {
  alert(err);
});