Julian Bilcke commited on
Commit ·
172da8f
1
Parent(s): eb53d59
Fix for #22
Browse filesFiles changed (3)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455# Investigating issue in production
Note: the following document is meant for maintainers of VMS.
It describe things that are normally only useful during development, for instance if there are bugs.
Normal VMS users do not need to read this document and perform those steps, since in theory VMS is already taking care of things (eg. automatic fix of corrupted internal JSON files) or providing ways to solve common issues (eg. buttons to download or delete data).
## Backuping data
During development of VMs, there might be bugs creating data corruption.
To avoid reseting the /data folder all the time, I suggest simply doing backups of what you need.
1. run the space in developer mode2. open vscode from the dev mode panel3. go to the data dir (eg /data if you have persistence, or .data otherwise)4. do whatever you want (you are the developer, after all)5. for instance you can edit files, delete stuff etc
### Manual backout of the output dir
```bashmkdir /data/backup
# to copy training datacp -r /data/training /data/backup/training
# to copy generated models and checkpointscp -r /data/output /data/backup/output```
### Manual restore of a backup
```bash# if you already have a backup of output/ then you can delete its contentrm -Rf output/*
# restore the backup, for instance the weights and checkpointscp -r backup/output/* output/```
### Manual restore of UI state
Restoring the UI state can be tricky as it is being modified by Gradio.
I recommend shutting Gradio down, but this will kill the space and the VS Code session.
So a tricky is to restart Gradio and immediately perform this command:
```bashcp backup/output/ui_state.json output/```
That way Gradio will inialize itself with the backuped UI state.68 unmodified lines6970717273747511 unmodified lines8788899091929394959697989910010153 unmodified lines1551561571581591601612 unmodified lines16416516616716816917017117217317417517617717817918018118218318414 unmodified lines19920020120220320420551 unmodified lines25725825926026126226326426526626722 unmodified lines29029129229329429543 unmodified lines33934034134234334434539 unmodified lines38538638738838939039139239339415 unmodified lines41041141241341441530 unmodified lines44644744844945045145253 unmodified lines50650750850951051151251351451516 unmodified lines53253353453553653768 unmodified linesnum_frames: int,guidance_scale: float,flow_shift: float,lora_weight: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,11 unmodified lines# Return updated log string for UI updatesreturn "\n".join(log_messages)# Find latest LoRA weights if lora_weight > 0lora_path = Noneusing_lora = lora_weight > 0if using_lora:lora_path = self.find_latest_lora_weights()if not lora_path:return None, "Error: No LoRA weights found", log("Error: No LoRA weights found in output directory")log(f"Using LoRA weights with weight {lora_weight}")else:log("Using original model without LoRA weights")53 unmodified linesif using_lora and lora_path:log(f"Using LoRA weights from: {lora_path}")log(f"Resolution: {width}x{height}, Frames: {num_frames}, FPS: {fps}")log(f"Guidance Scale: {guidance_scale}, Flow Shift: {flow_shift}, LoRA Weight: {lora_weight if using_lora else 0}")log(f"Generation Seed: {seed}")#log(f"Prompt: {full_prompt}")#log(f"Negative Prompt: {negative_prompt}")2 unmodified linesif internal_model_type == "wan":return self.generate_wan_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_weight,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)elif internal_model_type == "ltx_video":return self.generate_ltx_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_weight,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)elif internal_model_type == "hunyuan_video":return self.generate_hunyuan_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_weight,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)14 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_weight: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,51 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_weight > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with weight {lora_weight}...")pipe.load_lora_weights(lora_path)# TODO: Set the lora scale directly instead of using fuse_lora#pipe._lora_scale = lora_weightelse:log_fn("Using base model without LoRA weights")22 unmodified linesnum_frames=num_frames,guidance_scale=guidance_scale,num_inference_steps=inference_steps,generator=generator,).frames[0]else:43 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_weight: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,39 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_weight > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with weight {lora_weight}...")pipe.load_lora_weights(lora_path)pipe.fuse_lora(lora_weight)else:log_fn("Using base model without LoRA weights")15 unmodified linesdecode_timestep=0.03,decode_noise_scale=0.025,num_inference_steps=inference_steps,generator=generator,).frames[0]30 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_weight: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,53 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_weight > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with weight {lora_weight}...")pipe.load_lora_weights(lora_path)pipe.fuse_lora(lora_weight)else:log_fn("Using base model without LoRA weights")16 unmodified linesguidance_scale=guidance_scale,true_cfg_scale=1.0,num_inference_steps=inference_steps,generator=generator,).frames[0]68 unmodified lines6970717273747511 unmodified lines8788899091929394959697989910010153 unmodified lines1551561571581591601612 unmodified lines16416516616716816917017117217317417517617717817918018118218318414 unmodified lines19920020120220320420551 unmodified lines25725825926026126226326426522 unmodified lines28828929029129229329443 unmodified lines33833934034134234334439 unmodified lines38438538638738838939039139215 unmodified lines40840941041141241341430 unmodified lines44544644744844945045153 unmodified lines50550650750850951051151251316 unmodified lines53053153253353453553668 unmodified linesnum_frames: int,guidance_scale: float,flow_shift: float,lora_scale: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,11 unmodified lines# Return updated log string for UI updatesreturn "\n".join(log_messages)# Find latest LoRA weights if lora_scale > 0lora_path = Noneusing_lora = lora_scale > 0if using_lora:lora_path = self.find_latest_lora_weights()if not lora_path:return None, "Error: No LoRA weights found", log("Error: No LoRA weights found in output directory")log(f"Using LoRA weights with scale {lora_scale}")else:log("Using original model without LoRA weights")53 unmodified linesif using_lora and lora_path:log(f"Using LoRA weights from: {lora_path}")log(f"Resolution: {width}x{height}, Frames: {num_frames}, FPS: {fps}")log(f"Guidance Scale: {guidance_scale}, Flow Shift: {flow_shift}, LoRA Scale: {lora_scale if using_lora else 0}")log(f"Generation Seed: {seed}")#log(f"Prompt: {full_prompt}")#log(f"Negative Prompt: {negative_prompt}")2 unmodified linesif internal_model_type == "wan":return self.generate_wan_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_scale,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)elif internal_model_type == "ltx_video":return self.generate_ltx_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_scale,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)elif internal_model_type == "hunyuan_video":return self.generate_hunyuan_video(full_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_scale,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)14 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_scale: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,51 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_scale > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with lora scale {lora_scale}...")pipe.load_lora_weights(lora_path)else:log_fn("Using base model without LoRA weights")22 unmodified linesnum_frames=num_frames,guidance_scale=guidance_scale,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]else:43 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_scale: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,39 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_scale > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with lora scale {lora_scale}...")pipe.load_lora_weights(lora_path)else:log_fn("Using base model without LoRA weights")15 unmodified linesdecode_timestep=0.03,decode_noise_scale=0.025,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]30 unmodified linesguidance_scale: float,flow_shift: float,lora_path: str,lora_scale: float,inference_steps: int,seed: int = -1,enable_cpu_offload: bool = True,53 unmodified linespipe.enable_model_cpu_offload()# Apply LoRA weights if using themif lora_scale > 0 and lora_path:log_fn(f"Loading LoRA weights from {lora_path} with lora scale {lora_scale}...")pipe.load_lora_weights(lora_path)else:log_fn("Using base model without LoRA weights")16 unmodified linesguidance_scale=guidance_scale,true_cfg_scale=1.0,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]
163 unmodified lines16416516616716816917017164 unmodified lines236237238239240241242136 unmodified lines37938038138238338438511 unmodified lines3973983994004014024036 unmodified lines41041141241341441541616 unmodified lines43343443543643743843995 unmodified lines53553653753853954054161 unmodified lines60360460560660760860925 unmodified lines63563663763863964064115 unmodified lines6576586596606616626636646 unmodified lines671672673674675676677163 unmodified lines)with gr.Row():self.components["lora_weight"] = gr.Slider(label="LoRA Weight",minimum=0.0,maximum=1.0,step=0.01,64 unmodified linesis_using_lora = "Use LoRA model" in use_lora_valuereturn {self.components["lora_weight"]: gr.Slider(visible=is_using_lora)}def get_model_version_choices(self, model_type: str) -> List[str]:136 unmodified linesself.components["use_lora"].change(fn=self.update_lora_ui,inputs=[self.components["use_lora"]],outputs=[self.components["lora_weight"]])# Load preview UI state when the tab is selected11 unmodified linesself.components["fps"],self.components["guidance_scale"],self.components["flow_shift"],self.components["lora_weight"],self.components["inference_steps"],self.components["enable_cpu_offload"],self.components["model_version"],6 unmodified linesfor component_name in ["prompt", "negative_prompt", "prompt_prefix", "model_version", "resolution_preset","width", "height", "num_frames", "fps", "guidance_scale", "flow_shift","lora_weight", "inference_steps", "enable_cpu_offload", "seed", "use_lora"]:if component_name in self.components:self.components[component_name].change(16 unmodified linesself.components["num_frames"],self.components["guidance_scale"],self.components["flow_shift"],self.components["lora_weight"],self.components["inference_steps"],self.components["enable_cpu_offload"],self.components["fps"],95 unmodified linespreview_state.get("fps", 16),preview_state.get("guidance_scale", 5.0),preview_state.get("flow_shift", 3.0),preview_state.get("lora_weight", 0.7),preview_state.get("inference_steps", 30),preview_state.get("enable_cpu_offload", True),model_version,61 unmodified linesnum_frames: int,guidance_scale: float,flow_shift: float,lora_weight: float,inference_steps: int,enable_cpu_offload: bool,fps: int,25 unmodified lines"fps": fps,"guidance_scale": guidance_scale,"flow_shift": flow_shift,"lora_weight": lora_weight,"inference_steps": inference_steps,"enable_cpu_offload": enable_cpu_offload,"seed": seed,15 unmodified linesuse_lora_model = use_lora == "Use LoRA model"# Start actual generation# If not using LoRA, set lora_weight to 0 to disable iteffective_lora_weight = lora_weight if use_lora_model else 0.0result = self.app.previewing.generate_video(model_type=model_type,6 unmodified linesnum_frames=num_frames,guidance_scale=guidance_scale,flow_shift=flow_shift,lora_weight=effective_lora_weight, # Use 0.0 if not using LoRAinference_steps=inference_steps,enable_cpu_offload=enable_cpu_offload,fps=fps,163 unmodified lines16416516616716816917017164 unmodified lines236237238239240241242136 unmodified lines37938038138238338438511 unmodified lines3973983994004014024036 unmodified lines41041141241341441541616 unmodified lines43343443543643743843995 unmodified lines53553653753853954054161 unmodified lines60360460560660760860925 unmodified lines63563663763863964064115 unmodified lines6576586596606616626636646 unmodified lines671672673674675676677163 unmodified lines)with gr.Row():self.components["lora_scale"] = gr.Slider(label="LoRA Scale",minimum=0.0,maximum=1.0,step=0.01,64 unmodified linesis_using_lora = "Use LoRA model" in use_lora_valuereturn {self.components["lora_scale"]: gr.Slider(visible=is_using_lora)}def get_model_version_choices(self, model_type: str) -> List[str]:136 unmodified linesself.components["use_lora"].change(fn=self.update_lora_ui,inputs=[self.components["use_lora"]],outputs=[self.components["lora_scale"]])# Load preview UI state when the tab is selected11 unmodified linesself.components["fps"],self.components["guidance_scale"],self.components["flow_shift"],self.components["lora_scale"],self.components["inference_steps"],self.components["enable_cpu_offload"],self.components["model_version"],6 unmodified linesfor component_name in ["prompt", "negative_prompt", "prompt_prefix", "model_version", "resolution_preset","width", "height", "num_frames", "fps", "guidance_scale", "flow_shift","lora_scale", "inference_steps", "enable_cpu_offload", "seed", "use_lora"]:if component_name in self.components:self.components[component_name].change(16 unmodified linesself.components["num_frames"],self.components["guidance_scale"],self.components["flow_shift"],self.components["lora_scale"],self.components["inference_steps"],self.components["enable_cpu_offload"],self.components["fps"],95 unmodified linespreview_state.get("fps", 16),preview_state.get("guidance_scale", 5.0),preview_state.get("flow_shift", 3.0),preview_state.get("lora_scale", 0.7),preview_state.get("inference_steps", 30),preview_state.get("enable_cpu_offload", True),model_version,61 unmodified linesnum_frames: int,guidance_scale: float,flow_shift: float,lora_scale: float,inference_steps: int,enable_cpu_offload: bool,fps: int,25 unmodified lines"fps": fps,"guidance_scale": guidance_scale,"flow_shift": flow_shift,"lora_scale": lora_scale,"inference_steps": inference_steps,"enable_cpu_offload": enable_cpu_offload,"seed": seed,15 unmodified linesuse_lora_model = use_lora == "Use LoRA model"# Start actual generation# If not using LoRA, set lora_scale to 0 to disable iteffective_lora_scale = lora_scale if use_lora_model else 0.0result = self.app.previewing.generate_video(model_type=model_type,6 unmodified linesnum_frames=num_frames,guidance_scale=guidance_scale,flow_shift=flow_shift,lora_scale=effective_lora_scale, # Use 0.0 if not using LoRAinference_steps=inference_steps,enable_cpu_offload=enable_cpu_offload,fps=fps,
docs/vms/Investigating issues in production.mdAdded+55
vms/ui/project/services/previewing.py+20-21
vms/ui/project/tabs/preview_tab.py+13-13