Update app.py
Browse files
app.py
CHANGED
|
@@ -44,8 +44,9 @@ STYLE_PRESETS = {
|
|
| 44 |
}
|
| 45 |
|
| 46 |
# 固定模型配置 - 使用NSFW版本的safetensors文件
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
# 质量增强提示词 - 适配视频
|
| 51 |
QUALITY_ENHANCERS = [
|
|
@@ -116,46 +117,48 @@ def initialize_model():
|
|
| 116 |
print(f"🖥️ Using device: {device}")
|
| 117 |
|
| 118 |
print(f"📦 Loading NSFW Wan T2V checkpoint: wan_14B_e15.safetensors")
|
| 119 |
-
print(f"🔧 Using config from: {BASE_CONFIG_MODEL}")
|
| 120 |
|
| 121 |
-
#
|
| 122 |
try:
|
| 123 |
-
from diffusers import
|
| 124 |
-
pipeline =
|
| 125 |
-
|
| 126 |
-
config=BASE_CONFIG_MODEL,
|
| 127 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 128 |
use_safetensors=True,
|
| 129 |
safety_checker=None,
|
| 130 |
requires_safety_checker=False
|
| 131 |
)
|
| 132 |
-
print("✅ Successfully loaded with
|
| 133 |
-
except
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
|
| 160 |
pipeline = pipeline.to(device)
|
| 161 |
|
|
@@ -635,7 +638,7 @@ def create_interface():
|
|
| 635 |
# 简化警告信息
|
| 636 |
gr.HTML('''
|
| 637 |
<div class="warning-box">
|
| 638 |
-
⚠️ 18+ CONTENT WARNING ⚠️ |
|
| 639 |
</div>
|
| 640 |
''')
|
| 641 |
|
|
@@ -863,9 +866,9 @@ def create_interface():
|
|
| 863 |
# ===== 启动应用 =====
|
| 864 |
if __name__ == "__main__":
|
| 865 |
print("🎬 Starting NSFW Video Generator...")
|
| 866 |
-
print(f"🔧 NSFW
|
| 867 |
-
print(f"🔧 Base Config
|
| 868 |
-
print("🔧 Using from_single_file() method
|
| 869 |
print(f"🔧 Default Duration: {VIDEO_CONFIG['default_duration']}s")
|
| 870 |
print(f"🔧 Default Resolution: {VIDEO_CONFIG['default_width']}×{VIDEO_CONFIG['default_height']}")
|
| 871 |
print(f"🔧 Spaces GPU: {'✅ Available' if SPACES_AVAILABLE else '❌ Not Available'}")
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
# 固定模型配置 - 使用NSFW版本的safetensors文件
|
| 47 |
+
NSFW_CHECKPOINT_URL = "https://huggingface.co/NSFW-API/NSFW_Wan_14b/resolve/main/wan_14B_e15.safetensors"
|
| 48 |
+
# 使用CogVideoX作为基础配置,因为Wan很可能基于CogVideoX架构
|
| 49 |
+
BASE_CONFIG_MODEL = "THUDM/CogVideoX-5b" # 用于获取配置信息
|
| 50 |
|
| 51 |
# 质量增强提示词 - 适配视频
|
| 52 |
QUALITY_ENHANCERS = [
|
|
|
|
| 117 |
print(f"🖥️ Using device: {device}")
|
| 118 |
|
| 119 |
print(f"📦 Loading NSFW Wan T2V checkpoint: wan_14B_e15.safetensors")
|
| 120 |
+
print(f"🔧 Using CogVideoX config from: {BASE_CONFIG_MODEL}")
|
| 121 |
|
| 122 |
+
# 方法1: 尝试使用CogVideoXPipeline加载(最可能成功)
|
| 123 |
try:
|
| 124 |
+
from diffusers import CogVideoXPipeline
|
| 125 |
+
pipeline = CogVideoXPipeline.from_single_file(
|
| 126 |
+
NSFW_CHECKPOINT_URL,
|
| 127 |
+
config=BASE_CONFIG_MODEL,
|
| 128 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 129 |
use_safetensors=True,
|
| 130 |
safety_checker=None,
|
| 131 |
requires_safety_checker=False
|
| 132 |
)
|
| 133 |
+
print("✅ Successfully loaded with CogVideoXPipeline.from_single_file()")
|
| 134 |
+
except Exception as cogvideo_error:
|
| 135 |
+
print(f"⚠️ CogVideoX loading failed: {cogvideo_error}")
|
| 136 |
+
|
| 137 |
+
# 方法2: 尝试通用DiffusionPipeline
|
| 138 |
+
try:
|
| 139 |
+
pipeline = DiffusionPipeline.from_single_file(
|
| 140 |
+
NSFW_CHECKPOINT_URL,
|
| 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("✅ Successfully loaded with DiffusionPipeline.from_single_file()")
|
| 149 |
+
except Exception as diffusion_error:
|
| 150 |
+
print(f"⚠️ DiffusionPipeline single file loading failed: {diffusion_error}")
|
| 151 |
+
|
| 152 |
+
# 方法3: 最后备选 - 直接使用官方CogVideoX(非NSFW)
|
| 153 |
+
print("🔄 Falling back to official CogVideoX model (non-NSFW)...")
|
| 154 |
+
pipeline = CogVideoXPipeline.from_pretrained(
|
| 155 |
+
BASE_CONFIG_MODEL,
|
| 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("✅ Loaded official CogVideoX as fallback (non-NSFW version)")
|
| 162 |
|
| 163 |
pipeline = pipeline.to(device)
|
| 164 |
|
|
|
|
| 638 |
# 简化警告信息
|
| 639 |
gr.HTML('''
|
| 640 |
<div class="warning-box">
|
| 641 |
+
⚠️ 18+ CONTENT WARNING ⚠️ | Model: NSFW_Wan_14b → CogVideoX Architecture
|
| 642 |
</div>
|
| 643 |
''')
|
| 644 |
|
|
|
|
| 866 |
# ===== 启动应用 =====
|
| 867 |
if __name__ == "__main__":
|
| 868 |
print("🎬 Starting NSFW Video Generator...")
|
| 869 |
+
print(f"🔧 NSFW Checkpoint: {NSFW_CHECKPOINT_URL}")
|
| 870 |
+
print(f"🔧 Base Config: {BASE_CONFIG_MODEL} (CogVideoX-5b)")
|
| 871 |
+
print("🔧 Using CogVideoXPipeline.from_single_file() method")
|
| 872 |
print(f"🔧 Default Duration: {VIDEO_CONFIG['default_duration']}s")
|
| 873 |
print(f"🔧 Default Resolution: {VIDEO_CONFIG['default_width']}×{VIDEO_CONFIG['default_height']}")
|
| 874 |
print(f"🔧 Spaces GPU: {'✅ Available' if SPACES_AVAILABLE else '❌ Not Available'}")
|