eladrich / pixel2style2pixel

a StyleGAN Encoder for Image-to-Image Translation

  • Public
  • 31.9K runs
  • T4
  • GitHub
  • Paper
  • License

Run eladrich/pixel2style2pixel with an API

Headers
  • Preferstring

    Leave the request open and wait for the model to finish generating output. Set to wait=n where n is a number of seconds between 1 and 60.

    See https://replicate.com/docs/topics/predictions/create-a-prediction#sync-mode for more information.

Request body
  • inputobjectRequired

    The model's input as a JSON object. The input schema depends on what model you are running. To see the available inputs, click the "API" tab on the model you are running or get the model version and look at its openapi_schema property. For example, stability-ai/sdxl takes prompt as an input.

    Files should be passed as HTTP URLs or data URLs.

    Use an HTTP URL when:

    • you have a large file > 256kb
    • you want to be able to use the file multiple times
    • you want your prediction metadata to be associable with your input files

    Use a data URL when:

    • you have a small file <= 256kb
    • you don't want to upload and host the file somewhere
    • you don't need to use the file again (Replicate will not store it)
  • versionstringRequired

    The ID of the model version that you want to run.

  • webhookstring

    An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the response body of the get prediction operation. If there are network problems, we will retry the webhook a few times, so make sure it can be safely called more than once. Replicate will not follow redirects when sending webhook requests to your service, so be sure to specify a URL that will resolve without redirecting.

  • webhook_events_filterarray

    By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished. You can change which events trigger webhook requests by specifying webhook_events_filter in the prediction request:

    • start: immediately on prediction start
    • output: each time a prediction generates an output (note that predictions can generate multiple outputs)
    • logs: each time log output is generated by a prediction
    • completed: when the prediction reaches a terminal state (succeeded/canceled/failed)

    For example, if you only wanted requests to be sent at the start and end of the prediction, you would provide:

    {
      "version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
      "input": {
        "text": "Alice"
      },
      "webhook": "https://example.com/my-webhook",
      "webhook_events_filter": ["start", "completed"]
    }
    

    Requests for event types output and logs will be sent at most once every 500ms. If you request start and completed webhooks, then they'll always be sent regardless of throttling.

Examples

Create a prediction and get the output

Make a request
post/predictions
import Replicate from "replicate";
const replicate = new Replicate();

const input = {
    image: "https://replicate.delivery/mgxm/7935db96-ae91-440f-8c75-b94bd6315d79/input_img.jpg",
    model: "toonify"
};

const output = await replicate.run("eladrich/pixel2style2pixel:919ed2f7b6c5c24f3a53207842b61b6eba515136bd7bb9ffa75e01e970609cc4", { input });

import { writeFile } from "node:fs/promises";
await writeFile("output", output);
//=> output written to disk
Input parameters
  • prediction_idstringRequired
    The ID of the prediction to get.
Examples

Get the latest version of a prediction by id

Make a request
get/predictions/{prediction_id}
import Replicate from "replicate";
const replicate = new Replicate();

console.log("Getting prediction...")
const prediction = await replicate.predictions.get(predictionId);
//=> {"id": "xyz...", "status": "successful", ... }
Input parameters
  • prediction_idstringRequired
    The ID of the prediction to cancel.
Examples

Cancel an in progress prediction

Make a request
post/predictions/{prediction_id}/cancel
import Replicate from "replicate";
const replicate = new Replicate();

console.log("Canceling prediction...")
const prediction = await replicate.predictions.cancel(predictionId);
//=> {"id": "xyz...", "status": "canceled", ... }
Examples

List the first page of your predictions

Make a request
get/predictions
import Replicate from "replicate";
const replicate = new Replicate();

const page = await replicate.predictions.list();
console.log(page.results)
//=> [{ "id": "xyz...", "status": "successful", ... }, { ... }]