Code Monkey home page Code Monkey logo

a2iprompt's Introduction

About

This tool will help you to convert Automatic1111 prompt to InvokeAI prompt

Usage

Online test click here and use it directly

or download this repo and open index.html it will work locally.

Features

  • Support InvokeAI (V2 and V3)

  • Support wide conversion cases

  • Support translation from invokeai to automatic1111

  • Fetch prompt from online image

  • Copy shortcuts

  • Tokens counter

  • Prompt syntax highlights

  • Auto prompt copy

  • Weight limiters

  • Weight randomizer

Standalone (Developers)

If you want to use the translation engine in your project use converter_standalone.js or converter_standalone.ts for TypeScript

note that .ts version will report error for missing encoder function, you need to import that (GPT-Tokenizer) manually or disable the line if you're not intersted in tokens counter

//Create instance first
var invokeaiResolver = new InvokeAIPromptResolver();

//Prepare options, all keys are optional, you don't have to add all of them
var options = {
    invokeaiVersion: 3,
    rawNegative: false,
    limitWeightPositive: "$1",
    limitWeightNegative: "$1",
    randomWeight: false,
    usePowValueAlways: false,
    dynamicPrompts: true
};

//1- From auto1111 to invokeai 
var output1 = invokeaiResolver.convertAuto1111ToInvokeAI(positive, negative, options);

//2- From invokeai to auto1111
var output2 = invokeaiResolver.convertInvokeAIToAuto1111(positive, negative, options);;

//Both functions (1 & 2) returns object as below:
/*
    {
    from: {
            positive: { text: , tokens: },
            negative: { text: , tokens: },
        },
    to: {
            positive: { text: , tokens: },
            negative: { text: , tokens: },
        }
    }
*/

//Calculate tokens without translation
//Require `encoders/cl100k_base.js` to be included
var tokensOutput = invokeaiResolver.calculateInvokeAITokens(positive, negative);
//This function returns object as below:
/*
    {
        positive: { text: , tokens: },
        negative: { text: , tokens: }
    };
*/

Contribution

Feel free to submit any request or fix

if you want to make your own fork just don't remove copyright section.

Privacy

This tool works locally and doesn't send or collect any usage data or any texts

Credits

Bashar Astifan (Developer)

GPT-Tokenizer thanks to Bazyli Brzóska

Syntax highlights and code editor CodeMirror

Tooltips TippyJS

Notifications Ryan Morr

Checkbox switch Edgar

HTML page has some elements from Navneet and Trent Dec

a2iprompt's People

Contributors

basharast avatar

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.