sczhou commited on
Commit
cfcc9cd
·
verified ·
1 Parent(s): 2588300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -112,7 +112,7 @@ def inference(image, face_align, background_enhance, face_upsample, upscale, cod
112
  draw_box = False
113
  detection_model = "retinaface_resnet50"
114
 
115
- print('Inp:', image, background_enhance, face_upsample, upscale, codeformer_fidelity)
116
  face_align = face_align if face_align is not None else True
117
  background_enhance = background_enhance if background_enhance is not None else True
118
  face_upsample = face_upsample if face_upsample is not None else True
@@ -121,8 +121,12 @@ def inference(image, face_align, background_enhance, face_upsample, upscale, cod
121
  has_aligned = not face_align
122
  upscale = 1 if has_aligned else upscale
123
 
124
- img = cv2.imread(str(image), cv2.IMREAD_COLOR)
125
- print('\timage size:', img.shape)
 
 
 
 
126
 
127
  upscale = int(upscale) # convert type to int
128
  if upscale > 4: # avoid memory exceeded due to too large upscale
@@ -280,7 +284,7 @@ td {
280
 
281
  demo = gr.Interface(
282
  inference, [
283
- gr.Image(type="filepath", label="Input"),
284
  gr.Checkbox(value=True, label="Pre_Face_Align"),
285
  gr.Checkbox(value=True, label="Background_Enhance"),
286
  gr.Checkbox(value=True, label="Face_Upsample"),
 
112
  draw_box = False
113
  detection_model = "retinaface_resnet50"
114
 
115
+ print('Inp:', image.shape, background_enhance, face_upsample, upscale, codeformer_fidelity)
116
  face_align = face_align if face_align is not None else True
117
  background_enhance = background_enhance if background_enhance is not None else True
118
  face_upsample = face_upsample if face_upsample is not None else True
 
121
  has_aligned = not face_align
122
  upscale = 1 if has_aligned else upscale
123
 
124
+ img = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
125
+
126
+ if img is None:
127
+ raise ValueError(f"Failed to read image from {image_path}")
128
+
129
+ # print('\timage size:', img.shape)
130
 
131
  upscale = int(upscale) # convert type to int
132
  if upscale > 4: # avoid memory exceeded due to too large upscale
 
284
 
285
  demo = gr.Interface(
286
  inference, [
287
+ gr.Image(type="numpy", label="Input"),
288
  gr.Checkbox(value=True, label="Pre_Face_Align"),
289
  gr.Checkbox(value=True, label="Background_Enhance"),
290
  gr.Checkbox(value=True, label="Face_Upsample"),