supli6669 commited on
Commit ·
da2865e
1
Parent(s): 4f3bc5f
CPU optimizations and UI defaults
Browse filesFiles changed (4)
217 unmodified lines218219220221222223224217 unmodified lines["retinaface_mobile0.25", "retinaface_resnet50", "YOLOv5l", "YOLOv5n"],help="MobileNet = extremely fast. RetinaFace = most accurate. YOLOv5 = fast.")upscale_factor = st.select_slider("Upscale Factor", [1, 2, 3, 4], value=2)bg_upscale_toggle = st.toggle("Real-ESRGAN Background Upscale", value=True)st.markdown("<div class='sidebar-section'>🔬 Post-Processing</div>", unsafe_allow_html=True)sharpen_amount = st.slider("Sharpness Boost", 0.0, 1.0, 0.0, 0.05,217 unmodified lines218219220221222223224217 unmodified lines["retinaface_mobile0.25", "retinaface_resnet50", "YOLOv5l", "YOLOv5n"],help="MobileNet = extremely fast. RetinaFace = most accurate. YOLOv5 = fast.")upscale_factor = st.select_slider("Upscale Factor", [1, 2, 3, 4], value=2)bg_upscale_toggle = st.toggle("Real-ESRGAN Background Upscale", value=False)st.markdown("<div class='sidebar-section'>🔬 Post-Processing</div>", unsafe_allow_html=True)sharpen_amount = st.slider("Sharpness Boost", 0.0, 1.0, 0.0, 0.05,
55 unmodified lines5657585960616234 unmodified lines97989910010110210355 unmodified lines- 30- 80latent_gt_path: nullnum_worker_per_gpu: 0batch_size_per_gpu: 1dataset_enlarge_ratio: 1prefetch_mode: cpu34 unmodified linesparam_key_g: params_emastrict_load_g: falsepretrain_network_d: nullresume_state: D:\.gemini-scratch\custom-ai-enhancer\models\CodeFormer\experiments\20260708_201102_CodeFormer_stage3_custom\training_states\1200.statetrain:use_hq_feat_loss: truefeat_loss_weight: 1.055 unmodified lines5657585960616234 unmodified lines97989910010110210355 unmodified lines- 30- 80latent_gt_path: nullnum_worker_per_gpu: 4batch_size_per_gpu: 1dataset_enlarge_ratio: 1prefetch_mode: cpu34 unmodified linesparam_key_g: params_emastrict_load_g: falsepretrain_network_d: nullresume_state: D:\.gemini-scratch\custom-ai-enhancer\models\CodeFormer\experiments\20260708_201102_CodeFormer_stage3_custom\training_states\1450.statetrain:use_hq_feat_loss: truefeat_loss_weight: 1.0
120 unmodified lines121122123124125126127120 unmodified linesort_outs = self.ort_session_cf.run(None, ort_inputs)return ort_outs[0]def process_image(self, img, w=0.5, detection_model='retinaface_resnet50', upscale=2, blend_softness=0.5, bg_upsampler=None, det_threshold=0.5, sharpen_amount=0.0, face_upsample=False, batch_size=0, parallel=False):"""Enhance an image using the local CodeFormer pipeline.120 unmodified lines121122123124125126127120 unmodified linesort_outs = self.ort_session_cf.run(None, ort_inputs)return ort_outs[0]def process_image(self, img, w=0.5, detection_model='retinaface_mobile0.25', upscale=2, blend_softness=0.5, bg_upsampler=None, det_threshold=0.5, sharpen_amount=0.0, face_upsample=False, batch_size=0, parallel=False):"""Enhance an image using the local CodeFormer pipeline.
34 unmodified lines3536373839404157 unmodified lines9910010110210310410510610710810911011111211311411534 unmodified linesupscale_factor=2,face_size=512,crop_ratio=(1, 1),det_model='retinaface_resnet50',save_ext='png',use_parse=True,device=pipeline.device57 unmodified linest1 = time.time()print(f"CodeFormer ONNX inference time (1 face): {t1 - t0:.4f}s")# 3. Real-ESRGAN Background Upscaling timingt0 = time.time()bg_img = pipeline.enhance_realesrgan_onnx(img, 2)t1 = time.time()print(f"Real-ESRGAN Background Upscaling time: {t1 - t0:.4f}s")# 4. Real-ESRGAN Face Upscaling timingt0 = time.time()face_up_re = pipeline.enhance_realesrgan_onnx(cropped_face, 2)t1 = time.time()print(f"Real-ESRGAN Face Upscaling time (512x512 -> 1024x1024): {t1 - t0:.4f}s")# 5. Lanczos Face Upscaling timingt0 = time.time()34 unmodified lines3536373839404157 unmodified lines9910010110210310410510610710810911011111211311411511611711811934 unmodified linesupscale_factor=2,face_size=512,crop_ratio=(1, 1),det_model='retinaface_mobile0.25',save_ext='png',use_parse=True,device=pipeline.device57 unmodified linest1 = time.time()print(f"CodeFormer ONNX inference time (1 face): {t1 - t0:.4f}s")# 3. Real-ESRGAN Background Upscaling timing (optional, disabled by default)run_re_bg = Falseif run_re_bg:t0 = time.time()bg_img = pipeline.enhance_realesrgan_onnx(img, 2)t1 = time.time()print(f"Real-ESRGAN Background Upscaling time: {t1 - t0:.4f}s")# 4. Real-ESRGAN Face Upscaling timing (optional, disabled by default)run_re_face = Falseif run_re_face:t0 = time.time()face_up_re = pipeline.enhance_realesrgan_onnx(cropped_face, 2)t1 = time.time()print(f"Real-ESRGAN Face Upscaling time (512x512 -> 1024x1024): {t1 - t0:.4f}s")# 5. Lanczos Face Upscaling timingt0 = time.time()
app.py+1-1
models/CodeFormer/options/CodeFormer_stage3_custom.yml+2-2
pipeline.py+1-1
tools/benchmark.py+15-11