Spaces:
Running
Running
P01yH3dr0n
commited on
Commit
•
eef13e5
1
Parent(s):
98c3bc5
Update utils.py
Browse files
utils.py
CHANGED
@@ -42,10 +42,9 @@ def generate_novelai_image(
|
|
42 |
ref_image=None,
|
43 |
info_extract=1,
|
44 |
ref_str=0.6,
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
inp_str=0.7
|
49 |
):
|
50 |
# Assign a random seed if seed is -1
|
51 |
if seed == -1:
|
@@ -64,7 +63,7 @@ def generate_novelai_image(
|
|
64 |
"steps": steps,
|
65 |
"n_samples": 1,
|
66 |
"ucPreset": 0,
|
67 |
-
"add_original_image":
|
68 |
"cfg_rescale": cfg_rescale,
|
69 |
"controlnet_strength": 1,
|
70 |
"dynamic_thresholding": dyn_threshold,
|
@@ -72,7 +71,7 @@ def generate_novelai_image(
|
|
72 |
"legacy": False,
|
73 |
"legacy_v3_extend": False,
|
74 |
"negative_prompt": negative_prompt,
|
75 |
-
"noise":
|
76 |
"noise_schedule": schedule,
|
77 |
"qualityToggle": True,
|
78 |
"reference_information_extracted": info_extract,
|
@@ -85,6 +84,7 @@ def generate_novelai_image(
|
|
85 |
}
|
86 |
if ref_image is not None:
|
87 |
payload['parameters']['reference_image'] = image2base64(ref_image)
|
|
|
88 |
if use_inp:
|
89 |
payload['action'] = "infill"
|
90 |
payload['model'] = 'nai-diffusion-3-inpainting'
|
@@ -92,6 +92,12 @@ def generate_novelai_image(
|
|
92 |
payload['parameters']['image'] = image2base64(inp_img['background'])
|
93 |
payload['parameters']['extra_noise_seed'] = seed
|
94 |
payload['parameters']['strength'] = inp_str
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
# Send the POST request
|
96 |
response = requests.post(url, json=payload, headers=headers)
|
97 |
|
|
|
42 |
ref_image=None,
|
43 |
info_extract=1,
|
44 |
ref_str=0.6,
|
45 |
+
i2i_image=None,
|
46 |
+
i2i_str=0.7,
|
47 |
+
i2i_noise=0
|
|
|
48 |
):
|
49 |
# Assign a random seed if seed is -1
|
50 |
if seed == -1:
|
|
|
63 |
"steps": steps,
|
64 |
"n_samples": 1,
|
65 |
"ucPreset": 0,
|
66 |
+
"add_original_image": True,
|
67 |
"cfg_rescale": cfg_rescale,
|
68 |
"controlnet_strength": 1,
|
69 |
"dynamic_thresholding": dyn_threshold,
|
|
|
71 |
"legacy": False,
|
72 |
"legacy_v3_extend": False,
|
73 |
"negative_prompt": negative_prompt,
|
74 |
+
"noise": i2i_noise,
|
75 |
"noise_schedule": schedule,
|
76 |
"qualityToggle": True,
|
77 |
"reference_information_extracted": info_extract,
|
|
|
84 |
}
|
85 |
if ref_image is not None:
|
86 |
payload['parameters']['reference_image'] = image2base64(ref_image)
|
87 |
+
'''
|
88 |
if use_inp:
|
89 |
payload['action'] = "infill"
|
90 |
payload['model'] = 'nai-diffusion-3-inpainting'
|
|
|
92 |
payload['parameters']['image'] = image2base64(inp_img['background'])
|
93 |
payload['parameters']['extra_noise_seed'] = seed
|
94 |
payload['parameters']['strength'] = inp_str
|
95 |
+
'''
|
96 |
+
if i2i_image is not None:
|
97 |
+
payload['action'] = "img2img"
|
98 |
+
payload['parameters']['image'] = image2base64(i2i_image)
|
99 |
+
payload['parameters']['strength'] = i2i_str
|
100 |
+
payload['parameters']['extra_noise_seed'] = seed
|
101 |
# Send the POST request
|
102 |
response = requests.post(url, json=payload, headers=headers)
|
103 |
|