Readme
This is a fork of kvfrans/clipdraw with some additional constraints to encourage more interesting output.
There’s a blog post walking through some of the changes: https://replicate.com/blog/constraining-clipdraw.
Generate art from text prompts. Based on kvfrans/clipdraw.
Run this model in Node.js with one line of code:
npm install replicate
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run evilstreak/clipdraw using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"evilstreak/clipdraw:9b6a753e2d3471530a5c11b3c77b9f64eaf3b8a2c6810bba487dadd0c687a230",
{
input: {
prompt: "Watercolor painting of an underwater submarine.",
num_paths: 256,
num_iterations: 600,
display_frequency: 10,
distance_from_centre_power: 2,
distance_from_centre_weight: 0.001,
distance_from_centre_threshold: 75
}
}
);
// To access the file URL:
console.log(output[0].url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output[0]);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
import replicate
Run evilstreak/clipdraw using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"evilstreak/clipdraw:9b6a753e2d3471530a5c11b3c77b9f64eaf3b8a2c6810bba487dadd0c687a230",
input={
"prompt": "Watercolor painting of an underwater submarine.",
"num_paths": 256,
"num_iterations": 600,
"display_frequency": 10,
"distance_from_centre_power": 2,
"distance_from_centre_weight": 0.001,
"distance_from_centre_threshold": 75
}
)
# The evilstreak/clipdraw model can stream output as it's running.
# The predict method returns an iterator, and you can iterate over that output.
for item in output:
# https://replicate.com/evilstreak/clipdraw/api#output-schema
print(item)
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run evilstreak/clipdraw using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "evilstreak/clipdraw:9b6a753e2d3471530a5c11b3c77b9f64eaf3b8a2c6810bba487dadd0c687a230",
"input": {
"prompt": "Watercolor painting of an underwater submarine.",
"num_paths": 256,
"num_iterations": 600,
"display_frequency": 10,
"distance_from_centre_power": 2,
"distance_from_centre_weight": 0.001,
"distance_from_centre_threshold": 75
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Add a payment method to run this model.
By signing in, you agree to our
terms of service and privacy policy
{
"completed_at": "2022-05-26T16:24:52.769183Z",
"created_at": "2022-05-26T16:19:58.987233Z",
"data_removed": false,
"error": null,
"id": "tflr6wwxyrdihefica7zkzw5ny",
"input": {
"prompt": "Watercolor painting of an underwater submarine.",
"num_paths": 256,
"num_iterations": 600,
"display_frequency": 10,
"distance_from_centre_power": 2,
"distance_from_centre_weight": 0.001,
"distance_from_centre_threshold": 75
},
"logs": "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py:876: UserWarning: Argument fill/fillcolor is not supported for Tensor input. Fill value is zero\n warnings.warn(\"Argument fill/fillcolor is not supported for Tensor input. Fill value is zero\")\niteration: 0, render:loss: 5.265625\niteration: 10, render:loss: 2.767578125\niteration: 20, render:loss: 1.107421875\niteration: 30, render:loss: 0.0966796875\niteration: 40, render:loss: -0.5224609375\niteration: 50, render:loss: -0.89892578125\niteration: 60, render:loss: -1.0595703125\niteration: 70, render:loss: -1.29296875\niteration: 80, render:loss: -1.4404296875\niteration: 90, render:loss: -1.4287109375\niteration: 100, render:loss: -1.56640625\niteration: 110, render:loss: -1.541015625\niteration: 120, render:loss: -1.587890625\niteration: 130, render:loss: -1.67578125\niteration: 140, render:loss: -1.64453125\niteration: 150, render:loss: -1.7158203125\niteration: 160, render:loss: -1.7373046875\niteration: 170, render:loss: -1.74609375\niteration: 180, render:loss: -1.7265625\niteration: 190, render:loss: -1.7255859375\niteration: 200, render:loss: -1.7373046875\niteration: 210, render:loss: -1.7431640625\niteration: 220, render:loss: -1.7451171875\niteration: 230, render:loss: -1.7607421875\niteration: 240, render:loss: -1.7685546875\niteration: 250, render:loss: -1.7470703125\niteration: 260, render:loss: -1.7724609375\niteration: 270, render:loss: -1.787109375\niteration: 280, render:loss: -1.763671875\niteration: 290, render:loss: -1.7802734375\niteration: 300, render:loss: -1.775390625\niteration: 310, render:loss: -1.7880859375\niteration: 320, render:loss: -1.84375\niteration: 330, render:loss: -1.796875\niteration: 340, render:loss: -1.791015625\niteration: 350, render:loss: -1.818359375\niteration: 360, render:loss: -1.8525390625\niteration: 370, render:loss: -1.892578125\niteration: 380, render:loss: -1.8544921875\niteration: 390, render:loss: -1.8896484375\niteration: 400, render:loss: -1.9033203125\niteration: 410, render:loss: -1.8642578125\niteration: 420, render:loss: -1.8837890625\niteration: 430, render:loss: -1.8681640625\niteration: 440, render:loss: -1.8837890625\niteration: 450, render:loss: -1.9345703125\niteration: 460, render:loss: -1.8701171875\niteration: 470, render:loss: -1.9306640625\niteration: 480, render:loss: -1.962890625\niteration: 490, render:loss: -1.9423828125\niteration: 500, render:loss: -1.9580078125\niteration: 510, render:loss: -1.9638671875\niteration: 520, render:loss: -1.9638671875\niteration: 530, render:loss: -1.962890625\niteration: 540, render:loss: -1.9833984375\niteration: 550, render:loss: -1.9541015625\niteration: 560, render:loss: -1.9814453125\niteration: 570, render:loss: -1.9267578125\niteration: 580, render:loss: -1.98046875\niteration: 590, render:loss: -1.9609375\niteration: 599, render:loss: -2.0078125",
"metrics": {
"predict_time": 288.605864,
"total_time": 293.78195
},
"output": [
"https://replicate.delivery/mgxm/3a00ff00-2a12-4b2b-97d1-776bf7e48641/out.png",
"https://replicate.delivery/mgxm/a4c56ced-3440-4242-8d07-52fa8b91d685/out.png",
"https://replicate.delivery/mgxm/3435f0bd-b1fd-4fa9-a57f-a9316a84f71f/out.png",
"https://replicate.delivery/mgxm/ee8ef53b-ffe8-4334-a286-f6f7bc582405/out.png",
"https://replicate.delivery/mgxm/099aa413-739c-4bba-ac74-eacc725e97e0/out.png",
"https://replicate.delivery/mgxm/73e010ef-07dd-4507-84f8-60a44be70891/out.png",
"https://replicate.delivery/mgxm/6391f16a-31f6-45d5-adc3-f92a7ad8b37f/out.png",
"https://replicate.delivery/mgxm/b803bb19-90e3-4de4-8c74-94f958436656/out.png",
"https://replicate.delivery/mgxm/a693d56d-f43f-42c6-b135-a82e8407215b/out.png",
"https://replicate.delivery/mgxm/b54e85df-8ecd-4e84-9a49-62f8c42c9fb4/out.png",
"https://replicate.delivery/mgxm/8158b5b4-43a8-4025-8e12-7168cbf6f497/out.png",
"https://replicate.delivery/mgxm/d8f48870-f8d7-4745-b32e-42b5d7cbbd17/out.png",
"https://replicate.delivery/mgxm/0792470b-1afd-4281-acee-05dd4671c052/out.png",
"https://replicate.delivery/mgxm/6a733089-ff0b-4223-aba6-eed40e2c406e/out.png",
"https://replicate.delivery/mgxm/51ca7b20-695f-4c0f-afb7-c6569c8d00a9/out.png",
"https://replicate.delivery/mgxm/9a4012ef-2e0e-4094-b18a-cd1f1d17f9ac/out.png",
"https://replicate.delivery/mgxm/fc66fd19-71a2-4166-a8cb-7c7708b7d594/out.png",
"https://replicate.delivery/mgxm/15f31f0d-0454-4969-b2d8-e5a6a6832dc0/out.png",
"https://replicate.delivery/mgxm/c5484e1b-af98-4cd9-8e22-3d67761a5cc7/out.png",
"https://replicate.delivery/mgxm/fd547cd6-5110-4ec3-b04f-bcc7c9e074bd/out.png",
"https://replicate.delivery/mgxm/d0f50c22-846a-4c63-9dc9-6ae0f03d8957/out.png",
"https://replicate.delivery/mgxm/6e0b8a9b-0275-455d-a8d6-f016fe2be7d3/out.png",
"https://replicate.delivery/mgxm/14efbb75-d638-4e99-8276-7bf2aa663c6f/out.png",
"https://replicate.delivery/mgxm/f4f69e64-aadf-41cf-a92b-26379108b092/out.png",
"https://replicate.delivery/mgxm/6fcf304a-6f1e-4a98-ad60-122af39c08c3/out.png",
"https://replicate.delivery/mgxm/438dbd25-e1dd-49a3-b827-711fd2705b89/out.png",
"https://replicate.delivery/mgxm/8f722e41-1b80-48e8-86f0-048a9f8d57e4/out.png",
"https://replicate.delivery/mgxm/ec8275a7-a83c-4a4b-806b-ab3ab9090ce6/out.png",
"https://replicate.delivery/mgxm/bd2e4856-d3c9-45c4-9a4e-4dbd52714335/out.png",
"https://replicate.delivery/mgxm/1407f7a0-d377-4700-9960-d4350412e6c8/out.png",
"https://replicate.delivery/mgxm/d69d140b-c04f-4a9e-b24f-cc79b65681e6/out.png",
"https://replicate.delivery/mgxm/f146c89d-dc12-4f09-a78f-8f8f8cc800fd/out.png",
"https://replicate.delivery/mgxm/5821114d-de25-4148-af0b-0e02b69470fa/out.png",
"https://replicate.delivery/mgxm/268e2668-a803-41cb-a4cc-56d9ef7589f7/out.png",
"https://replicate.delivery/mgxm/667fccb2-4e0e-4970-adf7-6d5400485f84/out.png",
"https://replicate.delivery/mgxm/c2cec788-43bf-4f58-bad3-b2d4c15a4991/out.png",
"https://replicate.delivery/mgxm/3adac1a4-d1cc-465e-b768-9b7649e87edc/out.png",
"https://replicate.delivery/mgxm/99084ce6-ed74-433b-9443-97d209348ac2/out.png",
"https://replicate.delivery/mgxm/91df3f74-ca32-4318-aeb0-6bfbfb1bc05a/out.png",
"https://replicate.delivery/mgxm/0c6dc44c-3a62-45cb-9d83-fbc60bff9fb8/out.png",
"https://replicate.delivery/mgxm/bca9cfed-5cbd-4a47-8558-b4b96c37b5bb/out.png",
"https://replicate.delivery/mgxm/1f7201f6-e677-4496-9366-0363834066ce/out.png",
"https://replicate.delivery/mgxm/b638a8ec-012f-41f7-9c06-f8ecfa4e93e3/out.png",
"https://replicate.delivery/mgxm/d50d3801-a366-46f9-ac82-0dcc10a2fd2b/out.png",
"https://replicate.delivery/mgxm/f9efd395-d9c3-4f23-90e6-5d42efc53f5f/out.png",
"https://replicate.delivery/mgxm/0557ae49-ce59-4725-8b93-249fe15608cb/out.png",
"https://replicate.delivery/mgxm/6ef3397f-a216-4ac6-83cf-22c40e379f1d/out.png",
"https://replicate.delivery/mgxm/01166eda-0d71-4a5e-b497-98db225bc46d/out.png",
"https://replicate.delivery/mgxm/497640af-378a-4bd3-addc-190b68c99147/out.png",
"https://replicate.delivery/mgxm/0ce131ec-f838-4e2a-827f-008b1ed61656/out.png",
"https://replicate.delivery/mgxm/55632b46-ac5b-4625-bcdc-5e3d7a3c0a5b/out.png",
"https://replicate.delivery/mgxm/c80bf6ab-f95a-4739-b3a2-98bdc50d0642/out.png",
"https://replicate.delivery/mgxm/b9ecaebf-9e80-4526-b20f-69f16dba1ebf/out.png",
"https://replicate.delivery/mgxm/4189c045-059e-4808-9e0f-3b747e9e81cf/out.png",
"https://replicate.delivery/mgxm/df82dd19-1a64-47ad-8ff8-3edd014747a0/out.png",
"https://replicate.delivery/mgxm/c3f4fe58-7369-4728-9514-2f31fbb4cf93/out.png",
"https://replicate.delivery/mgxm/9dd729a1-33fa-4090-a7a7-bf7ebe7b2e5e/out.png",
"https://replicate.delivery/mgxm/66db7d09-867e-443b-8f11-589a09576ee3/out.png",
"https://replicate.delivery/mgxm/35b27145-78b7-4b71-b9a8-89238b8490b3/out.png",
"https://replicate.delivery/mgxm/58438552-9f19-4c9c-bba8-09a6c25339b2/out.png",
"https://replicate.delivery/mgxm/414c9066-b851-4637-83d7-d5fc6ca97d13/out.png",
"https://replicate.delivery/mgxm/40ec928c-6193-4d16-80d2-ffe561dbf331/out.png"
],
"started_at": "2022-05-26T16:20:04.163319Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/tflr6wwxyrdihefica7zkzw5ny",
"cancel": "https://api.replicate.com/v1/predictions/tflr6wwxyrdihefica7zkzw5ny/cancel"
},
"version": "9b6a753e2d3471530a5c11b3c77b9f64eaf3b8a2c6810bba487dadd0c687a230"
}
/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py:876: UserWarning: Argument fill/fillcolor is not supported for Tensor input. Fill value is zero
warnings.warn("Argument fill/fillcolor is not supported for Tensor input. Fill value is zero")
iteration: 0, render:loss: 5.265625
iteration: 10, render:loss: 2.767578125
iteration: 20, render:loss: 1.107421875
iteration: 30, render:loss: 0.0966796875
iteration: 40, render:loss: -0.5224609375
iteration: 50, render:loss: -0.89892578125
iteration: 60, render:loss: -1.0595703125
iteration: 70, render:loss: -1.29296875
iteration: 80, render:loss: -1.4404296875
iteration: 90, render:loss: -1.4287109375
iteration: 100, render:loss: -1.56640625
iteration: 110, render:loss: -1.541015625
iteration: 120, render:loss: -1.587890625
iteration: 130, render:loss: -1.67578125
iteration: 140, render:loss: -1.64453125
iteration: 150, render:loss: -1.7158203125
iteration: 160, render:loss: -1.7373046875
iteration: 170, render:loss: -1.74609375
iteration: 180, render:loss: -1.7265625
iteration: 190, render:loss: -1.7255859375
iteration: 200, render:loss: -1.7373046875
iteration: 210, render:loss: -1.7431640625
iteration: 220, render:loss: -1.7451171875
iteration: 230, render:loss: -1.7607421875
iteration: 240, render:loss: -1.7685546875
iteration: 250, render:loss: -1.7470703125
iteration: 260, render:loss: -1.7724609375
iteration: 270, render:loss: -1.787109375
iteration: 280, render:loss: -1.763671875
iteration: 290, render:loss: -1.7802734375
iteration: 300, render:loss: -1.775390625
iteration: 310, render:loss: -1.7880859375
iteration: 320, render:loss: -1.84375
iteration: 330, render:loss: -1.796875
iteration: 340, render:loss: -1.791015625
iteration: 350, render:loss: -1.818359375
iteration: 360, render:loss: -1.8525390625
iteration: 370, render:loss: -1.892578125
iteration: 380, render:loss: -1.8544921875
iteration: 390, render:loss: -1.8896484375
iteration: 400, render:loss: -1.9033203125
iteration: 410, render:loss: -1.8642578125
iteration: 420, render:loss: -1.8837890625
iteration: 430, render:loss: -1.8681640625
iteration: 440, render:loss: -1.8837890625
iteration: 450, render:loss: -1.9345703125
iteration: 460, render:loss: -1.8701171875
iteration: 470, render:loss: -1.9306640625
iteration: 480, render:loss: -1.962890625
iteration: 490, render:loss: -1.9423828125
iteration: 500, render:loss: -1.9580078125
iteration: 510, render:loss: -1.9638671875
iteration: 520, render:loss: -1.9638671875
iteration: 530, render:loss: -1.962890625
iteration: 540, render:loss: -1.9833984375
iteration: 550, render:loss: -1.9541015625
iteration: 560, render:loss: -1.9814453125
iteration: 570, render:loss: -1.9267578125
iteration: 580, render:loss: -1.98046875
iteration: 590, render:loss: -1.9609375
iteration: 599, render:loss: -2.0078125
This model costs approximately $0.098 to run on Replicate, or 10 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker.
This model runs on Nvidia T4 GPU hardware. Predictions typically complete within 8 minutes. The predict time for this model varies significantly based on the inputs.
This is a fork of kvfrans/clipdraw with some additional constraints to encourage more interesting output.
There’s a blog post walking through some of the changes: https://replicate.com/blog/constraining-clipdraw.
This model is cold. You'll get a fast response if the model is warm and already running, and a slower response if the model is cold and starting up.
/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py:876: UserWarning: Argument fill/fillcolor is not supported for Tensor input. Fill value is zero
warnings.warn("Argument fill/fillcolor is not supported for Tensor input. Fill value is zero")
iteration: 0, render:loss: 5.265625
iteration: 10, render:loss: 2.767578125
iteration: 20, render:loss: 1.107421875
iteration: 30, render:loss: 0.0966796875
iteration: 40, render:loss: -0.5224609375
iteration: 50, render:loss: -0.89892578125
iteration: 60, render:loss: -1.0595703125
iteration: 70, render:loss: -1.29296875
iteration: 80, render:loss: -1.4404296875
iteration: 90, render:loss: -1.4287109375
iteration: 100, render:loss: -1.56640625
iteration: 110, render:loss: -1.541015625
iteration: 120, render:loss: -1.587890625
iteration: 130, render:loss: -1.67578125
iteration: 140, render:loss: -1.64453125
iteration: 150, render:loss: -1.7158203125
iteration: 160, render:loss: -1.7373046875
iteration: 170, render:loss: -1.74609375
iteration: 180, render:loss: -1.7265625
iteration: 190, render:loss: -1.7255859375
iteration: 200, render:loss: -1.7373046875
iteration: 210, render:loss: -1.7431640625
iteration: 220, render:loss: -1.7451171875
iteration: 230, render:loss: -1.7607421875
iteration: 240, render:loss: -1.7685546875
iteration: 250, render:loss: -1.7470703125
iteration: 260, render:loss: -1.7724609375
iteration: 270, render:loss: -1.787109375
iteration: 280, render:loss: -1.763671875
iteration: 290, render:loss: -1.7802734375
iteration: 300, render:loss: -1.775390625
iteration: 310, render:loss: -1.7880859375
iteration: 320, render:loss: -1.84375
iteration: 330, render:loss: -1.796875
iteration: 340, render:loss: -1.791015625
iteration: 350, render:loss: -1.818359375
iteration: 360, render:loss: -1.8525390625
iteration: 370, render:loss: -1.892578125
iteration: 380, render:loss: -1.8544921875
iteration: 390, render:loss: -1.8896484375
iteration: 400, render:loss: -1.9033203125
iteration: 410, render:loss: -1.8642578125
iteration: 420, render:loss: -1.8837890625
iteration: 430, render:loss: -1.8681640625
iteration: 440, render:loss: -1.8837890625
iteration: 450, render:loss: -1.9345703125
iteration: 460, render:loss: -1.8701171875
iteration: 470, render:loss: -1.9306640625
iteration: 480, render:loss: -1.962890625
iteration: 490, render:loss: -1.9423828125
iteration: 500, render:loss: -1.9580078125
iteration: 510, render:loss: -1.9638671875
iteration: 520, render:loss: -1.9638671875
iteration: 530, render:loss: -1.962890625
iteration: 540, render:loss: -1.9833984375
iteration: 550, render:loss: -1.9541015625
iteration: 560, render:loss: -1.9814453125
iteration: 570, render:loss: -1.9267578125
iteration: 580, render:loss: -1.98046875
iteration: 590, render:loss: -1.9609375
iteration: 599, render:loss: -2.0078125