Skip to content

A simple node.js example that generates an image using StableDiffusion via Hugging Face Inference API.

License

Notifications You must be signed in to change notification settings

YAV-AI/NodeJS-Stable-Diffusion-XL-Base-1.0-Hugging-Face-Inference-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS example: Stable Diffusion using Hugging Face Inference API

Installation

To set up and run this example, follow these steps:

  1. Clone this repo.

  2. Navigate to the project directory.

  3. Open index.mjs Replace "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" in the code with your Hugging Face API token. You can obtain an API token by signing up on the Hugging Face website.

  4. Install the required Node.js packages by running the following command:

    npm install

How to use?

Open index.mjs and change your image caption

generateImage("photo of rocket launching into space");

Open terminal and run

node index.mjs

Once the image is processed, it will return

Image saved to: output/photo-of-rocket-launching-into-space.png

Examples

Further reading

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0
https://huggingface.co/docs/api-inference/index
https://huggingface.co/docs/inference-endpoints/index