90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
|
|
import asyncio
|
|
import os
|
|
import sys
|
|
import json
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
# Mock settings and imports
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Mock database and models to avoid dependency issues
|
|
sys.modules['app.database'] = MagicMock()
|
|
sys.modules['app.models.job'] = MagicMock()
|
|
sys.modules['app.models.asset'] = MagicMock()
|
|
|
|
# Import services after mocking
|
|
from app.services.video_upscaler import VIDEO_MODELS
|
|
# Image upscaler we can import 'upscale' or just check models
|
|
from app.services.image_upscaler import TOPAZ_MODELS
|
|
|
|
async def debug_topaz_video_payload():
|
|
print("--- Debugging Topaz Video Payload ---")
|
|
|
|
# Simulate user inputs
|
|
model_name = "Proteus"
|
|
model_code = VIDEO_MODELS.get(model_name, "prob-4")
|
|
|
|
params = {
|
|
"sharpening": 50,
|
|
"recover_detail": 20,
|
|
"add_noise": 10,
|
|
"video_type": "Progressive"
|
|
}
|
|
|
|
# REPLICATED LOGIC FROM video_upscaler.py
|
|
# ---------------------------------------
|
|
enhance_filter_payload = {
|
|
"model": model_code,
|
|
"videoType": params["video_type"].lower(),
|
|
}
|
|
|
|
if params["sharpening"] is not None:
|
|
enhance_filter_payload["details"] = int(params["sharpening"])
|
|
if params["recover_detail"] is not None:
|
|
enhance_filter_payload["recoverOriginalDetailValue"] = int(params["recover_detail"])
|
|
if params["add_noise"] is not None:
|
|
enhance_filter_payload["noise"] = int(params["add_noise"])
|
|
|
|
# Full payload simulation
|
|
filters = []
|
|
filters.append(enhance_filter_payload)
|
|
|
|
payload = {
|
|
"source": {"container": "mp4", "duration": 10}, # Mock source
|
|
"filters": filters,
|
|
"output": {
|
|
"resolution": {"width": 3840, "height": 2160},
|
|
"frameRate": 30,
|
|
"container": "mp4"
|
|
}
|
|
}
|
|
# ---------------------------------------
|
|
|
|
print(f"Generated Video Payload: {json.dumps(payload, indent=2)}")
|
|
|
|
# Validation
|
|
if "sharpen" in enhance_filter_payload:
|
|
print("FAIL: 'sharpen' key found (forbidden)")
|
|
if "recoverDetail" in enhance_filter_payload:
|
|
print("FAIL: 'recoverDetail' key found (forbidden)")
|
|
if enhance_filter_payload["videoType"] != "progressive":
|
|
print(f"FAIL: videoType not lowercase: {enhance_filter_payload['videoType']}")
|
|
|
|
print("---------------------------------------")
|
|
|
|
async def debug_topaz_image_setup():
|
|
print("--- Debugging Topaz Image Setup ---")
|
|
|
|
try:
|
|
import PIL
|
|
print("Pillow (PIL) is installed.")
|
|
except ImportError:
|
|
print("FAIL: Pillow (PIL) is NOT installed. This will cause 'Failed to start' errors.")
|
|
|
|
print(f"Loaded {len(TOPAZ_MODELS)} Topaz Image models.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(debug_topaz_video_payload())
|
|
asyncio.run(debug_topaz_image_setup())
|