western92 commited on
Commit ·
176d2d4
1
Parent(s): 72dddd7
- .gitignore +2 -0
- __pycache__/handler.cpython-310.pyc +0 -0
- __pycache__/main.cpython-310.pyc +0 -0
- babe.png +0 -0
- babe.py +11 -17
- babe2.png +0 -0
- babe3.png +0 -0
- babe4.png +0 -0
- babe5.png +0 -0
- handler.py +6 -8
- main.py +16 -20
- test_handler.py +12 -7
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.othervenv
|
| 2 |
+
.myvenv
|
__pycache__/handler.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/handler.cpython-310.pyc and b/__pycache__/handler.cpython-310.pyc differ
|
|
|
__pycache__/main.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ
|
|
|
babe.png
CHANGED
|
Git LFS Details
|
|
babe.py
CHANGED
|
@@ -1,24 +1,18 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
|
| 4 |
-
x = get_nude(Image.open("girl.png"))
|
| 5 |
x[0].save("babe.png")
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
import concurrent.futures
|
| 11 |
-
from main import get_nude
|
| 12 |
-
from PIL import Image
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
x[0].save("babe.png")
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
x[0].save("babe2.png")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
executor.submit(process_image_2)
|
|
|
|
| 1 |
+
import concurrent.futures
|
| 2 |
+
from main import get_nude
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
+
x = get_nude(Image.open("girl.png"), replicate_api_key="r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",with_big_tits=True)
|
| 6 |
x[0].save("babe.png")
|
| 7 |
|
| 8 |
+
x2 = get_nude(Image.open("girl.png"), replicate_api_key="r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",with_big_tits=True)
|
| 9 |
+
x2[0].save("babe2.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
x3 = get_nude(Image.open("girl.png"), replicate_api_key="r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",with_small_tits=True)
|
| 12 |
+
x3[0].save("babe3.png")
|
|
|
|
| 13 |
|
| 14 |
+
x4 = get_nude(Image.open("girl.png"), replicate_api_key="r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk")
|
| 15 |
+
x4[0].save("babe4.png")
|
|
|
|
| 16 |
|
| 17 |
+
x5 = get_nude(Image.open("girl.png"), replicate_api_key="r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",with_big_tits=True)
|
| 18 |
+
x5[0].save("babe5.png")
|
|
|
babe2.png
CHANGED
|
Git LFS Details
|
|
babe3.png
ADDED
|
babe4.png
ADDED
|
babe5.png
ADDED
|
handler.py
CHANGED
|
@@ -62,18 +62,16 @@ class EndpointHandler():
|
|
| 62 |
original_image_res = requests.get(data.get("original_link"))
|
| 63 |
original_pil = Image.open(BytesIO(original_image_res.content))
|
| 64 |
|
| 65 |
-
|
| 66 |
-
if (data.get("loras")):
|
| 67 |
-
loras = data.get("loras", "").split(",")
|
| 68 |
|
| 69 |
-
|
| 70 |
-
if (data.get("lora_weights")):
|
| 71 |
-
lora_weights = data.get("lora_weights", "").split(",")
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
nude_pils = get_nude_function(cfg_scale=data.get("cfg_scale"), generate_max_size=data.get("generate_max_size"), original_max_size=data.get(
|
| 76 |
-
"original_max_size"), original_pil=original_pil, positive_prompt=data.get("positive_prompt"), steps=data.get("steps"),
|
| 77 |
|
| 78 |
filenames = []
|
| 79 |
|
|
|
|
| 62 |
original_image_res = requests.get(data.get("original_link"))
|
| 63 |
original_pil = Image.open(BytesIO(original_image_res.content))
|
| 64 |
|
| 65 |
+
replicate_api_key = data.get("replicate_api_key", "")
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
print("got repli", replicate_api_key)
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
with_small_tits = data.get("with_small_tits", False)
|
| 70 |
+
|
| 71 |
+
with_big_tits = data.get("with_big_tits", False)
|
| 72 |
|
| 73 |
nude_pils = get_nude_function(cfg_scale=data.get("cfg_scale"), generate_max_size=data.get("generate_max_size"), original_max_size=data.get(
|
| 74 |
+
"original_max_size"), original_pil=original_pil, positive_prompt=data.get("positive_prompt"), steps=data.get("steps"), replicate_api_key=replicate_api_key, with_small_tits=with_small_tits, with_big_tits=with_big_tits)
|
| 75 |
|
| 76 |
filenames = []
|
| 77 |
|
main.py
CHANGED
|
@@ -181,30 +181,20 @@ base_pipe.enable_model_cpu_offload()
|
|
| 181 |
base_pipe.safety_checker = None
|
| 182 |
base_pipe.enable_xformers_memory_efficient_attention()
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
'path', "."), "models", lora), weight_name=lora, adapter_name=lora.split(".")[0])
|
| 189 |
|
|
|
|
|
|
|
| 190 |
|
| 191 |
-
|
| 192 |
-
if len(
|
| 193 |
-
loras) == 0:
|
| 194 |
-
return base_pipe
|
| 195 |
|
| 196 |
-
|
|
|
|
| 197 |
|
| 198 |
-
|
| 199 |
-
lora_weights = _.map_(lora_weights, lambda x: float(x))
|
| 200 |
-
|
| 201 |
-
if len(lora_weights) > 0 and len(lora_weights) == len(lora_names):
|
| 202 |
-
pipe.set_adapters(lora_names, adapter_weights=lora_weights)
|
| 203 |
-
|
| 204 |
-
return pipe
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
def get_nude(original_pil, original_max_size=2000, generate_max_size=768, positive_prompt="nude girl, pussy, tits", negative_prompt="ugly", steps=20, cfg_scale=7, loras=[], lora_weights=[], replicate_api_key=""):
|
| 208 |
try:
|
| 209 |
exif_data = original_pil._getexif()
|
| 210 |
orientation_tag = 274 # The Exif tag for orientation
|
|
@@ -299,7 +289,13 @@ def get_nude(original_pil, original_max_size=2000, generate_max_size=768, positi
|
|
| 299 |
dwpose_pil_resized = dwpose_pil.resize(
|
| 300 |
(int(expanded_mask_image_width), int(expanded_mask_image_height)))
|
| 301 |
|
| 302 |
-
pipe =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
end_result_images = pipe(
|
| 305 |
positive_prompt,
|
|
|
|
| 181 |
base_pipe.safety_checker = None
|
| 182 |
base_pipe.enable_xformers_memory_efficient_attention()
|
| 183 |
|
| 184 |
+
pipe_with_tit_slider = _.clone_deep(base_pipe)
|
| 185 |
|
| 186 |
+
pipe_with_tit_slider.load_lora_weights(os.path.join(os.environ.get(
|
| 187 |
+
'path', "."), "models", "breastsizeslideroffset.safetensors"), weight_name="breastsizeslideroffset.safetensors", adapter_name="breastsizeslideroffset")
|
|
|
|
| 188 |
|
| 189 |
+
pipe_with_small_tits = _.clone_deep(pipe_with_tit_slider)
|
| 190 |
+
pipe_with_small_tits.set_adapters("breastsizeslideroffset", adapter_weights=[-0.5])
|
| 191 |
|
| 192 |
+
pipe_with_medium_tits = _.clone_deep(base_pipe)
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
+
pipe_with_big_tits = _.clone_deep(pipe_with_tit_slider)
|
| 195 |
+
pipe_with_big_tits.set_adapters("breastsizeslideroffset", adapter_weights=[1])
|
| 196 |
|
| 197 |
+
def get_nude(original_pil, original_max_size=2000, generate_max_size=768, positive_prompt="nude girl, pussy, tits", negative_prompt="ugly", steps=20, cfg_scale=7, loras=[], lora_weights=[], replicate_api_key="", with_small_tits=False, with_big_tits=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
try:
|
| 199 |
exif_data = original_pil._getexif()
|
| 200 |
orientation_tag = 274 # The Exif tag for orientation
|
|
|
|
| 289 |
dwpose_pil_resized = dwpose_pil.resize(
|
| 290 |
(int(expanded_mask_image_width), int(expanded_mask_image_height)))
|
| 291 |
|
| 292 |
+
pipe = _.clone_deep(base_pipe)
|
| 293 |
+
|
| 294 |
+
if with_small_tits:
|
| 295 |
+
pipe = _.clone_deep(pipe_with_small_tits)
|
| 296 |
+
|
| 297 |
+
if with_big_tits:
|
| 298 |
+
pipe = _.clone_deep(pipe_with_big_tits)
|
| 299 |
|
| 300 |
end_result_images = pipe(
|
| 301 |
positive_prompt,
|
test_handler.py
CHANGED
|
@@ -23,23 +23,28 @@ handler = EndpointHandler(".")
|
|
| 23 |
|
| 24 |
def process_request_1():
|
| 25 |
result = handler(data={
|
|
|
|
| 26 |
"original_link": "https://i.ibb.co/w0nJvJQ/Td9sw-XMr-Rh-Xp-YPn0-B65q.png",
|
| 27 |
-
"
|
| 28 |
})
|
| 29 |
print("1", result)
|
| 30 |
|
| 31 |
def process_request_2():
|
| 32 |
result = handler(data={
|
|
|
|
| 33 |
"original_link": "https://i.ibb.co/TM7tdCG/image-5.png",
|
| 34 |
-
"
|
| 35 |
-
"lora_weights": "1"
|
| 36 |
})
|
| 37 |
print("2", result)
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 40 |
executor.submit(process_request_1)
|
| 41 |
executor.submit(process_request_2)
|
| 42 |
-
executor.submit(
|
| 43 |
-
executor.submit(process_request_1)
|
| 44 |
-
executor.submit(process_request_1)
|
| 45 |
-
executor.submit(process_request_2)
|
|
|
|
| 23 |
|
| 24 |
def process_request_1():
|
| 25 |
result = handler(data={
|
| 26 |
+
"replicate_api_key": "r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",
|
| 27 |
"original_link": "https://i.ibb.co/w0nJvJQ/Td9sw-XMr-Rh-Xp-YPn0-B65q.png",
|
| 28 |
+
"with_small_tits": True
|
| 29 |
})
|
| 30 |
print("1", result)
|
| 31 |
|
| 32 |
def process_request_2():
|
| 33 |
result = handler(data={
|
| 34 |
+
"replicate_api_key": "r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",
|
| 35 |
"original_link": "https://i.ibb.co/TM7tdCG/image-5.png",
|
| 36 |
+
"with_big_tits": True
|
|
|
|
| 37 |
})
|
| 38 |
print("2", result)
|
| 39 |
|
| 40 |
+
def process_request_3():
|
| 41 |
+
result = handler(data={
|
| 42 |
+
"replicate_api_key": "r8_GTeyENFqfOXFAI0COiGlB2RkhqEzqS64XBuIk",
|
| 43 |
+
"original_link": "https://i.ibb.co/TM7tdCG/image-5.png",
|
| 44 |
+
})
|
| 45 |
+
print("3", result)
|
| 46 |
+
|
| 47 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 48 |
executor.submit(process_request_1)
|
| 49 |
executor.submit(process_request_2)
|
| 50 |
+
executor.submit(process_request_3)
|
|
|
|
|
|
|
|
|