img-booru Not under Vixen control
Media
Rating
Thumbnail Size
Theme

An import status file says an import was running, but it has not updated recently.

import torch
from torch import autocast
from compel import Compel
import base64
from PIL import Image
from io import BytesIO
import numpy as np



from diffusers import DiffusionPipeline, AutoencoderKL, StableDiffusionImg2ImgPipeline,AutoPipelineForImage2Image,AutoPipelineForInpainting,StableDiffusionPipeline
model_id = "IDK-ab0ut/Yiffymix_v52-XL" # has new pooled embeds
model1_id=model_id
model2_id=model_id

device = "cuda"

pipe1 = None


pipe2 = AutoPipelineForInpainting.from_pretrained(model2_id, torch_dtype=torch.float16, use_safetensors=True)

pipe2 = pipe2.to(device)
compel_proc2 = Compel(tokenizer=[pipe2.tokenizer,pipe2.tokenizer_2], text_encoder=[pipe2.text_encoder, pipe2.text_encoder_2], truncate_long_prompts=False,  requires_pooled=[False, True])

def display(img):
    img.show()


def test(prompt,i=1,start=1024,depth=30,guidance_scale=7.5, negative_prompt=None, pipe=pipe1, width=512, height=512, skip=2):
    if isinstance(prompt,str):
        posprompt=prompt
        negprompt=negative_prompt
    else:
        posprompt=prompt[0]
        negprompt=prompt[1]
    print("+ %s\n- %s\n"%(posprompt,negprompt))
    prompt_embeds, prompt_embeds_pooled = compel_proc(posprompt)
    negative_prompt_embeds, negative_prompt_embeds_pooled = compel_proc(negprompt)
    [prompt_embeds,negative_prompt_embeds] = compel_proc.pad_conditioning_tensors_to_same_length([prompt_embeds, negative_prompt_embeds])
    results=[]
    for a in range(start,start+i):
        generator = torch.Generator(device).manual_seed(a)
        with autocast(device):
            image = pipe(prompt_embeds=prompt_embeds, pooled_prompt_embeds=prompt_embeds_pooled, guidance_scale=guidance_scale,num_inference_steps=depth, generator=generator, negative_prompt_embeds=negative_prompt_embeds, negative_pooled_prompt_embeds=negative_prompt_embeds_pooled, clip_skip=skip, width=width,height=height).images[0]
            print(a)
            display(image)
            results.append(image)
    return results
    

def generate(prompt,i,depth=60,guidance_scale=7.5,negative_prompt=None,width=512,height=512,pipe=pipe1, skip=2):
    return test(prompt,1,start=i,depth=depth,guidance_scale=guidance_scale,negative_prompt=negative_prompt,width=width,height=height,pipe=pipe,skip=skip)

def improvetest(prompt, inputimg=None, maskimage=None, i=1,strength=0.3,start=1024,depth=30,guidance_scale=7.5, negative_prompt=None, pipe=pipe2, skip=2, width=512, height=512):
    if isinstance(prompt,str):
        posprompt=prompt
        negprompt=negative_prompt
    else:
        posprompt=prompt[0]
        negprompt=prompt[1]
    print("+ %s\n- %s\n"%(posprompt,negprompt))
    prompt_embeds, prompt_embeds_pooled = compel_proc2(posprompt)
    negative_prompt_embeds, negative_prompt_embeds_pooled = compel_proc2(negprompt)
    [prompt_embeds,negative_prompt_embeds] = compel_proc2.pad_conditioning_tensors_to_same_length([prompt_embeds, negative_prompt_embeds])
    results=[]
    for a in range(start,start+i):
        generator = torch.Generator(device).manual_seed(a)
        with autocast(device):
            with torch.inference_mode():
                image = pipe(image=inputimg, mask_image=maskimage, strength=strength, prompt_embeds=prompt_embeds, pooled_prompt_embeds=prompt_embeds_pooled, guidance_scale=guidance_scale,num_inference_steps=depth, generator=generator, negative_prompt_embeds=negative_prompt_embeds, negative_pooled_prompt_embeds=negative_prompt_embeds_pooled, clip_skip=skip, width=width, height=height).images[0]
            print(a)
            display(image)
            results.append(image)
    return results

def improve(prompt,inputimg,i,strength=0.3,depth=60,guidance_scale=7.5,negative_prompt=None,pipe=pipe2):
    return improvetest(prompt,inputimg, 1,strength=strength,start=i,depth=depth,guidance_scale=guidance_scale,negative_prompt=negative_prompt,pipe=pipe)

def resize(img):
    w,h=img.size
    s=max(w,h)
    f=512./s
    return img.resize((int(w*f),int(h*f)))

def loadimage(data):
    r=base64.b64decode((data.split("base64,",1))[-1])
    img = Image.open(BytesIO(r))
    npimg=np.array(img)
    npimg=npimg[:,:,[0,1,2]]
    return Image.fromarray(npimg)
    return resize(Image.fromarray(npimg))

white="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAA3NCSVQICAjb4U/gAAAAGUlEQVQYV2P8//8/AyHAREgBSH5UEb2DAAA/qQMVBPlgXQAAAABJRU5ErkJggg=="
imgbb=loadimage(white)



p0="""
Photorealistic:

The butcher, a middle aged bull leaned back and waited for the next client.

A young gazelle stepped in: Sylvia turned 14 today and it was time for her to get processed.

The butcher told her to lay down on the large table.

Sylvia stretched, exposing her naked belly.

Are you excited? the butcher asked her, petting her belly.


"""

n0="""ugly"""
p=(p0,n0)

res0=improvetest(p,imgbb,imgbb,1,strength=1.0,guidance_scale=3,depth=35,start=1002)

x=res0[0]

p0="""
Photorealistic:

A young gazelle has come to visit the butcher bull to be processed.
She was told to lay down on the table.

Sylvia the gazelle nodded and patiently held still. The knife was very sharp. The man cut the gazelle deep and open, sliced her belly-skin, and took out her inner organs.

"""


n0="""ugly"""
p=(p0,n0)

res0=improvetest(p,x,imgbb,1,strength=0.65,guidance_scale=3.5,depth=30,start=1018)
y=res0[0]

p0="""
Photorealistic:

A young gazelle has come to visit the butcher bull to be processed.
She was told to lay down on the table.

After Sylvia was butchered her belly was filled with delicious vegetables and stuffed to the brim.
She squirmed, her belly bulging and twitching, excited for what would come next. her nipples got pointy.

photorealistic fur
gazelle stuffed with vegetables
"""


n0="""ugly"""
p=(p0,n0)

res0=improvetest(p,y,imgbb,1,strength=0.65,guidance_scale=3.5,depth=30,start=1006)
z=res0[0]

p0="""
Photorealistic:

A young gazelle has come to visit the kitchen to be processed.
She was told to lay down on the table.

After Sylvia had been roasted in the oven, she had turned into a very delicious gazelle roast.

Stretching on her back on a serving platter, her roasted meat juicy, her roasted skin crispy,
and completely cooked through, with her belly stuffed with delicious roasted vegetables, her tiny breasts crispy.

Her roasted body was roasted to perfection, completely cooked through and through.
"""

n0="""ugly"""
p=(p0,n0)

res0=improvetest(p,x,imgbb,1,strength=0.65,guidance_scale=3.5,depth=25,start=1006)
v=res0[0]

Descriptions

inkbunny.net · 3618485:5564246

Disclaimer:

[b]I have enough friends on IB who hate AI generated art, so I am deliberately making it hard to see these unless you are into this enough to run the code yourself ;)[/b]

Instructions:

Please download attached .py.txt file and rename to .py execute as python code to generate the full picture series. ( read code before blindly executing as safety precaution)

Warning: Needs at least 10 GB of GPU RAM or will run out of memory. Tweaks to run on CPU might be possible.  You might have to install some dependencies (huggingface library) - see error messages about missing imports and use "pip" or "conda" as needed.

For complete prompt data and random seeds please see attached sourcecode

Also, to see the full res picture series please run the sourcecode.

Feel free to play with it and make your own if you like

[b]prompt1: (generation) (technically img 2 img in code, but source image is just plain white background and strength is 1.0, overriding source completely)[/b]

Photorealistic:

The butcher, a middle aged bull leaned back and waited for the next client.

A young gazelle stepped in: Sylvia turned 14 today and it was time for her to get processed.

The butcher told her to lay down on the large table.

Sylvia stretched, exposing her naked belly.

Are you excited? the butcher asked her, petting her belly.

[b]prompt 2: (run as image 2 image on the result of prompt1)[/b]

Photorealistic:

A young gazelle has come to visit the butcher bull to be processed.
She was told to lay down on the table.

Sylvia the gazelle nodded and patiently held still. The knife was very sharp. The man cut the gazelle deep and open, sliced her belly-skin, and took out her inner organs.

[b]prompt 3: (run as image 2 image on the result of prompt 2)[/b]

Photorealistic:

A young gazelle has come to visit the butcher bull to be processed.
She was told to lay down on the table.

After Sylvia was butchered her belly was filled with delicious vegetables and stuffed to the brim.
She squirmed, her belly bulging and twitching, excited for what would come next. her nipples got pointy.

photorealistic fur
gazelle stuffed with vegetables

[b]prompt 4: (run as image 2 image on result of prompt 1)[/b]

Photorealistic:

A young gazelle has come to visit the kitchen to be processed.
She was told to lay down on the table.

After Sylvia had been roasted in the oven, she had turned into a very delicious gazelle roast.

Stretching on her back on a serving platter, her roasted meat juicy, her roasted skin crispy,
and completely cooked through, with her belly stuffed with delicious roasted vegetables, her tiny breasts crispy.

Her roasted body was roasted to perfection, completely cooked through and through.

[b]negative prompt on all 4[/b]:  "ugly"

Comments

No comments yet.

Log in to comment.