Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,11 +24,16 @@ except Exception:
|
|
| 24 |
rembg_remove = None
|
| 25 |
|
| 26 |
# face restore
|
|
|
|
|
|
|
| 27 |
try:
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
except Exception:
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
# realesrgan (fallback upscaler)
|
| 34 |
try:
|
|
@@ -105,7 +110,6 @@ SCHEDULERS = {
|
|
| 105 |
PIPE_CACHE: Dict[str, object] = {}
|
| 106 |
CONTROL_CACHE: Dict[str, ControlNetModel] = {}
|
| 107 |
UPSCALE_PIPE: Optional[StableDiffusionUpscalePipeline] = None
|
| 108 |
-
GFP: Optional[GFPGANer] = None
|
| 109 |
REALSR: Optional[RealESRGAN] = None
|
| 110 |
|
| 111 |
def set_sched(pipe, name: str):
|
|
|
|
| 24 |
rembg_remove = None
|
| 25 |
|
| 26 |
# face restore
|
| 27 |
+
# ---- Optional face restore (safe import) ----
|
| 28 |
+
_HAS_GFP = False
|
| 29 |
try:
|
| 30 |
+
import gfpgan
|
| 31 |
+
if hasattr(gfpgan, "GFPGANer"):
|
| 32 |
+
GFPGANer = gfpgan.GFPGANer # type: ignore
|
| 33 |
+
_HAS_GFP = True
|
| 34 |
except Exception:
|
| 35 |
+
GFPGANer = None # type: ignore
|
| 36 |
+
GFP = None
|
| 37 |
|
| 38 |
# realesrgan (fallback upscaler)
|
| 39 |
try:
|
|
|
|
| 110 |
PIPE_CACHE: Dict[str, object] = {}
|
| 111 |
CONTROL_CACHE: Dict[str, ControlNetModel] = {}
|
| 112 |
UPSCALE_PIPE: Optional[StableDiffusionUpscalePipeline] = None
|
|
|
|
| 113 |
REALSR: Optional[RealESRGAN] = None
|
| 114 |
|
| 115 |
def set_sched(pipe, name: str):
|