(image_path,prompt,denoise_strength,resolution,seed)
| 36 | |
| 37 | # get the initial image |
| 38 | def square_Image_request (image_path,prompt,denoise_strength,resolution,seed): |
| 39 | print(len(image_path),prompt,denoise_strength,resolution,seed) |
| 40 | data = { |
| 41 | "init_images": [image_path], |
| 42 | "resize_mode": 0, |
| 43 | "denoising_strength": denoise_strength, |
| 44 | "prompt": prompt, |
| 45 | "negative_prompt": "", |
| 46 | #"control_net_enabled": "true", |
| 47 | "alwayson_scripts": { |
| 48 | "ControlNet":{ |
| 49 | "args": [ |
| 50 | { |
| 51 | "input_image": image_path, |
| 52 | "module": "hed", |
| 53 | # "model": "control_canny-fp16 [e3fe7712]", |
| 54 | "model": "control_hed-fp16 [13fee50b]", |
| 55 | "processor_res": 1024, |
| 56 | "weight": 1 |
| 57 | } |
| 58 | ] |
| 59 | } |
| 60 | }, |
| 61 | "seed": seed, |
| 62 | "sampler_index": "Euler a", |
| 63 | "batch_size": 1, |
| 64 | "n_iter": 1, |
| 65 | "steps": 20, |
| 66 | "cfg_scale": 6, |
| 67 | "width": resolution, |
| 68 | "height": resolution, |
| 69 | "restore_faces": True, |
| 70 | "include_init_images": False, |
| 71 | "override_settings": {}, |
| 72 | "override_settings_restore_afterwards": True |
| 73 | } |
| 74 | response = requests.post(img2imgurl, json=data) |
| 75 | #print (response.content) |
| 76 | print(len(json.loads(response.content)["images"])) |
| 77 | if response.status_code == 200: |
| 78 | return json.loads(response.content)["images"][0] |
| 79 | else: |
| 80 | try: |
| 81 | error_data = response.json() |
| 82 | print("Error:") |
| 83 | print(str(error_data)) |
| 84 | |
| 85 | except json.JSONDecodeError: |
| 86 | error_data = response.content |
| 87 | print(f"Error: Unable to parse JSON error data. {error_data}") |
| 88 | return None |
| 89 | |
| 90 | |
| 91 | def prepare_request(allpaths,index,last_stylized,resolution,seed,last_mask,last_last_mask,fillindenoise,edgedenoise,target,diffuse,forwards): |
nothing calls this directly
no outgoing calls
no test coverage detected