liasece / sd-webui-train-tools

The stable diffusion webui training aid extension helps you quickly and visually train models such as Lora.
Other
393 stars 48 forks source link

Error in image preprocessing. Auto focal point crop is not work. #50

Closed 724791ce closed 8 months ago

724791ce commented 8 months ago

The following error statement appears and the task crashes when auto-crap is applied. All works well if auto crop is disabled.


 Train Tools: dataset update error OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\net_impl.cpp:279: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'cv::dnn::dnn4_v20230620::Net::Impl::getLayerData'
Traceback (most recent call last)
  File "C:\stable-diffusion-webui\extensions\sd-webui-train-tools\liasece_sd_webui_train_tools\dateset_ui.py", line 107, in on_ui_update_dataset_click
    preprocess.preprocess(None, origin_preload_data_path, processed_output_path,
  File "C:\stable-diffusion-webui\extensions\sd-webui-train-tools\liasece_sd_webui_train_tools\tools\preprocess.py", line 22, in preprocess
    preprocess_work(process_src, process_dst, process_width, process_height, preprocess_txt_action, process_keep_original_size, process_flip, process_split, process_caption, process_caption_deepbooru, split_threshold, overlap_ratio, process_focal_crop, process_focal_crop_face_weight, process_focal_crop_entropy_weight, process_focal_crop_edges_weight, process_focal_crop_debug, process_multicrop, process_multicrop_mindim, process_multicrop_maxdim, process_multicrop_minarea, process_multicrop_maxarea, process_multicrop_objective, process_multicrop_threshold)
  File "C:\stable-diffusion-webui\extensions\sd-webui-train-tools\liasece_sd_webui_train_tools\tools\preprocess.py", line 216, in preprocess_work
    for focal in autocrop.crop_image(img, autocrop_settings):
  File "C:\stable-diffusion-webui\modules\textual_inversion\autocrop.py", line 33, in crop_image
    focus = focal_point(im_debug, settings)
  File "C:\stable-diffusion-webui\modules\textual_inversion\autocrop.py", line 76, in focal_point
    face_points = image_face_points(im, settings) if settings.face_points_weight > 0 else []
  File "C:\stable-diffusion-webui\modules\textual_inversion\autocrop.py", line 151, in image_face_points
    faces = detector.detect(np.array(im))
cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\net_impl.cpp:279: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'cv::dnn::dnn4_v20230620::Net::Impl::getLayerData'

I found the following interesting statement regarding this issue. https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11727 This is the same problem as the above page, and I wonder if this is due to the open cv version upgrade (4.7 series→4.8 series) that came with the control net update. I have a log of open cv 4.8 in my PC that was upgraded on the day the problem occurred. But i dont know how to downgrade.

liasece commented 8 months ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11727#issuecomment-1739494210 worked?

724791ce commented 8 months ago

I did it. I tried the link procedure. Downgrading opencv from 4.8 to 4.7.0.72 in the venv used in webui. After that, everything worked out fine. Now that the issue is resolved, I'll close this place.