Files
..
2025-03-07 00:34:46 +01:00
2025-03-07 00:34:46 +01:00

docker build -t image_generation .
docker run --rm -it -p 12343:80 image_generation
import requests
import cv2
import base64
import numpy as np

endpoint = "http://192.168.2.64:12343/image"

prompt = "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."
prompt = "A group of kids happily playing in a joy environment"
#prompt = "A bitcoin behaving like a king, surrounded by small alternative coins. Detailed, geometric style"

json = {
    "prompt": prompt,
    "num_inference_steps": 10,
    "size": "512x512",
    "seed": 123456,
}

for inf_step in [1, 4, 10, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100]:
    json["num_inference_steps"] = inf_step

    %time r = requests.post(endpoint, json=json)
    print("Status code", r.status_code)

    # Image
    png_as_np = np.frombuffer(base64.b64decode(r.text), dtype=np.uint8)
    image_bgr = cv2.imdecode(png_as_np, cv2.IMREAD_COLOR)

    cv2.imwrite("sample_img_{}.png".format(json["num_inference_steps"]), image_bgr)