stable-diffusion-webui-depthmap-script icon indicating copy to clipboard operation
stable-diffusion-webui-depthmap-script copied to clipboard

[Documentation] Insufficient documentation of the API

Open AIjie-sen opened this issue 2 years ago • 5 comments

I want to use depth map through the API, can you explain how to use it?

AIjie-sen avatar Jul 31 '23 07:07 AIjie-sen

Hello @AIjie-sen! Currently there is no good explanation unfortunately. This is still in the works, as well as the API. Please see below for an quick example.

semjonsona avatar Jul 31 '23 08:07 semjonsona

你好@AIjie-sen! 不幸的是,目前还没有很好的解释。这将进行中。这是我们目前所拥有的全部内容: #296(评论)

Can't txt2img add a script parameter to get depth map from the requests module now?

AIjie-sen avatar Jul 31 '23 08:07 AIjie-sen

@AIjie-sen You can use the "DepthMap" script. Also, API is very experimental and we do not advertize it yet. Still, here is an example of how it could be used:

# Works as of v0.4.3

import requests
import base64
from PIL import Image
import json
import io


if __name__ == '__main__':
    with open("/home/semjon/Pictures/Shortfin-mako-shark-seas.webp", "rb") as image_file:
        img = base64.b64encode(image_file.read()).decode()
    url = 'http://192.168.5.200:7860/depth/generate'
    dics = {  # See src/common_constants.py for more options
        "depth_input_images": [img],
        "options": {
            "compute_device": "GPU",
            "model_type": 9,
            "boost": False,
        }
    }

    x = requests.post(url, json=dics)
    response = json.loads(x.text)
    im = base64.b64decode(response['images'][0])
    im = Image.open(io.BytesIO(im))
    im.save('depth_img.png', 'PNG')  # Pillow image is saved

semjonsona avatar Jul 31 '23 12:07 semjonsona

你好@AIjie-sen! 不幸的是,目前还没有很好的解释。这将进行中。这是我们目前所拥有的全部内容: #296(评论)

Can't txt2img add a script parameter to get depth map from the requests module now?

Hey! I am in the same boat. Since I see this extension shows up in scripts (depthmap.py), I figured adding this script to a txt2img or img2img call would work, except I cannot easily see the arguments, as explained here:

To find out the list of arguments that are accepted by a particular script look up the associated python file from AUTOMATIC1111's repo scripts/[script_name].py. Search for its run(p, **args) function and the arguments that come after 'p' is the list of accepted arguments

...because the script seems to get the arguments through a Gradio method. Or do they maybe match to the "options" in your example @semjon00 ?

Sorry for reviving this. It's a bit unclear to me the current situation of API (not standalone, but integration into A1111 API)

aulerius avatar Nov 10 '23 01:11 aulerius