Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files144 unmodified lines14514614714814915015115215315415526 unmodified lines182183184185186187188189190135 unmodified lines3263273283293303313326 unmodified lines339340341342343344345144 unmodified linesupscale = 4if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolutionupscale = 2if max(img.shape[:2]) > 1500: # avoid memory exceeded due to too large img resolutionupscale = 1background_enhance = Falseface_upsample = Falseface_helper = FaceRestoreHelper(upscale,face_size=512,26 unmodified linesif min(img.shape[:2]) > 1000 and num_det_faces > 15:raise gr.Error("Too many faces detected (>15) in a high-resolution image. ""To keep the demo responsive, this case is skipped. ""For such inputs, please deploy the demo locally without this limit.")# face restoration for each cropped facefor idx, cropped_face in enumerate(face_helper.cropped_faces):135 unmodified linesgr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')], [gr.Image(type="filepath", label="Output"),gr.Markdown("Please download the output within 30 seconds.")],title=title,description=description,6 unmodified lines['05.jpg', True, True, True, 2, 0.1],['06.png', False, True, True, 1, 0.5]],concurrency_limit=1)DEBUG = os.getenv('DEBUG') == '1'144 unmodified lines14514614714814915015115215315415515615715815916026 unmodified lines187188189190191192193194195196135 unmodified lines3323333343353363373386 unmodified lines345346347348349350351144 unmodified linesupscale = 4if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolutionupscale = 2if min(img.shape[:2]) > 1100 or max(img.shape[:2]) > 1500: # avoid memory exceeded due to too large img resolution# upscale = 1# background_enhance = False# face_upsample = Falseraise gr.Error("Image resolution is too large (short side > 1100 or long side > 1500). ""To keep the demo responsive and avoid long queue times, this case is skipped. ""For such inputs, please deploy this demo locally and remove this limit.")face_helper = FaceRestoreHelper(upscale,face_size=512,26 unmodified linesif min(img.shape[:2]) > 1000 and num_det_faces > 15:raise gr.Error("Too many faces detected (>15) in a high-resolution image. ""To keep the demo responsive and avoid long queue times, this case is skipped. ""For such inputs, please deploy this demo locally and remove this limit.")# face restoration for each cropped facefor idx, cropped_face in enumerate(face_helper.cropped_faces):135 unmodified linesgr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')], [gr.Image(type="filepath", label="Output"),gr.Markdown("**Please download the output within 30 seconds.**")],title=title,description=description,6 unmodified lines['05.jpg', True, True, True, 2, 0.1],['06.png', False, True, True, 1, 0.5]],concurrency_limit=2)DEBUG = os.getenv('DEBUG') == '1'
app.py+15-9