Spaces:
Running
Running
P01yH3dr0n
commited on
Commit
•
9181b21
1
Parent(s):
0041adc
Update utils.py
Browse files
utils.py
CHANGED
@@ -5,7 +5,7 @@ import requests
|
|
5 |
import json
|
6 |
import base64
|
7 |
|
8 |
-
from PIL import Image
|
9 |
|
10 |
|
11 |
jwt_token = ''
|
@@ -88,10 +88,10 @@ def generate_novelai_image(
|
|
88 |
}
|
89 |
if ref_image is not None:
|
90 |
payload['parameters']['reference_image'] = image2base64(ref_image)
|
91 |
-
if selection == 'inp' and inp_img
|
92 |
payload['action'] = "infill"
|
93 |
payload['model'] = 'nai-diffusion-3-inpainting'
|
94 |
-
payload['parameters']['mask'] = image2base64(inp_img['layers'][0])
|
95 |
payload['parameters']['image'] = image2base64(inp_img['background'])
|
96 |
payload['parameters']['extra_noise_seed'] = seed
|
97 |
if i2i_image is not None and selection == 'i2i':
|
|
|
5 |
import json
|
6 |
import base64
|
7 |
|
8 |
+
from PIL import Image, ImageChops
|
9 |
|
10 |
|
11 |
jwt_token = ''
|
|
|
88 |
}
|
89 |
if ref_image is not None:
|
90 |
payload['parameters']['reference_image'] = image2base64(ref_image)
|
91 |
+
if selection == 'inp' and inp_img['background'].getextrema()[3][1] > 0:
|
92 |
payload['action'] = "infill"
|
93 |
payload['model'] = 'nai-diffusion-3-inpainting'
|
94 |
+
payload['parameters']['mask'] = image2base64(ImageChops.invert(inp_img['layers'][0]))
|
95 |
payload['parameters']['image'] = image2base64(inp_img['background'])
|
96 |
payload['parameters']['extra_noise_seed'] = seed
|
97 |
if i2i_image is not None and selection == 'i2i':
|