Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app_pusa.py
Browse files- app_pusa.py +2 -41
 
    	
        app_pusa.py
    CHANGED
    
    | 
         @@ -14,7 +14,7 @@ import os 
     | 
|
| 14 | 
         
             
            # LORA_FILENAME = "Wan21_CausVid_bidirect2_T2V_1_3B_lora_rank32.safetensors"
         
     | 
| 15 | 
         | 
| 16 | 
         | 
| 17 | 
         
            -
             
     | 
| 18 | 
         | 
| 19 | 
         | 
| 20 | 
         | 
| 
         @@ -31,7 +31,6 @@ LORA_REPO_ID = "Kijai/WanVideo_comfy" 
     | 
|
| 31 | 
         | 
| 32 | 
         
             
            #pusa test
         
     | 
| 33 | 
         | 
| 34 | 
         
            -
            MODEL_ID = "Wan-AI/Wan2.1-T2V-14B"
         
     | 
| 35 | 
         
             
            LORA_FILENAME = "Pusa/Wan21_PusaV1_LoRA_14B_rank512_bf16.safetensors"
         
     | 
| 36 | 
         | 
| 37 | 
         
             
            # LORA_REPO_ID = "RaphaelLiu/PusaV1"
         
     | 
| 
         @@ -158,45 +157,7 @@ def generate_video(prompt, height, width, 
     | 
|
| 158 | 
         
             
                               guidance_scale = 1, steps = 4,
         
     | 
| 159 | 
         
             
                               seed = 42, randomize_seed = False, 
         
     | 
| 160 | 
         
             
                               progress=gr.Progress(track_tqdm=True)):
         
     | 
| 161 | 
         
            -
             
     | 
| 162 | 
         
            -
                Generate a video from a text prompt using the Wan 2.1 T2V model with CausVid LoRA.
         
     | 
| 163 | 
         
            -
                
         
     | 
| 164 | 
         
            -
                This function takes a text prompt and generates a video based on the provided
         
     | 
| 165 | 
         
            -
                prompt and parameters. It uses the Wan 2.1 1.3B Text-to-Video model with CausVid LoRA
         
     | 
| 166 | 
         
            -
                for fast generation in 3-8 steps.
         
     | 
| 167 | 
         
            -
                
         
     | 
| 168 | 
         
            -
                Args:
         
     | 
| 169 | 
         
            -
                    prompt (str): Text prompt describing the desired video content.
         
     | 
| 170 | 
         
            -
                    height (int): Target height for the output video. Will be adjusted to multiple of MOD_VALUE (32).
         
     | 
| 171 | 
         
            -
                    width (int): Target width for the output video. Will be adjusted to multiple of MOD_VALUE (32).
         
     | 
| 172 | 
         
            -
                    negative_prompt (str, optional): Negative prompt to avoid unwanted elements. 
         
     | 
| 173 | 
         
            -
                        Defaults to default_negative_prompt (contains unwanted visual artifacts).
         
     | 
| 174 | 
         
            -
                    duration_seconds (float, optional): Duration of the generated video in seconds.
         
     | 
| 175 | 
         
            -
                        Defaults to 2. Clamped between MIN_FRAMES_MODEL/FIXED_FPS and MAX_FRAMES_MODEL/FIXED_FPS.
         
     | 
| 176 | 
         
            -
                    guidance_scale (float, optional): Controls adherence to the prompt. Higher values = more adherence.
         
     | 
| 177 | 
         
            -
                        Defaults to 1.0. Range: 0.0-20.0.
         
     | 
| 178 | 
         
            -
                    steps (int, optional): Number of inference steps. More steps = higher quality but slower.
         
     | 
| 179 | 
         
            -
                        Defaults to 4. Range: 1-30.
         
     | 
| 180 | 
         
            -
                    seed (int, optional): Random seed for reproducible results. Defaults to 42.
         
     | 
| 181 | 
         
            -
                        Range: 0 to MAX_SEED (2147483647).
         
     | 
| 182 | 
         
            -
                    randomize_seed (bool, optional): Whether to use a random seed instead of the provided seed.
         
     | 
| 183 | 
         
            -
                        Defaults to False.
         
     | 
| 184 | 
         
            -
                    progress (gr.Progress, optional): Gradio progress tracker. Defaults to gr.Progress(track_tqdm=True).
         
     | 
| 185 | 
         
            -
                
         
     | 
| 186 | 
         
            -
                Returns:
         
     | 
| 187 | 
         
            -
                    tuple: A tuple containing:
         
     | 
| 188 | 
         
            -
                        - video_path (str): Path to the generated video file (.mp4)
         
     | 
| 189 | 
         
            -
                        - current_seed (int): The seed used for generation (useful when randomize_seed=True)
         
     | 
| 190 | 
         
            -
                
         
     | 
| 191 | 
         
            -
                Raises:
         
     | 
| 192 | 
         
            -
                    gr.Error: If prompt is empty or None.
         
     | 
| 193 | 
         
            -
                
         
     | 
| 194 | 
         
            -
                Note:
         
     | 
| 195 | 
         
            -
                    - Frame count is calculated as duration_seconds * FIXED_FPS (24)
         
     | 
| 196 | 
         
            -
                    - Output dimensions are adjusted to be multiples of MOD_VALUE (32)
         
     | 
| 197 | 
         
            -
                    - The function uses GPU acceleration via the @spaces.GPU decorator
         
     | 
| 198 | 
         
            -
                    - Generation time varies based on steps and duration (see get_duration function)
         
     | 
| 199 | 
         
            -
                """
         
     | 
| 200 | 
         
             
                if not prompt or prompt.strip() == "":
         
     | 
| 201 | 
         
             
                    raise gr.Error("Please enter a text prompt. Try to use long and precise descriptions.")
         
     | 
| 202 | 
         | 
| 
         | 
|
| 14 | 
         
             
            # LORA_FILENAME = "Wan21_CausVid_bidirect2_T2V_1_3B_lora_rank32.safetensors"
         
     | 
| 15 | 
         | 
| 16 | 
         | 
| 17 | 
         
            +
            MODEL_ID = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
         
     | 
| 18 | 
         | 
| 19 | 
         | 
| 20 | 
         | 
| 
         | 
|
| 31 | 
         | 
| 32 | 
         
             
            #pusa test
         
     | 
| 33 | 
         | 
| 
         | 
|
| 34 | 
         
             
            LORA_FILENAME = "Pusa/Wan21_PusaV1_LoRA_14B_rank512_bf16.safetensors"
         
     | 
| 35 | 
         | 
| 36 | 
         
             
            # LORA_REPO_ID = "RaphaelLiu/PusaV1"
         
     | 
| 
         | 
|
| 157 | 
         
             
                               guidance_scale = 1, steps = 4,
         
     | 
| 158 | 
         
             
                               seed = 42, randomize_seed = False, 
         
     | 
| 159 | 
         
             
                               progress=gr.Progress(track_tqdm=True)):
         
     | 
| 160 | 
         
            +
               
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 161 | 
         
             
                if not prompt or prompt.strip() == "":
         
     | 
| 162 | 
         
             
                    raise gr.Error("Please enter a text prompt. Try to use long and precise descriptions.")
         
     | 
| 163 | 
         |