Location>code7788 >text

Python-based text-to-image tool

Popularity:324 ℃/2024-08-26 13:48:44

address
/r/rainsccc/strtoimg

After pulling the image, you can start a container to run the application. The following command will start the container and map its port to the host:

docker run -d -p 5000:5000 rainsccc/strtoimg:latest
  • -d: Run the container in the background.
  • -p 5000:5000: Maps port 5000 of the container to port 5000 of the host.

Access to services

Once the service is started, you can access it via an HTTP GET request. The following is the URL template for the request:

http://localhost:5000/generate_image?text=YOUR_TEXT

commander-in-chief (military)YOUR_TEXT Replace the text with the text you wish to convert and make sure the text is URL-encoded. Example:

  • javaScript
    const encodedStr = encodeURIComponent(text);
    
http://localhost:5000/generate_image?text=%E6%AD%A3%E5%9C%A8%E5%8A%A0%E8%BD%BD%2C%E8%AF%B7%E7%88%86%E5%90%8E

typical example

Example of a request

utilizationcurl Example of a command request:

curl "http://localhost:5000/generate_image?text=Hello%20World"

responsive

The request will return a PNG image containing the text "Hello World". You can view it in your browser or save it locally.

common problems

  • Image generation failure

    If you receive an image generation failure message, check the container log. Use the following command to view the container log:

    docker logs <container_id>
    
  • port conflict

    If port 5000 is already occupied by another service, modify the-p host port in the parameter, for example:

    docker run -d -p 8080:5000 rainsccc/strtoimg:latest
    

    Then visithttp://localhost:8080/generate_image?text=YOUR_TEXT

Instructions for use

  • docker pull rainsccc/strtoimg:latest: Pull the latest version of the image from Docker Hub.
  • docker run -d -p 5000:5000 rainsccc/strtoimg:latest: Run the container and map its port 5000 to the host's port 5000.
  • curl "http://localhost:5000/generate_image?text=YOUR_TEXT": Sends an HTTP request to generate an image.