Generate Image with Github CI Action for free

in Blog Posts, Computer Vision (机器视觉), Solution

Generate Image with Github CI Action for free

Nowadays Github is way beyond a source code hosting website. People use it to host images, to make commenting system for static website, and there is for sure weird thing people do with Github that I am not aware of.

In teaching myself how to use Github Action for CI, I am curious if one can just use this for some customized task. Github Action is designed for CI and CI needs computation resource. Each Github account has 2000 minutes computation for free.

CI is not optimized for low-latency by design. We cannot use it for something we expected for quick turnaround. When using SD, usually I need to wait for a couple minutes to get one image done and if it is not good, it takes me another round of waiting. The process is slow anyway so it feels like is a well-fit task to run on Github Action servers.

The project is at pppoe/cisd and the action script is mostly self-explanatory. Docker image is hosted on Docker Hub. I use the dispatch interface to give prompt and the output filename and the CI event. After about 9 mins, the task is done and I can access the image stored as artifact.

it takes about 3mins to setup and 5mins to run this SD model on Github’s vCPU
the total billable time is 9mins, generated image uploaded as downloadable artifact
test_1.png

The drawback is that it takes time to setup the environment (downloading docker image, starting the container, and etc.). In the end, the throughput (~0.1it/min) is much worse than a job running locally on my old Linux server (~0.5it/min).

To get meaningful gain in throughput, I need to kick off jobs in parallel. In fact, I can just repeatedly launch job with slightly modified prompt and wait for 9mins to checkout all the results. Another workflow would be using the same prompt and hope the random seeds can bring me some good ones.

To get an estimation on how much we would benefit from parallel jobs. I added a matrix strategy in the action to start 20 jobs in parallel. The total wall-clock time remains the same but now the throughput is at 2.2it/min.

run multiple jobs with matrix strategy

Write a Comment

Comment