What I Built
In our web service, we can fill the prompt and generate image with one of the text-to-image worker AI model randomly.
The user scenario image is as folows:
Demo
Our front-end worker is deployed at the Cloudflare Pages.
Try out our web service!
Firstly, open the web page and browse the above link:
Input the corgi
to be the prompt and click "Generate" button:
After waiting for about whiles, it will present generated image:
You're done for our web service tutorial now!
My Code
Our source code is available here:
peter279k / web-extract-worker
The web-based extract text to image worker :).
Web Extract Worker
Introduction
The web-based extract text to image worker :).
Installation
- Firstly, clone or fork this repository.
- Second, please refer the Cloudflare Pages Docs to complete the front-end page deployment.
And our techniques are as follows:
- Front-end: The
index.html
is the main page to let users input their prompts and see generated image. - Back-end: The
extract.php
is the main PHP program to handle user prompt and respond generated image.
Journey
We used these following models and the PHP program will choose them randomly when retrieving user prompts:
- Image-to-text: @cf/lykon/dreamshaper-8-lcm
- Image-to-text: @cf/stabilityai/stable-diffusion-xl-base-1.0
- Image-to-text: @cf/bytedance/stable-diffusion-xl-lightning
It's the dead simple for PHP developers to learn how to use the native PHP codes to develop a extract text to image service via the Cloudflare worker AI models :).
Top comments (0)