Skip to content

Commit 045ce40

Browse files
committed
feat: enhance AutoConfig to support path-based model configuration
1 parent 4bd845c commit 045ce40

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

cccv/arch/sr/dat_arch.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ def __init__(
365365
elif idx == 1:
366366
W_sp, H_sp = self.split_size[0], self.split_size[1]
367367
else:
368-
print("[CCCV] ERROR MODE", idx)
369-
exit(0)
368+
raise ValueError(f"[CCCV] ERROR MODE: invalid idx {idx}, expected 0 or 1")
370369
self.H_sp = H_sp
371370
self.W_sp = W_sp
372371

cccv/arch/sr/upcunet_arch.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ def forward(self, x, tile_mode, cache_mode, alpha, pro):
376376
t2 = tile_mode * 2
377377
crop_size = (((h0 - 1) // t2 * t2 + t2) // tile_mode, ((w0 - 1) // t2 * t2 + t2) // tile_mode)
378378
else:
379-
print("[CCCV] tile_mode config error")
380-
os._exit(233)
379+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
381380

382381
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
383382
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
@@ -526,8 +525,7 @@ def forward_gap_sync(self, x, tile_mode, alpha, pro):
526525
t2 = tile_mode * 2
527526
crop_size = (((h0 - 1) // t2 * t2 + t2) // tile_mode, ((w0 - 1) // t2 * t2 + t2) // tile_mode)
528527
else:
529-
print("[CCCV] tile_mode config error")
530-
os._exit(233)
528+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
531529
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
532530
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
533531
x = F.pad(x, (18, 18 + pw - w0, 18, 18 + ph - h0), "reflect")
@@ -767,8 +765,7 @@ def forward(self, x, tile_mode, cache_mode, alpha, pro):
767765
t4 = tile_mode * 4
768766
crop_size = (((h0 - 1) // t4 * t4 + t4) // tile_mode, ((w0 - 1) // t4 * t4 + t4) // tile_mode)
769767
else:
770-
print("[CCCV] tile_mode config error")
771-
os._exit(233)
768+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
772769
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
773770
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
774771
x = F.pad(x, (14, 14 + pw - w0, 14, 14 + ph - h0), "reflect")
@@ -916,8 +913,7 @@ def forward_gap_sync(self, x, tile_mode, alpha, pro):
916913
t4 = tile_mode * 4
917914
crop_size = (((h0 - 1) // t4 * t4 + t4) // tile_mode, ((w0 - 1) // t4 * t4 + t4) // tile_mode)
918915
else:
919-
print("[CCCV] tile_mode config error")
920-
os._exit(233)
916+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
921917
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
922918
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
923919
x = F.pad(x, (14, 14 + pw - w0, 14, 14 + ph - h0), "reflect")
@@ -1162,8 +1158,7 @@ def forward(self, x, tile_mode, cache_mode, alpha, pro):
11621158
t2 = tile_mode * 2
11631159
crop_size = (((h0 - 1) // t2 * t2 + t2) // tile_mode, ((w0 - 1) // t2 * t2 + t2) // tile_mode)
11641160
else:
1165-
print("[CCCV] tile_mode config error")
1166-
os._exit(233)
1161+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
11671162
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
11681163
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
11691164
x = F.pad(x, (19, 19 + pw - w0, 19, 19 + ph - h0), "reflect")
@@ -1323,8 +1318,7 @@ def forward_gap_sync(self, x, tile_mode, alpha, pro):
13231318
t2 = tile_mode * 2
13241319
crop_size = (((h0 - 1) // t2 * t2 + t2) // tile_mode, ((w0 - 1) // t2 * t2 + t2) // tile_mode) # 5.6G
13251320
else:
1326-
print("[CCCV] tile_mode config error")
1327-
os._exit(233)
1321+
raise ValueError("[CCCV] tile_mode config error: invalid tile_mode value")
13281322
ph = ((h0 - 1) // crop_size[0] + 1) * crop_size[0]
13291323
pw = ((w0 - 1) // crop_size[1] + 1) * crop_size[1]
13301324
x = F.pad(x, (19, 19 + pw - w0, 19, 19 + ph - h0), "reflect")

0 commit comments

Comments
 (0)