Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,2 +1,60 @@
|
|
| 1 |
import os
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import sys
|
| 3 |
+
os.environ['HF_HOME'] = os.path.abspath(
|
| 4 |
+
os.path.realpath(os.path.join(os.path.dirname(__file__), './hf_download'))
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
import gradio as gr
|
| 8 |
+
import torch
|
| 9 |
+
import traceback
|
| 10 |
+
import einops
|
| 11 |
+
import safetensors.torch as sf
|
| 12 |
+
import numpy as np
|
| 13 |
+
import math
|
| 14 |
+
import spaces
|
| 15 |
+
|
| 16 |
+
from PIL import Image
|
| 17 |
+
from diffusers import AutoencoderKLHunyuanVideo
|
| 18 |
+
from transformers import (
|
| 19 |
+
LlamaModel, CLIPTextModel,
|
| 20 |
+
LlamaTokenizerFast, CLIPTokenizer
|
| 21 |
+
)
|
| 22 |
+
from diffusers_helper.hunyuan import (
|
| 23 |
+
encode_prompt_conds, vae_decode,
|
| 24 |
+
vae_encode, vae_decode_fake
|
| 25 |
+
)
|
| 26 |
+
from diffusers_helper.utils import (
|
| 27 |
+
save_bcthw_as_mp4, crop_or_pad_yield_mask,
|
| 28 |
+
soft_append_bcthw, resize_and_center_crop,
|
| 29 |
+
state_dict_weighted_merge, state_dict_offset_merge,
|
| 30 |
+
generate_timestamp
|
| 31 |
+
)
|
| 32 |
+
from diffusers_helper.models.hunyuan_video_packed import HunyuanVideoTransformer3DModelPacked
|
| 33 |
+
from diffusers_helper.pipelines.k_diffusion_hunyuan import sample_hunyuan
|
| 34 |
+
from diffusers_helper.memory import (
|
| 35 |
+
cpu, gpu,
|
| 36 |
+
get_cuda_free_memory_gb,
|
| 37 |
+
move_model_to_device_with_memory_preservation,
|
| 38 |
+
offload_model_from_device_for_memory_preservation,
|
| 39 |
+
fake_diffusers_current_device,
|
| 40 |
+
DynamicSwapInstaller,
|
| 41 |
+
unload_complete_models,
|
| 42 |
+
load_model_as_complete
|
| 43 |
+
)
|
| 44 |
+
from diffusers_helper.thread_utils import AsyncStream, async_run
|
| 45 |
+
from diffusers_helper.gradio.progress_bar import make_progress_bar_css, make_progress_bar_html
|
| 46 |
+
from transformers import SiglipImageProcessor, SiglipVisionModel
|
| 47 |
+
from diffusers_helper.clip_vision import hf_clip_vision_encode
|
| 48 |
+
from diffusers_helper.bucket_tools import find_nearest_bucket
|
| 49 |
+
|
| 50 |
+
import ast #추가 삽입, requirements: albumentations 추가
|
| 51 |
+
script_repr = os.getenv("APP")
|
| 52 |
+
if script_repr is None:
|
| 53 |
+
print("Error: Environment variable 'APP' not set.")
|
| 54 |
+
sys.exit(1)
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
exec(script_repr)
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f"Error executing script: {e}")
|
| 60 |
+
sys.exit(1)
|