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

tensor.fart

v1.0.1

Published

An unofficial tensor.art API

Downloads

9

Readme

tensor.fart

Overview

tensor.fart is a Node.js module that interfaces with the Tensor.art API to generate images based on textual prompts. This module simplifies the process of creating images by handling image uploads, task creation, and result retrieval.

Features

  • Text-to-Image Generation: Create images from text descriptions.
  • Image Upload: Supports uploading from both URLs and local file paths.
  • Customizable Parameters: Adjust various parameters such as image dimensions, steps, and more.
  • Task Monitoring: Continuously checks and retrieves the generated image upon completion.

Installation

To install the tensor.fart module, use npm:

npm install tensor.fart

Usage

Importing and Instantiating

First, import the GenerateImage class from the module and instantiate it with your API token:

import GenerateImage from 'tensor.fart';

const token = "your-api-token";
const generateImage = new GenerateImage(token);

Generating an Image

Call the generate method with the required parameters to generate an image:

(async () => {
  const params = {
    prompt: "A serene landscape with rolling hills and a clear sky",
    height: 512,
    width: 512,
    image: "path-or-url-to-image", // Optional: specify an image path or URL
    imageCount: 1,
    steps: 20,
    samplerName: "Euler a",
    cfgScale: 7.0,
    seed: 12345,
    clipSkip: 1,
    workEngine: "Tensor",
    etaNoiseSeedDelta: 0
  };

  try {
    const response = await generateImage.generate(params);
    console.log("Generated Image URL:", response.result);
  } catch (error) {
    console.error('Error:', error);
  }
})();

Parameters

  • prompt: A string describing the desired image.
  • negativePrompt: A string specifying elements to avoid in the image.
  • height: Image height in pixels.
  • width: Image width in pixels.
  • image: A path to a local image or a URL for the input image.
  • imageCount: Number of images to generate.
  • steps: Number of steps for the generation process.
  • samplerName: The name of the sampling method.
  • cfgScale: Configuration scale for adjusting the fidelity of the generated image.
  • seed: Seed value for random number generation, ensuring reproducibility.
  • clipSkip: Value to fine-tune the clip model's usage.
  • workEngine: The engine to be used for image generation.
  • etaNoiseSeedDelta: Value to control the noise seed during generation.

Return Value

The generate method returns an object containing the URL of the generated image:

{
  "result": "https://path-to-the-generated-image"
}

Example

Here is a complete example demonstrating the usage of the tensor.fart module:

import GenerateImage from 'tensor.fart';

(async () => {
  const token = "your-api-token";
  const generateImage = new GenerateImage(token);
  const params = {
    prompt: "A futuristic city with neon lights",
    height: 1024,
    width: 768,
    image: "https://example.com/sample.jpg", // or local path "path/to/your/image.jpg"
    steps: 30,
    cfgScale: 8.0
  };

  try {
    const response = await generateImage.generate(params);
    console.log("Generated Image URL:", response.result);
  } catch (error) {
    console.error('Error:', error);
  }
})();

More Methods

Check this out

Contributing

To contribute to the tensor.fart module, fork the repository and use a feature branch. Pull requests are welcome and appreciated.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments