Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/yav-ai/nodejs-stable-diffusion-xl-base-1.0-hugging-face-inference-api
- Owner: YAV-AI
- License: mit
- Created: 2023-09-21T02:11:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-25T13:13:28.000Z (about 1 year ago)
- Last Synced: 2023-10-25T14:54:27.726Z (about 1 year ago)
- Topics: ai, generative-ai, huggingface, image-generation, inference-api, nodejs, nodejsexamples, sdxl, stable-diffusion, stable-diffusion-api, stable-diffusion-xl
- Language: JavaScript
- Homepage:
- Size: 297 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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