lcode-cli 0.45.0__py3-none-any.whl → 0.46.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lcode/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.45.0"
6
+ __version__ = "0.46.0"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
lcode/media.py CHANGED
@@ -6,10 +6,12 @@ sizes, variations and a gallery come with #151, video with #153.
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import json
9
10
  import os
10
11
  import random
11
12
  import re
12
13
  import shutil
14
+ import struct
13
15
  import subprocess
14
16
  import sys
15
17
  import time
@@ -269,6 +271,7 @@ def thumbnail(server: comfy.Server, outputs: dict, node: str = THUMB_NODES[1]) -
269
271
 
270
272
  SIZE_FLAG = re.compile(r"(?:^|\s)--?(ar|aspect|size)\b")
271
273
  MASK_FLAG = re.compile(r'(?:^|\s)--mask\s+("[^"]+"|\S+)')
274
+ REF_FLAG = re.compile(r"(?:^|\s)--refs?\b")
272
275
 
273
276
 
274
277
  def request(
@@ -276,6 +279,8 @@ def request(
276
279
  ) -> list[Made]:
277
280
  """A typed request: its @references (images to edit or follow), --mask, and flags (--n 4 --ar 16:9 …, over
278
281
  the session's /options), then the images."""
282
+ as_references = bool(REF_FLAG.search(text))
283
+ text = REF_FLAG.sub(" ", text)
279
284
  mask = None
280
285
  m = MASK_FLAG.search(text)
281
286
  if m:
@@ -292,8 +297,12 @@ def request(
292
297
  if agent.settings.mode == "video":
293
298
  if mask:
294
299
  raise MediaError("Video mode doesn't take a mask: @photo.png starts a video from a picture.")
295
- job = {"kind": "video", "prompt": prompt, "options": options, "sources": [str(p) for p in sources[:2]],
296
- "mask": None, "pads": None, "keep_shape": not SIZE_FLAG.search(text)} # fmt: skip
300
+ if as_references and not sources:
301
+ raise MediaError("--ref makes the @pictures references: @cat.png @hat.png --ref the cat wears the hat")
302
+ frames = [] if as_references else [str(p) for p in sources[:2]]
303
+ refs = [str(p) for p in sources] if as_references else []
304
+ job = {"kind": "video", "prompt": prompt, "options": options, "sources": frames, "mask": None, "pads": None,
305
+ "keep_shape": not SIZE_FLAG.search(text), "refs": refs} # fmt: skip
297
306
  return redo(agent, job, cancelled, ask)
298
307
  job = {"kind": "edit" if sources else "image", "prompt": prompt, "options": options,
299
308
  "sources": [str(p) for p in sources], "mask": str(mask) if mask else None, "pads": None,
@@ -492,8 +501,13 @@ def generate_video(
492
501
  start = sources[0] if sources else None
493
502
  end = sources[1] if len(sources) > 1 else None
494
503
  clip = Path(job["extend"]) if job.get("extend") else None
495
- model = video_model(agent, "first-last-frame" if end else ("camera" if options.camera else
496
- ("image-to-video" if clip else ""))) # fmt: skip
504
+ refs = [Path(p) for p in job.get("refs") or []]
505
+ restyle = Path(job["restyle"]) if job.get("restyle") else None
506
+ task = (
507
+ "restyle" if restyle else "references" if refs else "first-last-frame" if end
508
+ else "camera" if options.camera else "image-to-video" if clip else ""
509
+ ) # fmt: skip
510
+ model = video_model(agent, task)
497
511
  files = ensure_installed(agent, model, server, ask)
498
512
  workflow = comfy.load_workflow(model.workflow)
499
513
  seed = options.seed if options.seed is not None else random.randrange(2**32)
@@ -511,6 +525,14 @@ def generate_video(
511
525
  if clip is not None: # the new part continues the clip, so it has its size
512
526
  width, height = job["size"]
513
527
  fps = int(workflow.defaults.get("fps", 24))
528
+ if clip is not None: # one clip, one pace: the new part plays at the clip's fps
529
+ fps = int(clip_info(clip)["fps"] or fps)
530
+ if restyle is not None: # the restyled clip has the clip's size and pace (up to the model's length)
531
+ info = clip_info(restyle)
532
+ width, height = (info["width"] // 16 * 16 or 832), (info["height"] // 16 * 16 or 480)
533
+ fps = int(info["fps"] or fps)
534
+ options = replace(options, seconds=min(options.seconds if job.get("seconds_given") else 99,
535
+ (min(info["frames"] or 81, 81) - 1) / fps)) # fmt: skip
514
536
  text = imageopts.styled(prompt, options.style)
515
537
  values = {**workflow.defaults, **files, "prompt": text, "seed": seed, "width": width, "height": height,
516
538
  "length": imageopts.frames(options.seconds, fps), "fps": fps} # fmt: skip
@@ -535,28 +557,75 @@ def generate_video(
535
557
  graph[latent]["inputs"]["end_image"] = ["8101", 0]
536
558
  if clip is not None:
537
559
  continue_clip(graph, latent, server.upload(clip), values["length"])
560
+ vace = edits.node_of(graph, "WanVaceToVideo")
561
+ if refs and vace is not None:
562
+ graph[vace]["inputs"]["reference_image"] = reference_strip(graph, [server.upload(p) for p in refs])
563
+ if restyle is not None and vace is not None:
564
+ graph[vace]["inputs"]["control_video"] = control_from(graph, server.upload(restyle), values["length"])
538
565
  except (comfy.ComfyError, OSError) as e:
539
566
  raise MediaError(f"Couldn't hand the files to ComfyUI: {e}") from e
540
567
  add_thumbnail(graph, width, height)
541
568
  meta = describe_job(model, workflow, prompt, text, seed, values, options, files)
542
569
  meta.update({"seconds": round((values["length"] - 1) / fps, 2), "fps": fps, "frames": values["length"],
543
570
  "start_image": shown(agent, start) if start else "", "end_image": shown(agent, end) if end else "",
544
- "camera": options.camera, "extends": shown(agent, clip) if clip else ""}) # fmt: skip
545
- remembered = {k: job.get(k) for k in ("kind", "prompt", "sources", "mask", "pads", "keep_shape", "extend", "size")}
546
- stem = f"{clip.stem}-extended" if clip else ""
571
+ "camera": options.camera, "extends": shown(agent, clip) if clip else "",
572
+ "references": [shown(agent, p) for p in refs],
573
+ "restyles": shown(agent, restyle) if restyle else ""}) # fmt: skip
574
+ keys = ("kind", "prompt", "sources", "mask", "pads", "keep_shape", "extend", "size", "refs", "restyle")
575
+ remembered = {k: job.get(k) for k in keys}
576
+ stem = f"{clip.stem}-extended" if clip else (f"{restyle.stem}-restyled" if restyle else "")
547
577
  plan = Plan(model, workflow, graph, meta, prompt, seed, options, "video", job.get("sources") or [], remembered,
548
578
  stem) # fmt: skip
549
579
  return run_plan(agent, server, plan, cancelled, label)
550
580
 
551
581
 
552
- VIDEO_LATENTS = ("Wan22ImageToVideoLatent", "WanFunInpaintToVideo", "WanCameraImageToVideo")
582
+ VIDEO_LATENTS = ("Wan22ImageToVideoLatent", "WanFunInpaintToVideo", "WanCameraImageToVideo", "WanVaceToVideo")
553
583
  WHY = {
554
584
  "first-last-frame": "a clip between two frames",
555
585
  "camera": "a camera move",
556
586
  "image-to-video": "continuing a clip",
587
+ "references": "following reference pictures",
588
+ "restyle": "restyling a clip",
557
589
  }
558
590
 
559
591
 
592
+ def reference_strip(graph: dict, names: list[str]) -> list:
593
+ """The reference pictures side by side in one image, as VACE takes them."""
594
+ graph["8300"] = {"class_type": "LoadImage", "inputs": {"image": names[0]}}
595
+ strip = ["8300", 0]
596
+ for k, name in enumerate(names[1:], 1):
597
+ load, stitch = str(8300 + 2 * k - 1), str(8300 + 2 * k)
598
+ graph[load] = {"class_type": "LoadImage", "inputs": {"image": name}}
599
+ graph[stitch] = {
600
+ "class_type": "ImageStitch",
601
+ "inputs": {"image1": strip, "direction": "right", "match_image_size": True, "spacing_width": 0,
602
+ "spacing_color": "white", "image2": [load, 0]},
603
+ } # fmt: skip
604
+ strip = [stitch, 0]
605
+ return strip
606
+
607
+
608
+ def control_from(graph: dict, clip_name: str, length: int) -> list:
609
+ """Restyling: the clip's outlines (Canny edges), frame by frame, for VACE to follow."""
610
+ graph["8400"] = {"class_type": "LoadVideo", "inputs": {"file": clip_name}}
611
+ graph["8401"] = {"class_type": "GetVideoComponents", "inputs": {"video": ["8400", 0]}}
612
+ graph["8402"] = {
613
+ "class_type": "ImageFromBatch",
614
+ "inputs": {"image": ["8401", 0], "batch_index": 0, "length": length},
615
+ }
616
+ latent = edits.node_of(graph, "WanVaceToVideo")
617
+ w, h = graph[latent]["inputs"]["width"], graph[latent]["inputs"]["height"]
618
+ graph["8403"] = {
619
+ "class_type": "ImageScale",
620
+ "inputs": {"image": ["8402", 0], "upscale_method": "bilinear", "width": w, "height": h, "crop": "center"},
621
+ }
622
+ graph["8404"] = {
623
+ "class_type": "Canny",
624
+ "inputs": {"image": ["8403", 0], "low_threshold": 0.3, "high_threshold": 0.6},
625
+ }
626
+ return ["8404", 0]
627
+
628
+
560
629
  def video_model(agent: Agent, task: str) -> catalog.MediaModel:
561
630
  """The video model for a job: the chosen one, or the first that does what the job needs."""
562
631
  chosen = current(agent, "video")
@@ -582,6 +651,46 @@ def continue_clip(graph: dict, latent: str, clip_name: str, length: int) -> None
582
651
  graph[video]["inputs"]["images"] = ["8204", 0]
583
652
 
584
653
 
654
+ VIDEO_TYPES = (".mp4", ".webm", ".mkv", ".mov")
655
+ TOOL_NAMES = {"upscale": "upscaled", "remove-background": "nobg", "interpolate": "smooth", "sound": "sound"}
656
+
657
+
658
+ def is_video(path: Path) -> bool:
659
+ return path.suffix.lower() in VIDEO_TYPES
660
+
661
+
662
+ def clip_info(path: Path) -> dict:
663
+ """A clip's fps, seconds, frames, width and height: from lcode's JSON next to it, else its MP4 header."""
664
+ info = {"fps": 24.0, "seconds": 0.0, "frames": 0, "width": 0, "height": 0}
665
+ try:
666
+ meta = json.loads(path.with_suffix(".json").read_text())
667
+ info.update({k: meta[k] for k in info if isinstance(meta.get(k), (int, float))})
668
+ except (OSError, ValueError):
669
+ pass
670
+ if not info["seconds"]:
671
+ info["seconds"] = mp4_seconds(path)
672
+ if not info["frames"] and info["seconds"]:
673
+ info["frames"] = round(info["seconds"] * info["fps"]) + 1
674
+ return info
675
+
676
+
677
+ def mp4_seconds(path: Path) -> float:
678
+ """An MP4's length from its movie header (mvhd), or 0."""
679
+ try:
680
+ data = path.read_bytes()
681
+ except OSError:
682
+ return 0.0
683
+ i = data.find(b"mvhd")
684
+ if i < 4:
685
+ return 0.0
686
+ version = data[i + 4]
687
+ if version == 1:
688
+ scale, duration = struct.unpack(">IQ", data[i + 24 : i + 36])
689
+ else:
690
+ scale, duration = struct.unpack(">II", data[i + 16 : i + 24])
691
+ return duration / scale if scale else 0.0
692
+
693
+
585
694
  def apply_tool(
586
695
  agent: Agent,
587
696
  task: str,
@@ -589,27 +698,52 @@ def apply_tool(
589
698
  scale: int = 2,
590
699
  cancelled: Callable[[], bool] = lambda: False,
591
700
  ask: Callable[[str], bool] | None = None,
701
+ prompt: str = "",
592
702
  ) -> Made:
593
- """/upscale and /nobg: a tool model on one image (no seed, no prompt)."""
703
+ """A tool model on one image or clip: /upscale (both), /nobg (pictures), /smooth and /sound (clips)."""
704
+ video = is_video(source)
705
+ if task == "remove-background" and video:
706
+ raise MediaError("/nobg works on pictures.")
707
+ if task in ("interpolate", "sound") and not video:
708
+ raise MediaError(f"/{'smooth' if task == 'interpolate' else 'sound'} works on clips.")
709
+ if task == "sound" and not prompt.strip():
710
+ raise MediaError("Say what it should sound like: /sound 4 waves and seagulls")
594
711
  server = prepare(agent, ask, cancelled)
595
712
  model = catalog.load().tool(task)
596
713
  files = ensure_installed(agent, model, server, ask)
597
- workflow = comfy.load_workflow(model.workflow)
714
+ workflow = comfy.load_workflow(model.video_workflow if video and model.video_workflow else model.workflow)
598
715
  try:
599
716
  name = server.upload(source)
600
- width, height = edits.image_size(source)
717
+ if video:
718
+ info = clip_info(source)
719
+ width, height = info["width"] or 864, info["height"] or 480
720
+ else:
721
+ width, height = edits.image_size(source)
601
722
  except (comfy.ComfyError, OSError, edits.EditError) as e:
602
- raise MediaError(f"Couldn't hand the image to ComfyUI: {e}") from e
603
- values = {**workflow.defaults, **files, "image": name}
723
+ raise MediaError(f"Couldn't hand the file to ComfyUI: {e}") from e
724
+ values = {**workflow.defaults, **files, ("video" if video else "image"): name}
725
+ seed = 0
726
+ if video:
727
+ values["fps"] = info["fps"]
604
728
  if task == "upscale":
605
729
  values["scale_by"] = scale / 4 # Real-ESRGAN makes 4 times the size; scaled back for 2
606
730
  width, height = width * scale, height * scale
731
+ elif task == "interpolate":
732
+ values["multiplier"], values["fps"] = scale, info["fps"] * scale
733
+ elif task == "sound":
734
+ seed = random.randrange(2**32)
735
+ values.update({"prompt": prompt.strip(), "seed": seed, "seconds": max(1.0, info["seconds"])})
607
736
  graph = comfy.fill(workflow.graph, values)
608
737
  add_thumbnail(graph, width, height)
609
- what = f"upscaled {scale}×" if task == "upscale" else "background removed"
610
- prompt = f"{what}: {shown(agent, source)}"
738
+ what = {
739
+ "upscale": f"upscaled {scale}×",
740
+ "remove-background": "background removed",
741
+ "interpolate": f"{scale}× the frames",
742
+ "sound": f"sound: {prompt.strip()}",
743
+ }[task]
744
+ label = f"{what} ({shown(agent, source)})"
611
745
  meta = {
612
- "prompt": prompt,
746
+ "prompt": label,
613
747
  "model": model.name,
614
748
  "model_key": model.key,
615
749
  "workflow": workflow.key,
@@ -617,8 +751,10 @@ def apply_tool(
617
751
  "files": files,
618
752
  "created": time.strftime("%Y-%m-%dT%H:%M:%S%z"),
619
753
  }
620
- suffix = f"upscaled-{scale}x" if task == "upscale" else "nobg"
621
- plan = Plan(model, workflow, graph, meta, prompt, 0, imageopts.Options(), task, [str(source)], {},
754
+ if video:
755
+ meta.update({"fps": values["fps"], "seconds": info["seconds"], "width": width, "height": height})
756
+ suffix = {"upscale": f"upscaled-{scale}x", "interpolate": f"smooth-{scale}x"}.get(task, TOOL_NAMES[task])
757
+ plan = Plan(model, workflow, graph, meta, label, seed, imageopts.Options(), task, [str(source)], {},
622
758
  f"{source.stem}-{suffix}") # fmt: skip
623
759
  return run_plan(agent, server, plan, cancelled, "")
624
760
 
lcode/media.toml CHANGED
@@ -101,6 +101,7 @@ publisher = "Xintao Wang et al."
101
101
  license = "BSD-3-Clause"
102
102
  tasks = ["upscale"]
103
103
  workflow = "upscale-esrgan"
104
+ video_workflow = "upscale-video-esrgan"
104
105
  files = { model = "realesrgan-x4" }
105
106
  notes = "/upscale: 2× or 4× the pixels"
106
107
 
@@ -196,3 +197,60 @@ measured = "3 s clip (49 frames, 832×480): 115 s on an RTX 4080 Laptop, 12 GB"
196
197
  notes = "camera moves (--camera pan-left, zoom-in, …), small and fast, 16 fps"
197
198
  quality = { fast = [12, 0.38], balanced = [20, 0.38], best = [30, 0.38] }
198
199
  negative = true
200
+
201
+ [files.wan21-vace-1-3b]
202
+ folder = "diffusion_models"
203
+ name = "wan2.1_vace_1.3B_fp16.safetensors"
204
+ url = "https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/diffusion_models/wan2.1_vace_1.3B_fp16.safetensors"
205
+ gb = 4.31
206
+
207
+ [files.film-net]
208
+ folder = "frame_interpolation"
209
+ name = "film_net_fp16.safetensors"
210
+ url = "https://huggingface.co/Comfy-Org/frame_interpolation/resolve/main/frame_interpolation/film_net_fp16.safetensors"
211
+ gb = 0.07
212
+
213
+ [files.stable-audio-open]
214
+ folder = "checkpoints"
215
+ name = "stable-audio-open-1.0.safetensors"
216
+ url = "https://huggingface.co/Comfy-Org/stable-audio-open-1.0_repackaged/resolve/main/stable-audio-open-1.0.safetensors"
217
+ gb = 4.85
218
+
219
+ [files.t5-base]
220
+ folder = "text_encoders"
221
+ name = "t5-base.safetensors"
222
+ url = "https://huggingface.co/ComfyUI-Wiki/t5-base/resolve/main/t5-base.safetensors"
223
+ gb = 0.89
224
+
225
+ [models.wan21-vace-1-3b]
226
+ name = "Wan 2.1 VACE 1.3B"
227
+ mode = "video"
228
+ publisher = "Alibaba (Wan-AI)"
229
+ license = "Apache 2.0"
230
+ tasks = ["references", "restyle"]
231
+ workflow = "wan21-vace"
232
+ files = { model = "wan21-vace-1-3b", text_encoder = "umt5-xxl-fp8", vae = "wan21-vae" }
233
+ measured = "3 s clip from references (832×480): 190 s; restyling 3 s: 320 s, on an RTX 4080 Laptop, 12 GB"
234
+ notes = "clips that follow reference pictures (--ref), or restyle a clip (/restyle)"
235
+ quality = { fast = [12, 0.38], balanced = [20, 0.38], best = [30, 0.38] }
236
+ negative = true
237
+
238
+ [models.film]
239
+ name = "FILM"
240
+ mode = "tool"
241
+ publisher = "Google Research"
242
+ license = "Apache 2.0"
243
+ tasks = ["interpolate"]
244
+ workflow = "smooth-film"
245
+ files = { model = "film-net" }
246
+ notes = "/smooth: twice the frames per second"
247
+
248
+ [models.stable-audio-open]
249
+ name = "Stable Audio Open 1.0"
250
+ mode = "tool"
251
+ publisher = "Stability AI"
252
+ license = "Stability AI Community License"
253
+ tasks = ["sound"]
254
+ workflow = "sound-stable-audio"
255
+ files = { model = "stable-audio-open", text_encoder = "t5-base" }
256
+ notes = "/sound: sound effects and ambience for a clip, up to 47 s"
lcode/media_catalog.py CHANGED
@@ -71,6 +71,7 @@ class MediaModel:
71
71
  quality: dict[str, tuple[int, float]] = field(default_factory=dict, hash=False) # preset -> (steps, megapixels)
72
72
  negative: bool = False # whether it uses a negative prompt
73
73
  edit: str = "" # how it edits images ("reference-latent"), or empty: it doesn't
74
+ video_workflow: str = "" # a tool's workflow for clips, when it works on them too (upscaling)
74
75
 
75
76
  def preset(self, quality: str) -> tuple[int | None, float]:
76
77
  """(steps, megapixels) for a quality preset: None steps keeps the workflow's."""
@@ -163,6 +164,7 @@ def load() -> Catalog:
163
164
  {name: (int(v[0]), float(v[1])) for name, v in (m.get("quality") or {}).items()},
164
165
  bool(m.get("negative", False)),
165
166
  m.get("edit", ""),
167
+ m.get("video_workflow", ""),
166
168
  )
167
169
  return Catalog(files, models)
168
170
 
lcode/repl.py CHANGED
@@ -87,9 +87,12 @@ COMMANDS = {
87
87
  "/edit": "Image mode: change an image by instruction, e.g. /edit 3 make the sky purple (@photo.png: references)",
88
88
  "/use": "Image mode: images the next requests follow, e.g. /use 3 or /use photo.png (/use off)",
89
89
  "/extend": "Outpaint an image (/extend 3 --ar 16:9), or continue a clip in video mode (/extend 4 --seconds 3)",
90
- "/upscale": "Image mode: 2 or 4 times the pixels, e.g. /upscale 3 4",
90
+ "/upscale": "2 or 4 times the pixels of an image or a clip, e.g. /upscale 3 4",
91
91
  "/nobg": "Image mode: remove the background (a transparent PNG), e.g. /nobg 3",
92
92
  "/animate": "Image mode: make a video starting from an image, e.g. /animate 3 the waves roll in (video mode)",
93
+ "/smooth": "Video mode: 2 or 4 times the frames (smoother motion), e.g. /smooth 4",
94
+ "/sound": "Video mode: add sound to a clip, e.g. /sound 4 waves and seagulls",
95
+ "/restyle": "Video mode: the same clip in a new look, e.g. /restyle 4 as a watercolor painting",
93
96
  "/play": "Play a video in your player, e.g. /play 4 (default: the last)",
94
97
  "/cd": "Change the working directory",
95
98
  "/todos": "Show the current todo list",
@@ -1404,9 +1407,12 @@ def respond(agent: Agent, line: str) -> None:
1404
1407
 
1405
1408
  IMAGE_COMMANDS = (
1406
1409
  "/options", "/again", "/vary", "/gallery", "/open", "/play", "/edit", "/use", "/extend", "/upscale", "/nobg",
1407
- "/animate",
1410
+ "/animate", "/smooth", "/sound", "/restyle",
1408
1411
  ) # fmt: skip
1409
- VIDEO_TOO = ("/options", "/again", "/vary", "/gallery", "/open", "/play", "/use", "/extend") # video mode has these
1412
+ VIDEO_TOO = (
1413
+ "/options", "/again", "/vary", "/gallery", "/open", "/play", "/use", "/extend", "/upscale", "/smooth", "/sound",
1414
+ "/restyle",
1415
+ ) # what video mode has # fmt: skip
1410
1416
  NUMBER = re.compile(r"^#?(\d+)$")
1411
1417
 
1412
1418
 
@@ -1464,7 +1470,8 @@ def image_command(agent: Agent, cmd: str, arg: str) -> None:
1464
1470
  return
1465
1471
  if cmd == "/vary":
1466
1472
  job = dict(entry.get("job") or {"kind": "image", "sources": [], "mask": None, "pads": None})
1467
- if entry.get("kind") in ("upscale", "remove-background") or job["kind"] not in ("image", "edit", "video"):
1473
+ tools = ("upscale", "remove-background", "interpolate", "sound")
1474
+ if entry.get("kind") in tools or job["kind"] not in ("image", "edit", "video"):
1468
1475
  c.print(f"[yellow]#{entry['n']} is {escape(entry['prompt'])}: /vary the image it came from.[/]")
1469
1476
  return
1470
1477
  job["prompt"] = entry["prompt"] if job["kind"] == "image" else job.get("prompt", entry["prompt"])
@@ -1525,6 +1532,30 @@ def image_command(agent: Agent, cmd: str, arg: str) -> None:
1525
1532
  agent, run=lambda cancel, ask: media.apply_tool(agent, "upscale", source, int(scale), cancel, ask)
1526
1533
  )
1527
1534
  return
1535
+ if cmd == "/smooth":
1536
+ times = int(rest.strip().lower().rstrip("x×") or "2")
1537
+ if times not in (2, 4):
1538
+ c.print("[yellow]/smooth makes 2 or 4 times the frames: /smooth 4 2[/]")
1539
+ return
1540
+ make_image(
1541
+ agent, run=lambda cancel, ask: media.apply_tool(agent, "interpolate", source, times, cancel, ask)
1542
+ )
1543
+ return
1544
+ if cmd == "/sound":
1545
+ make_image(agent, run=lambda cancel, ask: media.apply_tool(agent, "sound", source, 1, cancel, ask, rest))
1546
+ return
1547
+ if cmd == "/restyle":
1548
+ if not media.is_video(source):
1549
+ c.print("[yellow]/restyle works on clips: /restyle 4 as a watercolor painting.[/]")
1550
+ return
1551
+ text, options = imageopts.parse(rest, imageopts.replace_seed(agent.image_options, n=1))
1552
+ if not text:
1553
+ c.print("[yellow]Say the new look: /restyle 4 as a watercolor painting[/]")
1554
+ return
1555
+ job = {"kind": "video", "prompt": text, "options": options, "sources": [], "mask": None, "pads": None,
1556
+ "keep_shape": True, "restyle": str(source), "seconds_given": "--seconds" in rest} # fmt: skip
1557
+ make_image(agent, run=lambda cancel, ask: media.redo(agent, job, cancel, ask))
1558
+ return
1528
1559
  if cmd == "/nobg":
1529
1560
  make_image(
1530
1561
  agent, run=lambda cancel, ask: media.apply_tool(agent, "remove-background", source, 2, cancel, ask)
@@ -0,0 +1,78 @@
1
+ {
2
+ "source": "ComfyUI's template utility_video_frame_interpolation, in API format",
3
+ "defaults": {
4
+ "multiplier": 2,
5
+ "fps": 48
6
+ },
7
+ "labels": {
8
+ "1": "loading the clip",
9
+ "2": "reading its frames",
10
+ "3": "loading FILM",
11
+ "4": "making the in-between frames",
12
+ "5": "making the video",
13
+ "6": "saving"
14
+ },
15
+ "graph": {
16
+ "1": {
17
+ "class_type": "LoadVideo",
18
+ "inputs": {
19
+ "file": "$video"
20
+ }
21
+ },
22
+ "2": {
23
+ "class_type": "GetVideoComponents",
24
+ "inputs": {
25
+ "video": [
26
+ "1",
27
+ 0
28
+ ]
29
+ }
30
+ },
31
+ "3": {
32
+ "class_type": "FrameInterpolationModelLoader",
33
+ "inputs": {
34
+ "model_name": "$model"
35
+ }
36
+ },
37
+ "4": {
38
+ "class_type": "FrameInterpolate",
39
+ "inputs": {
40
+ "interp_model": [
41
+ "3",
42
+ 0
43
+ ],
44
+ "images": [
45
+ "2",
46
+ 0
47
+ ],
48
+ "multiplier": "$multiplier"
49
+ }
50
+ },
51
+ "5": {
52
+ "class_type": "CreateVideo",
53
+ "inputs": {
54
+ "images": [
55
+ "4",
56
+ 0
57
+ ],
58
+ "audio": [
59
+ "2",
60
+ 1
61
+ ],
62
+ "fps": "$fps"
63
+ }
64
+ },
65
+ "6": {
66
+ "class_type": "SaveVideo",
67
+ "inputs": {
68
+ "video": [
69
+ "5",
70
+ 0
71
+ ],
72
+ "filename_prefix": "lcode/video",
73
+ "format": "mp4",
74
+ "codec": "auto"
75
+ }
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,144 @@
1
+ {
2
+ "source": "ComfyUI's template audio_stable_audio_example, in API format, with the sound put on the clip",
3
+ "defaults": {
4
+ "seconds": 5.0,
5
+ "fps": 24,
6
+ "steps": 50,
7
+ "negative": ""
8
+ },
9
+ "labels": {
10
+ "1": "loading the clip",
11
+ "2": "reading its frames",
12
+ "3": "loading Stable Audio",
13
+ "4": "loading the text encoder",
14
+ "5": "reading the prompt",
15
+ "8": "making the sound",
16
+ "9": "decoding the sound",
17
+ "10": "putting it on the clip",
18
+ "11": "saving"
19
+ },
20
+ "graph": {
21
+ "1": {
22
+ "class_type": "LoadVideo",
23
+ "inputs": {
24
+ "file": "$video"
25
+ }
26
+ },
27
+ "2": {
28
+ "class_type": "GetVideoComponents",
29
+ "inputs": {
30
+ "video": [
31
+ "1",
32
+ 0
33
+ ]
34
+ }
35
+ },
36
+ "3": {
37
+ "class_type": "CheckpointLoaderSimple",
38
+ "inputs": {
39
+ "ckpt_name": "$model"
40
+ }
41
+ },
42
+ "4": {
43
+ "class_type": "CLIPLoader",
44
+ "inputs": {
45
+ "clip_name": "$text_encoder",
46
+ "type": "stable_audio",
47
+ "device": "default"
48
+ }
49
+ },
50
+ "5": {
51
+ "class_type": "CLIPTextEncode",
52
+ "inputs": {
53
+ "text": "$prompt",
54
+ "clip": [
55
+ "4",
56
+ 0
57
+ ]
58
+ }
59
+ },
60
+ "6": {
61
+ "class_type": "CLIPTextEncode",
62
+ "inputs": {
63
+ "text": "$negative",
64
+ "clip": [
65
+ "4",
66
+ 0
67
+ ]
68
+ }
69
+ },
70
+ "7": {
71
+ "class_type": "EmptyLatentAudio",
72
+ "inputs": {
73
+ "seconds": "$seconds",
74
+ "batch_size": 1
75
+ }
76
+ },
77
+ "8": {
78
+ "class_type": "KSampler",
79
+ "inputs": {
80
+ "model": [
81
+ "3",
82
+ 0
83
+ ],
84
+ "seed": "$seed",
85
+ "steps": "$steps",
86
+ "cfg": 4.98,
87
+ "sampler_name": "dpmpp_3m_sde_gpu",
88
+ "scheduler": "exponential",
89
+ "positive": [
90
+ "5",
91
+ 0
92
+ ],
93
+ "negative": [
94
+ "6",
95
+ 0
96
+ ],
97
+ "latent_image": [
98
+ "7",
99
+ 0
100
+ ],
101
+ "denoise": 1
102
+ }
103
+ },
104
+ "9": {
105
+ "class_type": "VAEDecodeAudio",
106
+ "inputs": {
107
+ "samples": [
108
+ "8",
109
+ 0
110
+ ],
111
+ "vae": [
112
+ "3",
113
+ 2
114
+ ]
115
+ }
116
+ },
117
+ "10": {
118
+ "class_type": "CreateVideo",
119
+ "inputs": {
120
+ "images": [
121
+ "2",
122
+ 0
123
+ ],
124
+ "audio": [
125
+ "9",
126
+ 0
127
+ ],
128
+ "fps": "$fps"
129
+ }
130
+ },
131
+ "11": {
132
+ "class_type": "SaveVideo",
133
+ "inputs": {
134
+ "video": [
135
+ "10",
136
+ 0
137
+ ],
138
+ "filename_prefix": "lcode/video",
139
+ "format": "mp4",
140
+ "codec": "auto"
141
+ }
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "source": "ComfyUI's template utility-gan_upscaler, in API format",
3
+ "defaults": {
4
+ "scale_by": 0.5,
5
+ "fps": 24
6
+ },
7
+ "labels": {
8
+ "1": "loading the clip",
9
+ "2": "reading its frames",
10
+ "3": "loading the upscaler",
11
+ "4": "upscaling the frames",
12
+ "5": "resizing",
13
+ "6": "making the video",
14
+ "7": "saving"
15
+ },
16
+ "graph": {
17
+ "1": {
18
+ "class_type": "LoadVideo",
19
+ "inputs": {
20
+ "file": "$video"
21
+ }
22
+ },
23
+ "2": {
24
+ "class_type": "GetVideoComponents",
25
+ "inputs": {
26
+ "video": [
27
+ "1",
28
+ 0
29
+ ]
30
+ }
31
+ },
32
+ "3": {
33
+ "class_type": "UpscaleModelLoader",
34
+ "inputs": {
35
+ "model_name": "$model"
36
+ }
37
+ },
38
+ "4": {
39
+ "class_type": "ImageUpscaleWithModel",
40
+ "inputs": {
41
+ "upscale_model": [
42
+ "3",
43
+ 0
44
+ ],
45
+ "image": [
46
+ "2",
47
+ 0
48
+ ]
49
+ }
50
+ },
51
+ "5": {
52
+ "class_type": "ImageScaleBy",
53
+ "inputs": {
54
+ "image": [
55
+ "4",
56
+ 0
57
+ ],
58
+ "upscale_method": "lanczos",
59
+ "scale_by": "$scale_by"
60
+ }
61
+ },
62
+ "6": {
63
+ "class_type": "CreateVideo",
64
+ "inputs": {
65
+ "images": [
66
+ "5",
67
+ 0
68
+ ],
69
+ "audio": [
70
+ "2",
71
+ 1
72
+ ],
73
+ "fps": "$fps"
74
+ }
75
+ },
76
+ "7": {
77
+ "class_type": "SaveVideo",
78
+ "inputs": {
79
+ "video": [
80
+ "6",
81
+ 0
82
+ ],
83
+ "filename_prefix": "lcode/video",
84
+ "format": "mp4",
85
+ "codec": "auto"
86
+ }
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,173 @@
1
+ {
2
+ "source": "ComfyUI's template video_wan_vace_14B_ref2v (the 1.3B model, without the CausVid LoRA), in API format; lcode adds the reference picture or the control video",
3
+ "defaults": {
4
+ "width": 832,
5
+ "height": 480,
6
+ "length": 81,
7
+ "fps": 16,
8
+ "steps": 20,
9
+ "negative": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
10
+ },
11
+ "labels": {
12
+ "1": "loading the model",
13
+ "2": "loading the text encoder",
14
+ "3": "loading the VAE",
15
+ "5": "reading the prompt",
16
+ "6": "reading the prompt",
17
+ "7": "reading the references",
18
+ "8": "drawing the frames",
19
+ "10": "decoding the frames",
20
+ "11": "making the video",
21
+ "12": "saving"
22
+ },
23
+ "graph": {
24
+ "1": {
25
+ "class_type": "UNETLoader",
26
+ "inputs": {
27
+ "unet_name": "$model",
28
+ "weight_dtype": "default"
29
+ }
30
+ },
31
+ "2": {
32
+ "class_type": "CLIPLoader",
33
+ "inputs": {
34
+ "clip_name": "$text_encoder",
35
+ "type": "wan",
36
+ "device": "default"
37
+ }
38
+ },
39
+ "3": {
40
+ "class_type": "VAELoader",
41
+ "inputs": {
42
+ "vae_name": "$vae"
43
+ }
44
+ },
45
+ "4": {
46
+ "class_type": "ModelSamplingSD3",
47
+ "inputs": {
48
+ "model": [
49
+ "1",
50
+ 0
51
+ ],
52
+ "shift": 8
53
+ }
54
+ },
55
+ "5": {
56
+ "class_type": "CLIPTextEncode",
57
+ "inputs": {
58
+ "text": "$prompt",
59
+ "clip": [
60
+ "2",
61
+ 0
62
+ ]
63
+ }
64
+ },
65
+ "6": {
66
+ "class_type": "CLIPTextEncode",
67
+ "inputs": {
68
+ "text": "$negative",
69
+ "clip": [
70
+ "2",
71
+ 0
72
+ ]
73
+ }
74
+ },
75
+ "7": {
76
+ "class_type": "WanVaceToVideo",
77
+ "inputs": {
78
+ "positive": [
79
+ "5",
80
+ 0
81
+ ],
82
+ "negative": [
83
+ "6",
84
+ 0
85
+ ],
86
+ "vae": [
87
+ "3",
88
+ 0
89
+ ],
90
+ "width": "$width",
91
+ "height": "$height",
92
+ "length": "$length",
93
+ "batch_size": 1,
94
+ "strength": 1.0
95
+ }
96
+ },
97
+ "8": {
98
+ "class_type": "KSampler",
99
+ "inputs": {
100
+ "model": [
101
+ "4",
102
+ 0
103
+ ],
104
+ "seed": "$seed",
105
+ "steps": "$steps",
106
+ "cfg": 5,
107
+ "sampler_name": "uni_pc",
108
+ "scheduler": "simple",
109
+ "positive": [
110
+ "7",
111
+ 0
112
+ ],
113
+ "negative": [
114
+ "7",
115
+ 1
116
+ ],
117
+ "latent_image": [
118
+ "7",
119
+ 2
120
+ ],
121
+ "denoise": 1
122
+ }
123
+ },
124
+ "9": {
125
+ "class_type": "TrimVideoLatent",
126
+ "inputs": {
127
+ "samples": [
128
+ "8",
129
+ 0
130
+ ],
131
+ "trim_amount": [
132
+ "7",
133
+ 3
134
+ ]
135
+ }
136
+ },
137
+ "10": {
138
+ "class_type": "VAEDecode",
139
+ "inputs": {
140
+ "samples": [
141
+ "9",
142
+ 0
143
+ ],
144
+ "vae": [
145
+ "3",
146
+ 0
147
+ ]
148
+ }
149
+ },
150
+ "11": {
151
+ "class_type": "CreateVideo",
152
+ "inputs": {
153
+ "images": [
154
+ "10",
155
+ 0
156
+ ],
157
+ "fps": "$fps"
158
+ }
159
+ },
160
+ "12": {
161
+ "class_type": "SaveVideo",
162
+ "inputs": {
163
+ "video": [
164
+ "11",
165
+ 0
166
+ ],
167
+ "filename_prefix": "lcode/video",
168
+ "format": "mp4",
169
+ "codec": "auto"
170
+ }
171
+ }
172
+ }
173
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lcode-cli
3
- Version: 0.45.0
3
+ Version: 0.46.0
4
4
  Summary: A local-first terminal coding agent powered by open-weight models on your own GPU or Mac, via Ollama.
5
5
  Project-URL: Homepage, https://nasser1941.github.io/lcode/
6
6
  Project-URL: Documentation, https://nasser1941.github.io/lcode/
@@ -1,4 +1,4 @@
1
- lcode/__init__.py,sha256=L3biyHRfnXUkps8h8FkUi2zcpeYOxPdd5vXFMys3I_o,473
1
+ lcode/__init__.py,sha256=YuQJQmSdMYPXBSlWminIH15TJi78jdN8J0ga1xWj2Qc,473
2
2
  lcode/__main__.py,sha256=s5N5pryX2FAu93GGZ3FxUrIXHWGzxz66lKUoaV_h8Ws,35
3
3
  lcode/acp.py,sha256=d97VV3sbqXdWKhPQQNbYRaDTm8WrUk0mGbDLiOyX7jE,29058
4
4
  lcode/action.py,sha256=wuT5F9EJCdEligPeytzmEi8FpahWBhXer528tpuTj_k,16711
@@ -30,9 +30,9 @@ lcode/jobs.py,sha256=P1P3FqI6EqL4LgdMX9YGZwCW0Bh5BRXFA_FnQxpHNjE,5618
30
30
  lcode/limits.py,sha256=oJzVQoMyTZ0_Fkpu5t3qxrf9v7Hv9S8U8BRQR5M1aKA,1237
31
31
  lcode/lsp.py,sha256=NtSW7xapv7fg2HAQLuYK1nwIqT7nG0LK1hiTpOmla_4,26086
32
32
  lcode/matching.py,sha256=2N3_qwKJ5gd8el2m_y_egKkFM9rsF1eUhYJcRCVIp98,14015
33
- lcode/media.py,sha256=7Sq4fKRLNGMJekZp9mrRnyMJHfTjBE2Z13DaTM0v5aA,36618
34
- lcode/media.toml,sha256=Tbw9EsKk0vepKsVBS5OorzPHYEsib--UjRk7aRbh00o,8027
35
- lcode/media_catalog.py,sha256=kvEm3x48GdP2jH1XciZlWyXxxsAGjT6jt6heDcgYUtY,14614
33
+ lcode/media.py,sha256=bPJNKQrusg2z0kUHeZliGsCmgyzcBPjQXqaTxw-m9jc,42927
34
+ lcode/media.toml,sha256=fzBbk4NigNzZnBzRkuQxFLtdVmuXPHM0KkxknOUxaKA,10022
35
+ lcode/media_catalog.py,sha256=nYgJtgWmVwtgV_rBA2rWC21HBM9yYL70DrTkkRrhqDg,14754
36
36
  lcode/memory.py,sha256=WZEHTp-lVxAwS-yyLQR2xB3TMZ9sejmX2Ivg7T-tl3w,21949
37
37
  lcode/models.toml,sha256=lt2G64zzo_Ryxv2ISRSNZoVD_JqCqYqsM01n8WoXGs8,4098
38
38
  lcode/modes.py,sha256=MG2OuwGxzbPxzP5ax_pdPPxMsjEd5Lv4kCQbCoFKaNo,5095
@@ -43,7 +43,7 @@ lcode/planning.py,sha256=Q2upaoZPnXDMQT2F-ETxX1lk_wDntTzhSKNVYIQSoQA,6540
43
43
  lcode/preview.py,sha256=ATzEs6yaI1__bfo2_juWznrTDXUD4QTc_aQMPRCytgA,6253
44
44
  lcode/render.py,sha256=gMvf4W3qkLUJ4Vot3az_hP_zRDAItJC9pP-68dHFkfA,1375
45
45
  lcode/repeats.py,sha256=OTrPdb6BKArDLQEgHaXmJZ-tIFsY_1bk4P0wzzANKLY,5964
46
- lcode/repl.py,sha256=qOKk1zMCmwmOPayhbIcnXZPiBMZJzJI-c4NeR1bFwPY,73952
46
+ lcode/repl.py,sha256=Pus8vCPX16RoHYGci2T6TCIs3PiV-mBEI7-tqFOblUI,75740
47
47
  lcode/repomap.py,sha256=1GRJgEUjBl9XHSXsF7tSGXBCEgsY-3CzwMohaTudZ_M,13969
48
48
  lcode/residency.py,sha256=B9pwqG6yx5aQD2M5xyQ-bMnYmhD7fv3wCVw_X6VIeAo,7012
49
49
  lcode/review.py,sha256=0QBIS-R1B2b3zqx5TcC1qZptpKBbrDhYvMKSNCaDAUo,4686
@@ -77,13 +77,17 @@ lcode/servers/xai.py,sha256=h2emAvHSnkuB9WmJInlynsDhvxJwNVD2AHFX7vqMXNc,13627
77
77
  lcode/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
78
  lcode/workflows/flux2-klein-4b-t2i.json,sha256=yGrYDT8pG2bns9DS1JavhlX5fwhDgIKfAwrHrRCyE8k,1788
79
79
  lcode/workflows/remove-background.json,sha256=iMNaXqlkcWN-mCQWezD3NUbW94cHN3JcPYsSUsfOl64,794
80
+ lcode/workflows/smooth-film.json,sha256=5827JzOl46Y2gyPv5MbiHSgZlzUEPaKOq8fUuwCD-rc,1406
81
+ lcode/workflows/sound-stable-audio.json,sha256=H1mA0h5WaC8CwehsaUYpJOBo4k3k5ug76DLqXdJ1CUI,2654
80
82
  lcode/workflows/upscale-esrgan.json,sha256=quDmTnncvycggskgvw6zvfNsub7mS0WY3a4J99fWeXc,745
83
+ lcode/workflows/upscale-video-esrgan.json,sha256=e5cU0Rna4udxCZJfW1CzkmJXRJWq_lBHFBpFt5oaJ48,1577
81
84
  lcode/workflows/wan21-fun-camera.json,sha256=raXnj6-Y7gyJlOcxFRVSbMPihQA096nHkmyCq5xcASg,3898
85
+ lcode/workflows/wan21-vace.json,sha256=vJsiRvLCXCjKIibOO0SGM3fT6bedAGxF8N2sN2vcPDk,3597
82
86
  lcode/workflows/wan22-fun-inp-5b.json,sha256=4HbKEezik8MHvxTMP6PjQUPQPfCeSu10U9FrC-DHKYw,3327
83
87
  lcode/workflows/wan22-ti2v-5b.json,sha256=RcTehoC2pNizzlb7Ed3keJ56DiE7V5lhXmsvR2Y0smQ,3371
84
88
  lcode/workflows/z-image-turbo-t2i.json,sha256=sHsL7xnnuULOuWGYlQrDl4jOTySdAmb2T82c_cChv0s,1585
85
- lcode_cli-0.45.0.dist-info/METADATA,sha256=9tGfBLjjwTn6hcRdnFeCmqQRdwutAUzc5uKz8cuo95I,13469
86
- lcode_cli-0.45.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
87
- lcode_cli-0.45.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
88
- lcode_cli-0.45.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
89
- lcode_cli-0.45.0.dist-info/RECORD,,
89
+ lcode_cli-0.46.0.dist-info/METADATA,sha256=kqP00Fke7xDFTUDa8AGqGupdq4YoR7wWpdSyJoRi6ig,13469
90
+ lcode_cli-0.46.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
91
+ lcode_cli-0.46.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
92
+ lcode_cli-0.46.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
93
+ lcode_cli-0.46.0.dist-info/RECORD,,