Upload txt2gif-Breastgrowthfast.py
Browse files
Lora/timelapseBreast_breastV1/txt2gif-Breastgrowthfast.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import modules.scripts as scripts
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
import uuid
|
| 5 |
+
|
| 6 |
+
from modules.processing import process_images, Processed, fix_seed
|
| 7 |
+
from modules.shared import opts, cmd_opts, state
|
| 8 |
+
|
| 9 |
+
def build_prompts(character_prompt, lora_name, lora_strength):
|
| 10 |
+
prompts = []
|
| 11 |
+
|
| 12 |
+
prompts.append(f"topless, (small breasts:1.2), nipples, {character_prompt}, ")
|
| 13 |
+
prompts.append(f"topless, (small breasts:1.1), nipples, {character_prompt}, ")
|
| 14 |
+
prompts.append(f"topless, (small breasts:1.0), nipples, {character_prompt}, ")
|
| 15 |
+
prompts.append(f"topless, (small breasts:0.9), nipples, {character_prompt}, ")
|
| 16 |
+
prompts.append(f"topless, (small breasts:0.8), nipples, {character_prompt}, ")
|
| 17 |
+
prompts.append(f"topless, medium breasts, nipples, {character_prompt}, ")
|
| 18 |
+
prompts.append(f"topless, medium breasts, nipples, {character_prompt}, ")
|
| 19 |
+
prompts.append(f"topless, (large breasts:0.9), nipples, {character_prompt}, ")
|
| 20 |
+
prompts.append(f"topless, (large breasts:1.0), nipples, {character_prompt}, ")
|
| 21 |
+
prompts.append(f"topless, (large breasts:1.1), nipples, {character_prompt}, ")
|
| 22 |
+
prompts.append(f"topless, (large breasts:1.2), nipples, {character_prompt}, ")
|
| 23 |
+
prompts.append(f"topless, (large breasts:1.3), nipples, {character_prompt}, ")
|
| 24 |
+
prompts.append(f"topless, (large breasts:1.4), nipples, {character_prompt}, ")
|
| 25 |
+
prompts.append(f"topless, (huge breasts:1.0), nipples, {character_prompt}, ")
|
| 26 |
+
prompts.append(f"topless, (huge breasts:1.1), nipples, {character_prompt}, ")
|
| 27 |
+
prompts.append(f"topless, (huge breasts:1.2), nipples, {character_prompt}, ")
|
| 28 |
+
prompts.append(f"topless, (huge breasts:1.3), nipples, {character_prompt}, ")
|
| 29 |
+
prompts.append(f"topless, (huge breasts:1.4), nipples, {character_prompt}, ")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
return prompts
|
| 38 |
+
|
| 39 |
+
def make_gif(frames, filename = None):
|
| 40 |
+
if filename is None:
|
| 41 |
+
filename = str(uuid.uuid4())
|
| 42 |
+
|
| 43 |
+
outpath = "outputs/txt2img-images/txt2gif-Breastgrowthfast"
|
| 44 |
+
if not os.path.exists(outpath):
|
| 45 |
+
os.makedirs(outpath)
|
| 46 |
+
|
| 47 |
+
first_frame, append_frames = frames[0], frames[1:]
|
| 48 |
+
|
| 49 |
+
first_frame.save(f"{outpath}/{filename}.gif", format="GIF", append_images=append_frames,
|
| 50 |
+
save_all=True, duration=100, loop=0)
|
| 51 |
+
|
| 52 |
+
return first_frame
|
| 53 |
+
|
| 54 |
+
def main(p, lora_name, lora_strength):
|
| 55 |
+
character_prompt = p.prompt.strip().rstrip(',')
|
| 56 |
+
frame_prompts = build_prompts(character_prompt, lora_name, lora_strength)
|
| 57 |
+
|
| 58 |
+
fix_seed(p)
|
| 59 |
+
|
| 60 |
+
state.job_count = len(frame_prompts)
|
| 61 |
+
|
| 62 |
+
imgs = []
|
| 63 |
+
all_prompts = []
|
| 64 |
+
infotexts = []
|
| 65 |
+
|
| 66 |
+
for i in range(len(frame_prompts)):
|
| 67 |
+
if state.interrupted:
|
| 68 |
+
break
|
| 69 |
+
|
| 70 |
+
p.prompt = frame_prompts[i]
|
| 71 |
+
proc = process_images(p)
|
| 72 |
+
|
| 73 |
+
if state.interrupted:
|
| 74 |
+
break
|
| 75 |
+
|
| 76 |
+
imgs += proc.images
|
| 77 |
+
all_prompts += proc.all_prompts
|
| 78 |
+
infotexts += proc.infotexts
|
| 79 |
+
|
| 80 |
+
gif = [make_gif(imgs)]
|
| 81 |
+
|
| 82 |
+
imgs += gif
|
| 83 |
+
|
| 84 |
+
return Processed(p, imgs, p.seed, "", all_prompts=all_prompts, infotexts=infotexts)
|
| 85 |
+
|
| 86 |
+
class Script(scripts.Script):
|
| 87 |
+
is_txt2img = False
|
| 88 |
+
|
| 89 |
+
# Function to set title
|
| 90 |
+
def title(self):
|
| 91 |
+
return "txt2gif-Breastgrowthfast"
|
| 92 |
+
|
| 93 |
+
def ui(self, is_img2img):
|
| 94 |
+
with gr.Row():
|
| 95 |
+
lora_name = gr.Textbox(label="lora name", value = "")
|
| 96 |
+
with gr.Row():
|
| 97 |
+
lora_strength = gr.Number(label="lora strength", value = 0)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
return [lora_name, lora_strength]
|
| 101 |
+
|
| 102 |
+
# Function to show the script
|
| 103 |
+
def show(self, is_img2img):
|
| 104 |
+
return True
|
| 105 |
+
|
| 106 |
+
# Function to run the script
|
| 107 |
+
def run(self, p, lora_name, lora_strength):
|
| 108 |
+
# Make a process_images Object
|
| 109 |
+
return main(p, lora_name, lora_strength)
|