Extraltodeus / depthmap2mask

Create masks out of depthmaps in img2img
355 stars 35 forks source link

Any chance to get this as a script and not extension? #43

Open DennLie opened 1 year ago

DennLie commented 1 year ago

Currently custom scripts can be run through the automatic1111 api but not extensions. I would like to be able to use this through unity but my knowledge of phyton is too limited to convert this. Can someone help me or point me to what exactly has to be changed to run this as a script?

tristanschulze commented 1 year ago

Having the same issue here :/ I am trying to call the depthmap to Unity too.

I am stuck with this error: "UnboundLocalError: local variable 'model' referenced before assignment "

I have this C# class object already that goes as JSON to the API:

` public class aCALL{ public string prompt = "many things"; public int width = 256; public int height = 256; public int seed = -1; public int steps = 6; public int cfg_scale = 2; public bool tiling = false; public int resize_mode = 1; public float denoising_strength = .5f; public string negative_prompt = "ugly"; public bool restore_faces = false; public string[] styles = {"photography","portrait","fancy"}; public bool save_depth = true;

 public bool include_init_images = true;
public string script_name = "Depth aware img2img mask";
public string[] script_args = {

"save_depthmap:false", "treshold:1", "match_size:True", "net_width:512", "net_height:512", "invert_depth:False", "model_type:1", "override_mask_blur:False", "override_fill:false", "clean_cut:false", "save_alpha_crop:false"

};

 // [save_depthmap,treshold,match_size,net_width,net_height,invert_depth,model_type,override_mask_blur,override_fill,clean_cut, save_alpha_crop]

/*

treshold = gr.Slider(minimum=0, maximum=255, step=1, label='Contrasts cut level', value=0) match_size = gr.Checkbox(label="Match input size",value=True) net_width = gr.Slider(minimum=64, maximum=2048, step=64, label='Net width', value=384) net_height = gr.Slider(minimum=64, maximum=2048, step=64, label='Net height', value=384) with gr.Row(): invert_depth = gr.Checkbox(label="Invert DepthMap",value=False) save_depthmap = gr.Checkbox(label='Save depth map', value=False) save_alpha_crop = gr.Checkbox(label='Save alpha crop', value=False) override_mask_blur = gr.Checkbox(label='Override mask blur to 0', value=True) override_fill = gr.Checkbox(label='Override inpaint to original', value=True) clean_cut = gr.Checkbox(label='Turn the depthmap into absolute black/white', value=False) model_type = gr.Dropdown(label="Model", choices=['dpt_large','midas_v21','midas_v21_small'], value='midas_v21_small', type="index", elem_id="model_type")

missing 11 required positional arguments: 'save_depthmap', 'treshold', 'match_size', 'net_width', 'net_height', 'invert_depth', 'model_type', 'override_mask_blur', 'override_fill', 'clean_cut', and 'save_alpha_crop' 1

*/

public string[] init_images = new string[1];

public aCALL(int _w = 256, int _h = 256){
    width = _w;
    height = _h;
}

}

} `