-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
162 lines (135 loc) · 5.57 KB
/
Copy pathsetup.py
File metadata and controls
162 lines (135 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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
161
162
#!/usr/bin/env python3
"""
COMI Upscaled — The Curse of the HD Monkey Island
A setup wizard and pipeline orchestrator for upscaling
The Curse of Monkey Island to 4K resolution.
Usage:
python setup.py # Full interactive wizard
python setup.py --mode full # Skip mode selection, start pipeline
python setup.py --config-only # Just configure, don't run
python setup.py --help # All options
"""
import os
import sys
import argparse
# Ensure we're in the project root
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from setup_wizard import ui, config, pipeline
def wizard_mode(cfg):
"""Interactive mode selection wizard."""
ui.title_screen()
ui.panel(
"Welcome, Pirate!",
"You are about to embark on a grand adventure:\n"
"upscaling The Curse of Monkey Island to glorious 4K.\n\n"
"Choose your path wisely, for the seas are treacherous\n"
"and the pixels are plentiful.",
)
# ── Mode ──
ui.section("Choose Your Mode")
ui.info("express → Download upscaled assets (fast, needs internet)")
ui.info("full → Extract + upscale from game files (slow, best quality)")
ui.info("bring-your-own → Supply your own HD assets (expert)")
mode = ui.ask("Your choice", default=cfg.get("mode", "express"))
if mode not in {"express", "full", "bring-your-own"}:
ui.warn(f"Unknown mode '{mode}', using express")
mode = "express"
cfg["mode"] = mode
# ── Game path ──
if mode != "express":
ui.section("Game Files")
path = cfg.get("game", {}).get("path", "")
if not path:
path = ui.ask("Path to your Monkey Island 3 folder")
if path:
cfg.setdefault("game", {})["path"] = path
# ── Alpha filter ──
ui.section("Alpha Mask Quality")
ui.info("Controls how sprite transparency edges look when upscaled:")
ui.info(" lanczos → Best anti-aliasing (recommended)")
ui.info(" bilinear → Good quality, faster")
ui.info(" nearest → No anti-aliasing, fastest (jagged edges)")
filt = ui.ask("Filter", default=cfg.get("alpha", {}).get("filter", "lanczos"))
if filt not in {"lanczos", "bilinear", "nearest"}:
filt = "lanczos"
cfg.setdefault("alpha", {})["filter"] = filt
# ── Upscale model ──
if mode == "full":
ui.section("Upscale Model")
ui.info("Available models for RealESRGAN:")
ui.info(" realesrgan-x4plus-anime → Best for hand-drawn art (default)")
ui.info(" realesrgan-x4plus → General photo upscale")
ui.info(" realesr-animevideov3 → Optimized for anime")
model = ui.ask("Model", default=cfg.get("upscale", {}).get("model", "realesrgan-x4plus-anime"))
cfg.setdefault("upscale", {})["model"] = model
# ── Summary ──
ui.section("Configuration")
ui.info(config.fmt(cfg))
if not ui.confirm("Looks good?", default=True):
ui.info("Run 'python setup.py' again to reconfigure.")
return False
config.save(cfg)
return True
def main():
ap = argparse.ArgumentParser(
description="COMI Upscaled — The Curse of the HD Monkey Island"
)
ap.add_argument("--mode", choices=["express", "full", "bring-your-own"],
help="Skip wizard, set mode directly")
ap.add_argument("--config-only", action="store_true",
help="Configure and save, but don't run the pipeline")
ap.add_argument("--game", help="Path to Monkey Island 3 game folder")
ap.add_argument("--alpha-filter", choices=["lanczos", "bilinear", "nearest"],
help="Alpha mask resize filter")
ap.add_argument("--model", help="RealESRGAN model name")
ap.add_argument("--gpu", default="auto", help="GPU device ID")
ap.add_argument("--version", action="store_true", help="Show version")
args = ap.parse_args()
# ── Version ──
if args.version:
import setup_wizard
print(f"COMI Upscaled v{setup_wizard.__version__}")
return
# ── Load config, apply CLI overrides ──
cfg = config.load()
if args.mode:
cfg["mode"] = args.mode
if args.game:
cfg["game"]["path"] = os.path.abspath(args.game)
if args.alpha_filter:
cfg["alpha"]["filter"] = args.alpha_filter
if args.model:
cfg["upscale"]["model"] = args.model
if args.gpu:
cfg["upscale"]["gpu"] = args.gpu
# ── Interactive wizard (if no --mode) ──
if not args.mode:
if not wizard_mode(cfg):
return
# ── Config-only ──
if args.config_only:
config.save(cfg)
ui.success("Configuration saved! Run 'python setup.py' to start the pipeline.")
return
# ── Run pipeline ──
warnings = config.validate(cfg)
if warnings:
for w in warnings:
ui.warn(w)
if not ui.confirm("Continue anyway?", default=False):
return
# Save before running
config.save(cfg)
try:
pipeline.run(cfg)
except KeyboardInterrupt:
ui.warn("\nPipeline interrupted by user.")
ui.info("Progress was saved where possible — you can resume.")
sys.exit(1)
except Exception as e:
ui.error(f"Pipeline failed: {e}")
ui.insult()
sys.exit(1)
if __name__ == "__main__":
main()