Spaces:
Running
Running
add pre_face_align option.
Browse files56 unmodified lines57585960616238 unmodified lines1011021031041051061071081091101112 unmodified lines114115116117118119151 unmodified lines2712722732742752765 unmodified lines28228328428528628728828929029129256 unmodified linestorch.hub.download_url_to_file('https://replicate.com/api/models/sczhou/codeformer/files/7cf19c2c-e0cf-4712-9af8-cf5bdbb8d0ee/012.jpg','05.jpg')def imread(img_path):img = cv2.imread(img_path)38 unmodified linesos.makedirs('output', exist_ok=True)def inference(image, background_enhance, face_upsample, upscale, codeformer_fidelity):"""Run a single prediction on the model"""try: # global try# take the default setting for the demohas_aligned = Falseonly_center_face = Falsedraw_box = Falsedetection_model = "retinaface_resnet50"2 unmodified linesbackground_enhance = background_enhance if background_enhance is not None else Trueface_upsample = face_upsample if face_upsample is not None else Trueupscale = upscale if (upscale is not None and upscale > 0) else 2img = cv2.imread(str(image), cv2.IMREAD_COLOR)print('\timage size:', img.shape)151 unmodified linesdemo = gr.Interface(inference, [gr.Image(type="filepath", label="Input"),gr.Checkbox(value=True, label="Background_Enhance"),gr.Checkbox(value=True, label="Face_Upsample"),gr.Number(value=2, label="Rescaling_Factor (up to 4)"),5 unmodified linesdescription=description,article=article,examples=[['01.png', True, True, 2, 0.7],['02.jpg', True, True, 2, 0.7],['03.jpg', True, True, 2, 0.7],['04.jpg', True, True, 2, 0.1],['05.jpg', True, True, 2, 0.1]])DEBUG = os.getenv('DEBUG') == '1'56 unmodified lines57585960616263646538 unmodified lines1041051061071081091101111121131142 unmodified lines117118119120121122123151 unmodified lines2752762772782792802815 unmodified lines28728828929029129229329429529629729856 unmodified linestorch.hub.download_url_to_file('https://replicate.com/api/models/sczhou/codeformer/files/7cf19c2c-e0cf-4712-9af8-cf5bdbb8d0ee/012.jpg','05.jpg')torch.hub.download_url_to_file('https://raw.githubusercontent.com/sczhou/CodeFormer/master/inputs/cropped_faces/0729.png','06.png')def imread(img_path):img = cv2.imread(img_path)38 unmodified linesos.makedirs('output', exist_ok=True)def inference(image, face_align, background_enhance, face_upsample, upscale, codeformer_fidelity):"""Run a single prediction on the model"""try: # global try# take the default setting for the demohas_aligned = not face_alignonly_center_face = Falsedraw_box = Falsedetection_model = "retinaface_resnet50"2 unmodified linesbackground_enhance = background_enhance if background_enhance is not None else Trueface_upsample = face_upsample if face_upsample is not None else Trueupscale = upscale if (upscale is not None and upscale > 0) else 2upscale = 1 if has_aligned else upscaleimg = cv2.imread(str(image), cv2.IMREAD_COLOR)print('\timage size:', img.shape)151 unmodified linesdemo = gr.Interface(inference, [gr.Image(type="filepath", label="Input"),gr.Checkbox(value=True, label="Pre_Face_Align"),gr.Checkbox(value=True, label="Background_Enhance"),gr.Checkbox(value=True, label="Face_Upsample"),gr.Number(value=2, label="Rescaling_Factor (up to 4)"),5 unmodified linesdescription=description,article=article,examples=[['01.png', True, True, True, 2, 0.7],['02.jpg', True, True, True, 2, 0.7],['03.jpg', True, True, True, 2, 0.7],['04.jpg', True, True, True, 2, 0.1],['05.jpg', True, True, True, 2, 0.1],['06.png', False, True, True, 1, 0.5]])DEBUG = os.getenv('DEBUG') == '1'
app.py+13-7