Surae007 commited on
Commit
113f6ec
·
verified ·
1 Parent(s): b55114e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -24,11 +24,16 @@ except Exception:
24
  rembg_remove = None
25
 
26
  # face restore
 
 
27
  try:
28
- from gfpgan import GFPGANer
29
- _HAS_GFP = True
 
 
30
  except Exception:
31
- _HAS_GFP = False
 
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):