Coder Social home page Coder Social logo

jordip / prompt-generator-api Goto Github PK

View Code? Open in Web Editor NEW
103.0 2.0 13.0 1.39 MB

A simple prompt generator API for Stable Diffusion / Midjourney / Dall-e based in Python

License: GNU General Public License v3.0

Python 100.00%
dalle midjourney prompt prompt-builder prompt-generator python stable-diffusion api

prompt-generator-api's Introduction

Prompt Generator API

A simple prompt generator API for Stable Diffusion / Midjourney / Dall-e based in Python.

The API takes an initial prompt of a few words, and generates an extended and detailed prompt.

Based on the implementation of the FredZhang7/distilgpt2-stable-diffusion-v2 model.

Contributions are welcome :)

Example

Initial prompt

cat with sunglasses

Results of this prompt using Stable Diffusion v1.5

rdm-figure

Generated prompt using this API

cat with sunglasses, in the style of studio ghibli painting. cinematic lighting from right side on image and sharp focus by jean - baptiste monge! octane render redshift unreal engine 5 lumen global illumination ray tracing hdr arstation pixar disney tone mapping shiny reflectionsordan grimmer 4 k 8 lois van baal enki bilan ilya

Results of this prompt using Stable Diffusion v1.5

rdm-figure

Installation and usage

The API currently provides a POST endpoint to generate the prompt, configured to run at /generate

  1. Install the dependencies:
pip install --upgrade torch transformers flask flask_restful flask_limiter
  1. Clone the code of this repository:
git clone https://github.com/jordip/prompt-generator-api.git
  1. Run main.py from the root path:
python3 main.py
  1. Send a POST request to your instance of the API:
curl http://127.0.0.1:5000/generate -H "Content-Type: application/json" -d '{"prompt":"cat with sunglasses"}' -X POST

Required arguments

  • prompt
    • The beginning of the prompt.

Optional arguments

  • temperature
    • A higher temperature will produce more diverse results, but with a higher risk of less coherent text. Default: 0.9
  • top_k
    • The number of tokens to sample from at each step. Default: 80
  • max_length
    • The maximum number of tokens for the output of the model. Default: 80
  • repetition_penalty
    • The penalty value for each repetition of a token. Default: 1.2
  • num_return_sequences
    • The number of results to generate. Default: 5

Features

Blacklist

blacklist.txt contains a list of terms to be replaced from the returned prompt. One term per line.

Usage limits

The API is configured to limit the amount of requests received per minute by a single user.

prompt-generator-api's People

Contributors

jordip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

prompt-generator-api's Issues

Does't work

Hi

Then I do this curl http://127.0.0.1:5000/generate -H "Content-Type: application/json" -d '"prompt":"cat with sunglasses"' -X POST
Response "message": "The browser (or proxy) sent a request that this server could not understand."}

On server response 127.0.0.1 - - [25/Apr/2023 06:45:33] "POST /generate HTTP/1.1" 400 -

Could you help me?

How to send the output to the stable diffusion webui (AUTOMATIC 1111 webui)

Your work is amazing. I've got impressed by the speed especially, and I want to use this repo rather than other prompt builder.
Can you guide me how to send the generated prompt to the webui? Currently I'm using the automatic 1111 webui.
Specifically, I'd like to send the generated output to the webui's prompt.
Any suggestions?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.