Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,9 +43,9 @@ STYLE_PRESETS = {
|
|
| 43 |
"Artistic": "artistic style, creative composition, unique visual style, expressive animation, stylized rendering"
|
| 44 |
}
|
| 45 |
|
| 46 |
-
# 固定模型配置 -
|
| 47 |
-
FIXED_MODEL = "
|
| 48 |
-
|
| 49 |
|
| 50 |
# 质量增强提示词 - 适配视频
|
| 51 |
QUALITY_ENHANCERS = [
|
|
@@ -115,31 +115,47 @@ def initialize_model():
|
|
| 115 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 116 |
print(f"🖥️ Using device: {device}")
|
| 117 |
|
| 118 |
-
print(f"📦 Loading
|
|
|
|
| 119 |
|
| 120 |
-
#
|
| 121 |
try:
|
| 122 |
from diffusers import WanPipeline
|
| 123 |
-
pipeline = WanPipeline.
|
| 124 |
FIXED_MODEL,
|
|
|
|
| 125 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 126 |
-
variant="fp16" if torch.cuda.is_available() else None,
|
| 127 |
use_safetensors=True,
|
| 128 |
safety_checker=None,
|
| 129 |
requires_safety_checker=False
|
| 130 |
)
|
|
|
|
| 131 |
except ImportError:
|
| 132 |
# 如果WanPipeline不可用,使用通用DiffusionPipeline
|
| 133 |
-
print("⚠️ WanPipeline not found,
|
| 134 |
-
pipeline = DiffusionPipeline.
|
| 135 |
FIXED_MODEL,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 137 |
-
variant="fp16" if torch.cuda.is_available() else None,
|
| 138 |
use_safetensors=True,
|
| 139 |
safety_checker=None,
|
| 140 |
requires_safety_checker=False,
|
| 141 |
trust_remote_code=True
|
| 142 |
)
|
|
|
|
| 143 |
|
| 144 |
pipeline = pipeline.to(device)
|
| 145 |
|
|
@@ -619,7 +635,7 @@ def create_interface():
|
|
| 619 |
# 简化警告信息
|
| 620 |
gr.HTML('''
|
| 621 |
<div class="warning-box">
|
| 622 |
-
⚠️ 18+ CONTENT WARNING ⚠️ | T2V Model: NSFW_Wan_14b
|
| 623 |
</div>
|
| 624 |
''')
|
| 625 |
|
|
@@ -847,8 +863,9 @@ def create_interface():
|
|
| 847 |
# ===== 启动应用 =====
|
| 848 |
if __name__ == "__main__":
|
| 849 |
print("🎬 Starting NSFW Video Generator...")
|
| 850 |
-
print(f"🔧
|
| 851 |
-
print("🔧
|
|
|
|
| 852 |
print(f"🔧 Default Duration: {VIDEO_CONFIG['default_duration']}s")
|
| 853 |
print(f"🔧 Default Resolution: {VIDEO_CONFIG['default_width']}×{VIDEO_CONFIG['default_height']}")
|
| 854 |
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 |
+
# 固定模型配置 - 使用NSFW版本的safetensors文件
|
| 47 |
+
FIXED_MODEL = "https://huggingface.co/NSFW-API/NSFW_Wan_14b/resolve/main/wan_14B_e15.safetensors"
|
| 48 |
+
BASE_CONFIG_MODEL = "Wan-AI/Wan2.1-T2V-14B" # 用于获取配置信息
|
| 49 |
|
| 50 |
# 质量增强提示词 - 适配视频
|
| 51 |
QUALITY_ENHANCERS = [
|
|
|
|
| 115 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 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 |
+
# 使用from_single_file方法加载NSFW检查点
|
| 122 |
try:
|
| 123 |
from diffusers import WanPipeline
|
| 124 |
+
pipeline = WanPipeline.from_single_file(
|
| 125 |
FIXED_MODEL,
|
| 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 WanPipeline.from_single_file()")
|
| 133 |
except ImportError:
|
| 134 |
# 如果WanPipeline不可用,使用通用DiffusionPipeline
|
| 135 |
+
print("⚠️ WanPipeline not found, trying DiffusionPipeline")
|
| 136 |
+
pipeline = DiffusionPipeline.from_single_file(
|
| 137 |
FIXED_MODEL,
|
| 138 |
+
config=BASE_CONFIG_MODEL, # 使用官方配置
|
| 139 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 140 |
+
use_safetensors=True,
|
| 141 |
+
safety_checker=None,
|
| 142 |
+
requires_safety_checker=False,
|
| 143 |
+
trust_remote_code=True
|
| 144 |
+
)
|
| 145 |
+
print("✅ Successfully loaded with DiffusionPipeline.from_single_file()")
|
| 146 |
+
except Exception as single_file_error:
|
| 147 |
+
# 最后备选:尝试直接从官方模型仓库加载(但这不是NSFW版本)
|
| 148 |
+
print(f"⚠️ Single file loading failed: {single_file_error}")
|
| 149 |
+
print("🔄 Falling back to official model repository...")
|
| 150 |
+
pipeline = DiffusionPipeline.from_pretrained(
|
| 151 |
+
BASE_CONFIG_MODEL,
|
| 152 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
|
|
|
| 153 |
use_safetensors=True,
|
| 154 |
safety_checker=None,
|
| 155 |
requires_safety_checker=False,
|
| 156 |
trust_remote_code=True
|
| 157 |
)
|
| 158 |
+
print("✅ Loaded official model as fallback")
|
| 159 |
|
| 160 |
pipeline = pipeline.to(device)
|
| 161 |
|
|
|
|
| 635 |
# 简化警告信息
|
| 636 |
gr.HTML('''
|
| 637 |
<div class="warning-box">
|
| 638 |
+
⚠️ 18+ CONTENT WARNING ⚠️ | T2V Model: NSFW_Wan_14b (wan_14B_e15.safetensors)
|
| 639 |
</div>
|
| 640 |
''')
|
| 641 |
|
|
|
|
| 863 |
# ===== 启动应用 =====
|
| 864 |
if __name__ == "__main__":
|
| 865 |
print("🎬 Starting NSFW Video Generator...")
|
| 866 |
+
print(f"🔧 NSFW Wan T2V Checkpoint: wan_14B_e15.safetensors")
|
| 867 |
+
print(f"🔧 Base Config Model: {BASE_CONFIG_MODEL}")
|
| 868 |
+
print("🔧 Using from_single_file() method for NSFW checkpoint")
|
| 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'}")
|