Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yav-ai/nodejs-stable-diffusion-xl-base-1.0-hugging-face-inference-api

A simple node.js example that generates an image using StableDiffusion via Hugging Face Inference API.
https://github.com/yav-ai/nodejs-stable-diffusion-xl-base-1.0-hugging-face-inference-api

ai generative-ai huggingface image-generation inference-api nodejs nodejsexamples sdxl stable-diffusion stable-diffusion-api stable-diffusion-xl

Last synced: 4 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](https://huggingface.co/).

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

```bash
npm install
```

## How to use?

Open index.mjs and change your image caption

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

Open terminal and run

```bash
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