mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
@@ -90,7 +90,7 @@ class APIGenerate:
|
||||
script_runner = scripts_manager.scripts_txt2img
|
||||
if not script_runner.scripts:
|
||||
script_runner.initialize_scripts(False)
|
||||
ui.create_ui(None)
|
||||
# ui.create_ui(None)
|
||||
if not self.default_script_arg_txt2img:
|
||||
self.default_script_arg_txt2img = script.init_default_script_args(script_runner)
|
||||
selectable_scripts, selectable_script_idx = script.get_selectable_script(txt2imgreq.script_name, script_runner)
|
||||
@@ -141,7 +141,7 @@ class APIGenerate:
|
||||
script_runner = scripts_manager.scripts_img2img
|
||||
if not script_runner.scripts:
|
||||
script_runner.initialize_scripts(True)
|
||||
ui.create_ui(None)
|
||||
# ui.create_ui(None)
|
||||
if not self.default_script_arg_img2img:
|
||||
self.default_script_arg_img2img = script.init_default_script_args(script_runner)
|
||||
selectable_scripts, selectable_script_idx = script.get_selectable_script(img2imgreq.script_name, script_runner)
|
||||
|
||||
@@ -73,6 +73,8 @@ def init_default_script_args(script_runner):
|
||||
if script.ui(script.is_img2img):
|
||||
ui_default_values = []
|
||||
for elem in script.ui(script.is_img2img):
|
||||
if elem is None:
|
||||
continue
|
||||
ui_default_values.append(elem.value)
|
||||
script_args[script.args_from:script.args_to] = ui_default_values
|
||||
return script_args
|
||||
|
||||
@@ -14,7 +14,7 @@ debug = os.environ.get('SD_QUEUE_DEBUG', None) is not None
|
||||
def get_lock():
|
||||
if debug:
|
||||
fn = f'{sys._getframe(3).f_code.co_name}:{sys._getframe(2).f_code.co_name}:{sys._getframe(1).f_code.co_name}' # pylint: disable=protected-access
|
||||
log.debug(f'Queue: fn={fn} lock={queue_lock.locked()}')
|
||||
log.debug(f'Queue: lock={queue_lock.locked()} fn={fn}')
|
||||
return queue_lock
|
||||
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--rescale', type=float, default=0.0, help='cfg rescale')
|
||||
parser.add_argument('--distilled', type=float, default=10.0, help='cfg distilled')
|
||||
parser.add_argument('--shift', type=float, default=3.0, help='sampler shift')
|
||||
parser.add_argument('--variant', type=str, default='bi-directional', choices=['bi-directional', 'forward-only'], help='model variant')
|
||||
parser.add_argument('--variant', type=str, default='Bi-Directional', choices=['Bi-Directional', 'Forward-Only'], help='model variant')
|
||||
args = parser.parse_args()
|
||||
log.info(f'api-framepack: {args}')
|
||||
generate(args)
|
||||
|
||||
@@ -5,8 +5,9 @@ from modules.logger import log
|
||||
|
||||
|
||||
models = {
|
||||
'bi-directional': 'lllyasviel/FramePackI2V_HY',
|
||||
'forward-only': 'lllyasviel/FramePack_F1_I2V_HY_20250503',
|
||||
'None': None,
|
||||
'Bi-Directional': 'lllyasviel/FramePackI2V_HY',
|
||||
'Forward-Only': 'lllyasviel/FramePack_F1_I2V_HY_20250503',
|
||||
}
|
||||
default_model = {
|
||||
'pipeline': { 'repo': 'hunyuanvideo-community/HunyuanVideo', 'subfolder': '' },
|
||||
@@ -21,7 +22,7 @@ default_model = {
|
||||
'tokenizer_2': { 'repo': 'hunyuanvideo-community/HunyuanVideo', 'subfolder': 'tokenizer_2' },
|
||||
'feature_extractor': { 'repo': 'lllyasviel/flux_redux_bfl', 'subfolder': 'feature_extractor' },
|
||||
'image_encoder': { 'repo': 'lllyasviel/flux_redux_bfl', 'subfolder': 'image_encoder' },
|
||||
'transformer': { 'repo': models.get('bi-directional'), 'subfolder': '' },
|
||||
'transformer': { 'repo': models.get('Bi-Directional'), 'subfolder': '' },
|
||||
}
|
||||
model = default_model.copy()
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ def create_ui(prompt, negative, styles, _overrides, script_inputs, mp4_fps, mp4_
|
||||
with gr.Row():
|
||||
generate = gr.Button('Generate', elem_id="framepack_generate_btn", variant='primary', visible=False)
|
||||
with gr.Row():
|
||||
variant = gr.Dropdown(label="FP model variant", choices=list(framepack_load.models), value='bi-directional', type='value')
|
||||
variant = gr.Dropdown(label="FP model variant", choices=list(framepack_load.models), value='None', type='value')
|
||||
with gr.Row():
|
||||
resolution = gr.Slider(label="FP resolution", minimum=240, maximum=1088, value=640, step=16)
|
||||
duration = gr.Slider(label="FP duration", minimum=1, maximum=120, value=4, step=0.1)
|
||||
|
||||
@@ -14,7 +14,7 @@ stream = None # AsyncStream
|
||||
def get_latent_paddings(mp4_fps, mp4_interpolate, latent_window_size, total_second_length, variant):
|
||||
try:
|
||||
real_fps = mp4_fps / (mp4_interpolate + 1)
|
||||
is_f1 = variant == 'forward-only'
|
||||
is_f1 = variant == 'Forward-Only'
|
||||
if is_f1:
|
||||
total_latent_sections = (total_second_length * real_fps) / (latent_window_size * 4)
|
||||
total_latent_sections = int(max(round(total_latent_sections), 1))
|
||||
@@ -59,7 +59,7 @@ def worker(
|
||||
from modules.framepack.pipeline import utils
|
||||
from modules.framepack.pipeline import k_diffusion_hunyuan
|
||||
|
||||
is_f1 = variant == 'forward-only'
|
||||
is_f1 = variant == 'Forward-Only'
|
||||
total_generated_frames = 0
|
||||
total_generated_latent_frames = 0
|
||||
latent_paddings = get_latent_paddings(mp4_fps, mp4_interpolate, latent_window_size, total_second_length, variant)
|
||||
|
||||
@@ -115,7 +115,11 @@ def unload_model():
|
||||
|
||||
|
||||
def run_framepack(task_id, _ui_state, init_image, end_image, start_weight, end_weight, vision_weight, prompt, system_prompt, optimized_prompt, section_prompt, negative_prompt, styles, seed, resolution, duration, latent_ws, steps, cfg_scale, cfg_distilled, cfg_rescale, shift, use_teacache, use_cfgzero, use_preview, mp4_fps, mp4_codec, mp4_sf, mp4_video, mp4_frames, mp4_thumb, mp4_opt, mp4_ext, mp4_interpolate, attention, vae_type, variant, vlm_enhance, vlm_model, vlm_system_prompt, *_args, **_kwargs):
|
||||
variant = variant or 'bi-directional'
|
||||
variant = variant or 'Bi-Directional'
|
||||
if variant == 'None':
|
||||
log.error('FramePack: no model selected')
|
||||
yield gr.update(), gr.update(), 'No FramePack model selected'
|
||||
return
|
||||
if init_image is None:
|
||||
init_image = np.zeros((resolution, resolution, 3), dtype=np.uint8)
|
||||
mode = 't2v'
|
||||
|
||||
@@ -638,7 +638,10 @@ class ScriptRunner:
|
||||
script_index = args[0] if len(args) > 0 else 0
|
||||
if (script_index is None) or (script_index == 0):
|
||||
return processed
|
||||
script = self.selectable_scripts[script_index - 1]
|
||||
try:
|
||||
script = self.selectable_scripts[script_index - 1]
|
||||
except Exception:
|
||||
script = None
|
||||
if script is None or not hasattr(script, 'after'):
|
||||
return processed
|
||||
parsed = []
|
||||
|
||||
@@ -731,7 +731,7 @@ def load_diffuser_file(model_type: str, pipeline, checkpoint_info: CheckpointInf
|
||||
sd_model = load_sd3(checkpoint_info, diffusers_load_config)
|
||||
elif hasattr(pipeline, 'from_single_file'):
|
||||
diffusers.loaders.single_file_utils.CHECKPOINT_KEY_NAMES["clip"] = "cond_stage_model.transformer.text_model.embeddings.position_embedding.weight" # patch for diffusers==0.28.0
|
||||
diffusers_load_config['safety_checker'] = None, # sd15 specific but we cant know ahead of time
|
||||
diffusers_load_config['safety_checker'] = None # sd15 specific but we cant know ahead of time
|
||||
diffusers_load_config['requires_safety_checker'] = False # sd15 specific but we cant know ahead of time
|
||||
diffusers_load_config['use_safetensors'] = True
|
||||
diffusers_load_config.pop('cache_dir', None)
|
||||
|
||||
Vendored
+2
-2
@@ -11507,9 +11507,9 @@ function submit_control(...args) {
|
||||
return res;
|
||||
}
|
||||
function submit_video(...args) {
|
||||
log("submitVideo");
|
||||
clearGallery("video");
|
||||
const id = randomId();
|
||||
log("submitVideo", id);
|
||||
requestProgress(id, null, gradioApp().getElementById("video_gallery"));
|
||||
const res = create_submit_args(args);
|
||||
res[0] = id;
|
||||
@@ -11545,8 +11545,8 @@ function submit_video_wrapper(...args) {
|
||||
const modernEl = gradioApp().querySelector(".video_output.fade-in");
|
||||
let id = modernEl ? modernEl.id : args[0];
|
||||
id = id.replace("video-selector-", "");
|
||||
log("submitVideoWrapper", id);
|
||||
const btn = gradioApp().getElementById(`${id}_generate_btn`);
|
||||
log("submitVideoWrapper", { type: id, found: !!btn });
|
||||
if (btn) btn.click();
|
||||
}
|
||||
function submit_postprocessing(...args) {
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
@@ -318,9 +318,9 @@ function submit_control(...args) {
|
||||
}
|
||||
|
||||
function submit_video(...args) {
|
||||
log('submitVideo');
|
||||
clearGallery('video');
|
||||
const id = randomId();
|
||||
log('submitVideo', id);
|
||||
requestProgress(id, null, gradioApp().getElementById('video_gallery'));
|
||||
const res = create_submit_args(args);
|
||||
res[0] = id;
|
||||
@@ -360,8 +360,8 @@ function submit_video_wrapper(...args) {
|
||||
const modernEl = gradioApp().querySelector('.video_output.fade-in');
|
||||
let id = modernEl ? modernEl.id : args[0];
|
||||
id = id.replace('video-selector-', '');
|
||||
log('submitVideoWrapper', id);
|
||||
const btn = gradioApp().getElementById(`${id}_generate_btn`);
|
||||
log('submitVideoWrapper', { type: id, found: !!btn });
|
||||
if (btn) btn.click();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def initialize():
|
||||
from modules.models_hf import hf_init
|
||||
hf_init()
|
||||
|
||||
log.critical(f'Paths: data="{modules.paths.data_path}" models="{modules.paths.models_path}" temp="{modules.paths.temp_dir}"')
|
||||
log.info(f'Paths: data="{modules.paths.data_path}" models="{modules.paths.models_path}" temp="{modules.paths.temp_dir}"')
|
||||
|
||||
modules.sd_checkpoint.init_metadata()
|
||||
modules.hashes.load_cache()
|
||||
|
||||
Reference in New Issue
Block a user