Skip to main content

An API wrapper for Onlyfakes

Project description

Onlyfakes API

An API wrapper for the onlyfakes website made in python.

Is able to create prompts, submit them and fetch their results.

License: MIT - See the LICENSE file.

Installation

  • Install with pip: pip install onlyfakes
  • Install locally from github: pip install git+https://github.com/Egsagon/onlyfakes-api.git

Usage

Example classic usage:

import onlyfakes as of

# Initialise the session
client = of.Client()

# Create a new prompt
prompt = of.Prompt(
    positive = '<insert positive prompt>',
    negative = '<insert negative prompt>',
    engine = of.Engine.hentai_HD

    # Advanced settings
    width = 512,
    height = 640,
    cfg = 7.5,
    seed = of.Seed( 12345678 )
)

# Submit the prompt and wait for it to process
img = client.generate(prompt)

# Download the image at a specific path
img.download('result.png')

Other example using shorthands:

import onlyfakes as of

of.Client().new(prompt = '<fill>', negative_prompt = '<fill>', engine = of.Engine.hentai_HD).generate().download('result.png')

The generate method contains a loop that breaks when it get a result. You can change its interaction intervals and maximum by specifying them as arguments. You can also enable verbose to see the current process evolution.

prompt.generate(
    interval = 2 * 60,
    timeout = 4 * 60,
    verbose = True
)

If want async or stuff that runs in parallel, you can use the submit function that will only send your prompt to the backend. You will then be able to fetch the image using the check method. You can also build your async function.

response = client.submit(prompt)

# Do stuff for 2 min ... 

data = client.check()

if data == False: ... # The backend has not finished yet

# Create the image object from data url
image = of.Image( data['imageUrl'] )

TODO

  • Async stuff
  • Account handling
  • Presets

Project details


Release history Release notifications | RSS feed

This version

1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onlyfakes-1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

onlyfakes-1-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page