Browse Source

Add: optional input strip data

tin2tin-patch-1
tin2tin 1 year ago committed by GitHub
parent
commit
707f6a8399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      __init__.py

27
__init__.py

@ -812,6 +812,11 @@ class GeneratorAddonPreferences(AddonPreferences):
default=join(bpy.utils.user_resource("DATAFILES"), "Generator AI"), default=join(bpy.utils.user_resource("DATAFILES"), "Generator AI"),
) )
use_strip_data: BoolProperty(
name="Use Input Strip Data",
default=True,
)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
box = layout.box() box = layout.box()
@ -838,6 +843,13 @@ class GeneratorAddonPreferences(AddonPreferences):
sub_row.operator("renderreminder.play_notification", text="", icon="PLAY") sub_row.operator("renderreminder.play_notification", text="", icon="PLAY")
sub_row.active = self.playsound sub_row.active = self.playsound
row_row = box.row(align=True)
row_row.label(text="Use Input Strip Data:")
row_row.prop(self, "use_strip_data", text="")
row_row.label(text="")
row_row.label(text="")
row_row.label(text="")
class GENERATOR_OT_install(Operator): class GENERATOR_OT_install(Operator):
"""Install all dependencies""" """Install all dependencies"""
@ -1803,7 +1815,7 @@ class SEQUENCER_OT_generate_image(Operator):
type = scene.generatorai_typeselect type = scene.generatorai_typeselect
input = scene.input_strips input = scene.input_strips
prompt = style_prompt(scene.generate_movie_prompt)[0] prompt = style_prompt(scene.generate_movie_prompt)[0]
negative_prompt = scene.generate_movie_negative_prompt +", "+ style_prompt(scene.generate_movie_prompt)[1] +", nsfw nude nudity" negative_prompt = scene.generate_movie_negative_prompt +", "+ style_prompt(scene.generate_movie_prompt)[1] +", nsfw, nude, nudity,"
image_x = scene.generate_movie_x image_x = scene.generate_movie_x
image_y = scene.generate_movie_y image_y = scene.generate_movie_y
x = scene.generate_movie_x = closest_divisible_64(image_x) x = scene.generate_movie_x = closest_divisible_64(image_x)
@ -1816,7 +1828,7 @@ class SEQUENCER_OT_generate_image(Operator):
addon_prefs = preferences.addons[__name__].preferences addon_prefs = preferences.addons[__name__].preferences
image_model_card = addon_prefs.image_model_card image_model_card = addon_prefs.image_model_card
do_inpaint = input == "input_strips" and scene.inpaint_selected_strip and type == "image" do_inpaint = input == "input_strips" and scene.inpaint_selected_strip and type == "image"
do_refine = (scene.refine_sd or scene.image_path or image_model_card == "stabilityai/stable-diffusion-xl-base-1.0") and not do_inpaint do_refine = (scene.refine_sd or scene.image_path or image_model_card == "stabilityai/stable-diffusion-xl-base-1.0") #and not do_inpaint
# LOADING MODELS # LOADING MODELS
print("Model: " + image_model_card) print("Model: " + image_model_card)
@ -2221,6 +2233,7 @@ class SEQUENCER_OT_strip_to_generatorAI(Operator):
type = scene.generatorai_typeselect type = scene.generatorai_typeselect
seed = scene.movie_num_seed seed = scene.movie_num_seed
use_random = scene.movie_use_random use_random = scene.movie_use_random
use_strip_data = addon_prefs.use_strip_data
if not strips: if not strips:
self.report({"INFO"}, "Select strip(s) for processing.") self.report({"INFO"}, "Select strip(s) for processing.")
@ -2267,12 +2280,12 @@ class SEQUENCER_OT_strip_to_generatorAI(Operator):
seed_nr = extract_numbers(str(strip_prompt)) seed_nr = extract_numbers(str(strip_prompt))
if seed_nr: if seed_nr:
file_seed = int(seed_nr) file_seed = int(seed_nr)
if file_seed: if file_seed and use_strip_data:
strip_prompt = (strip_prompt.replace(str(file_seed)+"_", "")) strip_prompt = (strip_prompt.replace(str(file_seed)+"_", ""))
context.scene.movie_use_random = False context.scene.movie_use_random = False
context.scene.movie_num_seed = file_seed context.scene.movie_num_seed = file_seed
if len(strips) > 1: if use_strip_data:
styled_prompt = style_prompt(strip_prompt + ", " + prompt)[0] styled_prompt = style_prompt(strip_prompt + ", " + prompt)[0]
styled_negative_prompt = style_prompt(strip_prompt + ", " + prompt)[1] styled_negative_prompt = style_prompt(strip_prompt + ", " + prompt)[1]
else: else:
@ -2296,6 +2309,7 @@ class SEQUENCER_OT_strip_to_generatorAI(Operator):
scene.generate_movie_prompt = prompt scene.generate_movie_prompt = prompt
scene.generate_movie_negative_prompt = negative_prompt scene.generate_movie_negative_prompt = negative_prompt
if use_strip_data:
scene.movie_use_random = use_random scene.movie_use_random = use_random
scene.movie_num_seed = seed scene.movie_num_seed = seed
@ -2312,12 +2326,12 @@ class SEQUENCER_OT_strip_to_generatorAI(Operator):
seed_nr = extract_numbers(str(strip_prompt)) seed_nr = extract_numbers(str(strip_prompt))
if seed_nr: if seed_nr:
file_seed = int(seed_nr) file_seed = int(seed_nr)
if file_seed: if file_seed and use_strip_data:
strip_prompt = (strip_prompt.replace(str(file_seed)+"_", "")) strip_prompt = (strip_prompt.replace(str(file_seed)+"_", ""))
context.scene.movie_use_random = False context.scene.movie_use_random = False
context.scene.movie_num_seed = file_seed context.scene.movie_num_seed = file_seed
if len(strips) > 1: if use_strip_data:
styled_prompt = style_prompt(strip_prompt + ", " + prompt)[0] styled_prompt = style_prompt(strip_prompt + ", " + prompt)[0]
styled_negative_prompt = style_prompt(strip_prompt + ", " + prompt)[1] styled_negative_prompt = style_prompt(strip_prompt + ", " + prompt)[1]
else: else:
@ -2341,6 +2355,7 @@ class SEQUENCER_OT_strip_to_generatorAI(Operator):
scene.generate_movie_prompt = prompt scene.generate_movie_prompt = prompt
scene.generate_movie_negative_prompt = negative_prompt scene.generate_movie_negative_prompt = negative_prompt
if use_strip_data:
scene.movie_use_random = use_random scene.movie_use_random = use_random
scene.movie_num_seed = seed scene.movie_num_seed = seed

Loading…
Cancel
Save