Update app.py
Browse files
app.py
CHANGED
|
@@ -43,10 +43,10 @@ STYLE_PRESETS = {
|
|
| 43 |
"Artistic": "artistic style, creative composition, unique visual style, expressive animation, stylized rendering"
|
| 44 |
}
|
| 45 |
|
| 46 |
-
# 固定模型配置 -
|
| 47 |
-
|
| 48 |
-
#
|
| 49 |
-
|
| 50 |
|
| 51 |
# 质量增强提示词 - 适配视频
|
| 52 |
QUALITY_ENHANCERS = [
|
|
@@ -116,49 +116,43 @@ def initialize_model():
|
|
| 116 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 117 |
print(f"🖥️ Using device: {device}")
|
| 118 |
|
| 119 |
-
print(f"
|
| 120 |
-
print(f"
|
| 121 |
|
| 122 |
-
#
|
| 123 |
try:
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 129 |
use_safetensors=True,
|
| 130 |
-
|
| 131 |
-
requires_safety_checker=False
|
| 132 |
)
|
| 133 |
-
print("
|
| 134 |
-
except Exception as cogvideo_error:
|
| 135 |
-
print(f"⚠️ CogVideoX loading failed: {cogvideo_error}")
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
try:
|
| 139 |
-
pipeline =
|
| 140 |
-
|
| 141 |
-
config=BASE_CONFIG_MODEL,
|
| 142 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 143 |
-
use_safetensors=True
|
| 144 |
-
safety_checker=None,
|
| 145 |
-
requires_safety_checker=False,
|
| 146 |
-
trust_remote_code=True
|
| 147 |
)
|
| 148 |
-
print("
|
| 149 |
-
except Exception as
|
| 150 |
-
print(f"
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
print("🔄 Falling back to official CogVideoX model (non-NSFW)...")
|
| 154 |
pipeline = CogVideoXPipeline.from_pretrained(
|
| 155 |
-
|
| 156 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 157 |
-
use_safetensors=True
|
| 158 |
-
safety_checker=None,
|
| 159 |
-
requires_safety_checker=False
|
| 160 |
)
|
| 161 |
-
print("
|
| 162 |
|
| 163 |
pipeline = pipeline.to(device)
|
| 164 |
|
|
@@ -868,9 +862,9 @@ def create_interface():
|
|
| 868 |
# ===== 启动应用 =====
|
| 869 |
if __name__ == "__main__":
|
| 870 |
print("🎬 Starting NSFW Video Generator...")
|
| 871 |
-
print(f"
|
| 872 |
-
print(f"
|
| 873 |
-
print("
|
| 874 |
print(f"🔧 Default Duration: {VIDEO_CONFIG['default_duration']}s")
|
| 875 |
print(f"🔧 Default Resolution: {VIDEO_CONFIG['default_width']}×{VIDEO_CONFIG['default_height']}")
|
| 876 |
print(f"🔧 Spaces GPU: {'✅ Available' if SPACES_AVAILABLE else '❌ Not Available'}")
|
|
|
|
| 43 |
"Artistic": "artistic style, creative composition, unique visual style, expressive animation, stylized rendering"
|
| 44 |
}
|
| 45 |
|
| 46 |
+
# 固定模型配置 - 使用您的完整私人仓库(添加配置文件后)
|
| 47 |
+
PRIVATE_MODEL = "alexander00001/NSFW_Wan_14b"
|
| 48 |
+
# 备用官方模型
|
| 49 |
+
FALLBACK_MODEL = "THUDM/CogVideoX-5b"
|
| 50 |
|
| 51 |
# 质量增强提示词 - 适配视频
|
| 52 |
QUALITY_ENHANCERS = [
|
|
|
|
| 116 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 117 |
print(f"🖥️ Using device: {device}")
|
| 118 |
|
| 119 |
+
print(f"Loading Private NSFW Model: {PRIVATE_MODEL}")
|
| 120 |
+
print(f"Fallback Model: {FALLBACK_MODEL}")
|
| 121 |
|
| 122 |
+
# 首先尝试加载您的私人NSFW模型(完整仓库结构)
|
| 123 |
try:
|
| 124 |
+
# 使用WanPipeline而不是CogVideoXPipeline
|
| 125 |
+
from diffusers import WanPipeline
|
| 126 |
+
pipeline = WanPipeline.from_pretrained(
|
| 127 |
+
PRIVATE_MODEL,
|
| 128 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 129 |
use_safetensors=True,
|
| 130 |
+
trust_remote_code=True # 私人仓库需要
|
|
|
|
| 131 |
)
|
| 132 |
+
print("Successfully loaded private NSFW Wan model!")
|
|
|
|
|
|
|
| 133 |
|
| 134 |
+
except Exception as private_error:
|
| 135 |
+
print(f"Private Wan model loading failed: {private_error}")
|
| 136 |
+
print(f"Falling back to official model: {FALLBACK_MODEL}")
|
| 137 |
+
|
| 138 |
+
# 备选:尝试官方Wan2.2-Diffusers版本
|
| 139 |
try:
|
| 140 |
+
pipeline = WanPipeline.from_pretrained(
|
| 141 |
+
"Wan-AI/Wan2.2-T2V-A14B-Diffusers",
|
|
|
|
| 142 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 143 |
+
use_safetensors=True
|
|
|
|
|
|
|
|
|
|
| 144 |
)
|
| 145 |
+
print("Loaded official Wan2.2-Diffusers model")
|
| 146 |
+
except Exception as wan_error:
|
| 147 |
+
print(f"Official Wan loading failed: {wan_error}")
|
| 148 |
+
# 最后备选:CogVideoX
|
| 149 |
+
from diffusers import CogVideoXPipeline
|
|
|
|
| 150 |
pipeline = CogVideoXPipeline.from_pretrained(
|
| 151 |
+
FALLBACK_MODEL,
|
| 152 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 153 |
+
use_safetensors=True
|
|
|
|
|
|
|
| 154 |
)
|
| 155 |
+
print("Loaded CogVideoX as final fallback")
|
| 156 |
|
| 157 |
pipeline = pipeline.to(device)
|
| 158 |
|
|
|
|
| 862 |
# ===== 启动应用 =====
|
| 863 |
if __name__ == "__main__":
|
| 864 |
print("🎬 Starting NSFW Video Generator...")
|
| 865 |
+
print(f"Private NSFW Model: {PRIVATE_MODEL}")
|
| 866 |
+
print(f"Fallback Model: {FALLBACK_MODEL}")
|
| 867 |
+
print("Using complete repository structure for proper loading")
|
| 868 |
print(f"🔧 Default Duration: {VIDEO_CONFIG['default_duration']}s")
|
| 869 |
print(f"🔧 Default Resolution: {VIDEO_CONFIG['default_width']}×{VIDEO_CONFIG['default_height']}")
|
| 870 |
print(f"🔧 Spaces GPU: {'✅ Available' if SPACES_AVAILABLE else '❌ Not Available'}")
|