Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,16 @@ from PIL import Image
|
|
| 32 |
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 33 |
from pydub import AudioSegment
|
| 34 |
from huggingface_hub import snapshot_download
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
from src.models.unet_2d_condition import UNet2DConditionModel
|
| 38 |
from src.models.unet_3d_emo import EMOUNet3DConditionModel
|
|
@@ -364,7 +373,8 @@ def build_pipeline(quantized=False, target_device=None, target_dtype=None):
|
|
| 364 |
target_device, dtype=target_dtype
|
| 365 |
)
|
| 366 |
if quantized:
|
| 367 |
-
|
|
|
|
| 368 |
print("Using int8 quantization for VAE.")
|
| 369 |
|
| 370 |
reference_unet = UNet2DConditionModel.from_pretrained(
|
|
@@ -380,7 +390,8 @@ def build_pipeline(quantized=False, target_device=None, target_dtype=None):
|
|
| 380 |
)
|
| 381 |
)
|
| 382 |
if quantized:
|
| 383 |
-
|
|
|
|
| 384 |
print("Using int8 quantization for reference UNet.")
|
| 385 |
|
| 386 |
motion_module_path = "./pretrained_weights/motion_module.pth"
|
|
@@ -1088,4 +1099,4 @@ with gr.Blocks() as demo:
|
|
| 1088 |
|
| 1089 |
if __name__ == "__main__":
|
| 1090 |
demo.queue()
|
| 1091 |
-
demo.launch(show_error=True, ssr_mode=False, css=css)
|
|
|
|
| 32 |
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 33 |
from pydub import AudioSegment
|
| 34 |
from huggingface_hub import snapshot_download
|
| 35 |
+
|
| 36 |
+
# ===== تغییرات اعمال شده برای رفع خطای torchao =====
|
| 37 |
+
from torchao.quantization import quantize_
|
| 38 |
+
try:
|
| 39 |
+
from torchao.quantization import Int8WeightOnlyConfig
|
| 40 |
+
quant_config = Int8WeightOnlyConfig()
|
| 41 |
+
except ImportError:
|
| 42 |
+
from torchao.quantization import int8_weight_only
|
| 43 |
+
quant_config = int8_weight_only()
|
| 44 |
+
# =================================================
|
| 45 |
|
| 46 |
from src.models.unet_2d_condition import UNet2DConditionModel
|
| 47 |
from src.models.unet_3d_emo import EMOUNet3DConditionModel
|
|
|
|
| 373 |
target_device, dtype=target_dtype
|
| 374 |
)
|
| 375 |
if quantized:
|
| 376 |
+
# ===== تغییر مربوط به VAE =====
|
| 377 |
+
quantize_(vae, quant_config)
|
| 378 |
print("Using int8 quantization for VAE.")
|
| 379 |
|
| 380 |
reference_unet = UNet2DConditionModel.from_pretrained(
|
|
|
|
| 390 |
)
|
| 391 |
)
|
| 392 |
if quantized:
|
| 393 |
+
# ===== تغییر مربوط به reference UNet =====
|
| 394 |
+
quantize_(reference_unet, quant_config)
|
| 395 |
print("Using int8 quantization for reference UNet.")
|
| 396 |
|
| 397 |
motion_module_path = "./pretrained_weights/motion_module.pth"
|
|
|
|
| 1099 |
|
| 1100 |
if __name__ == "__main__":
|
| 1101 |
demo.queue()
|
| 1102 |
+
demo.launch(show_error=True, ssr_mode=False, css=css)
|