Home Artists Posts Import Register

Downloads

Content

Patreon exclusive posts index

Join discord and tell me your discord username to get a special rank : SECourses Discord

12 January 2024 Update

25 November 2023 Update

  • Resizer updated to 25_Nov_2023_resizer

16 November 2023 Update:

  • Face resizer will extract only faces.
  • Resize is optional

13 November 2023 Huge Update:

  • Re-download resize_images_v4 .zip file
  • Do a fresh install into a new folder - so GPU support will be enabled
  • Now supports GPU as well. GPU is like 3x faster than 13900K CPU
  • Save as PNG option added as a boolean parameter. Default set to False

30 October 2023 Huge Update:

  • Full new tutorial video > https://youtu.be/Fbuyu35TkE4
  • Please also upvote this Reddit Thread if possible
  • Yolo v7 based cropper script updated and now works much better.
  • The improvement of cropping quality is huge.
  • All of the shared classification / regularization datasets will be also hopefully updated

12 September 2023 Update - Important

It turns out that previously used face detection algorithm in resizer V2 was not good enough.

Updated script to V3. Now we will use RetinaFace library.

Download resize_images_v4 .zip and use it for best quality. It is slower than V2 script but much more accurate to focus faces.

Let me know if you encounter any problem and hopefully I will fix it ASAP. Please read very carefully.

I have updated my previous subject cropper script to Yolo V7 with improved logic. I had explained that script in this video : https://youtu.be/QTYX0tgA5ho

Also I was using Automatic1111 image preprocessing script to resize images into the desired resolution with face focus. However it is broken and not working correctly. Therefore I have written my State Of The Art (SOTA) image resizer script as well.

I used these scripts to process all of the images shared in this amazing regularazation / classification images dataset > https://www.patreon.com/posts/massive-4k-woman-87700469

Hopefully I will make a video to how to use these 2 new scripts. They are pretty easy actually.

How To Use Subject Cropper

Click here to 12_Jan_2024_auto_cropper Zip File. 281 MB and includes necessary model file as well.

It includes install and run . bat files. Install . bat file will make new venv and install everything for you. This won't affect your other installations like Automatic1111.

Then edit cropper_v7 . py and change INPUT_FOLDER & OUTPUT_FOLDER and set your desired ASPECT_RATIOS. This script will crop the subject with maximum resolution while trying to keep desired aspect ratio. It won't crop the parts of the subject. So aspect ratio may not be 100% correct. We will use resizer script to make them perfect size and aspect ratio.

Yolo V7 supports different classes as well. So you can change person into different classes you wish.

names: ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
       'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
       'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
       'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
       'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
       'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
       'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
       'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
       'hair drier', 'toothbrush']

How To Use SOTA Image Resizer - Downscaler

Download attached  . It includes install and run . bat files. Install . bat file will make new venv and install everything for you. This won't affect your other installations like Automatic1111.

Edit resizer_v4. py file and change folder paths and resolutions that you are looking for. This script will crop the image with focus of a person face if that exists. This is an amazing script to prepare different resolution training images datasets.

This script also uses best downscaling algorithm and save images with best quality. Also the script supports fully multi-threading. It is set to 2 threads. If your CPU is better increase it to like 10.

Comments

EnjoyerOfAll

This is good stuff. Thank you!!!!

Furkan Gözükara

thank you so much. hopefully i am going to update resizer with even a better version today. stay following

mike oxmaul

Ensure to keep the [ ] around the aspect ratio numbers. ASPECT_RATIOS = [(512, 512)] I was getting errors as I had removed it for some reason.

mike oxmaul

For SDXL training I changed the resize2.py to this: # Constants DATA = [ ((1024, 1024), r"C:\source\photo\folder"), ] OUTPUT_ROOT = r"C:\destination\photo\folder\1024" # Root folder to save resized images

mike oxmaul

Also, if you need unsplash images - you can use this tool to download them in bulk easily. https://www.wfdownloader.xyz/download

Anonymous

Hello, I am receiving the following error when running the resizer.bat. I removed the resizer folder and re-ran the installer.bat twice but I receive the same error. Any ideas? Here is the code I changed in the resizer.py file: # Constants DATA = [ ((512, 512), r"C:\Users\(my username)\Documents\WALLPAPERS\output\512x512") ] NUM_THREADS = 10 # Modify this for the desired number of threads OUTPUT_ROOT = r"C:\Users\(my username)\Documents\WALLPAPERS\1" # Root folder to save resized images concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "C:\Python31011\lib\concurrent\futures\process.py", line 246, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) File "C:\Python31011\lib\concurrent\futures\process.py", line 205, in _process_chunk return [fn(*args) for args in chunk] File "C:\Python31011\lib\concurrent\futures\process.py", line 205, in return [fn(*args) for args in chunk] File "C:\Resizer\resizer_v3.py", line 23, in resize_image faces = RetinaFace.detect_faces(input_path) File "C:\Resizer\venv\lib\site-packages\retinaface\RetinaFace.py", line 68, in detect_faces model = build_model() File "C:\Resizer\venv\lib\site-packages\retinaface\RetinaFace.py", line 34, in build_model retinaface_model.build_model(), File "C:\Resizer\venv\lib\site-packages\retinaface\model\retinaface_model.py", line 679, in build_model model = load_weights(model) File "C:\Resizer\venv\lib\site-packages\retinaface\model\retinaface_model.py", line 49, in load_weights model.load_weights(exact_file) File "C:\Resizer\venv\lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "C:\Resizer\venv\lib\site-packages\h5py\_hl\group.py", line 357, in __getitem__ oid = h5o.open(self.id, self._e(name), lapl=self._lapl) File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py\h5o.pyx", line 189, in h5py.h5o.open KeyError: 'Unable to synchronously open object (free block size is zero?)' """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Resizer\resizer_v3.py", line 84, in process_folder(folder, resolution) File "C:\Resizer\resizer_v3.py", line 78, in process_folder for _ in executor.map(resize_image, [(path, resolution, OUTPUT_ROOT) for path in image_paths]): File "C:\Python31011\lib\concurrent\futures\process.py", line 575, in _chain_from_iterable_of_lists for element in iterable: File "C:\Python31011\lib\concurrent\futures\_base.py", line 621, in result_iterator yield _result_or_cancel(fs.pop()) File "C:\Python31011\lib\concurrent\futures\_base.py", line 319, in _result_or_cancel return fut.result(timeout) File "C:\Python31011\lib\concurrent\futures\_base.py", line 458, in result return self.__get_result() File "C:\Python31011\lib\concurrent\futures\_base.py", line 403, in __get_result raise self._exception KeyError: 'Unable to synchronously open object (free block size is zero?)' Press any key to continue . . .

Anonymous

I found a work-around, I had to navigate to the following location under win10 (C:\Users\username\.deepface\weights\) and delete the retinaface.h5 file and all the other retina tmp files. Reran the script which re-downloaded the retina file and processed the images. I recived the same above error on my other win10 pc and just followed the above workaround.

Anonymous

It was. The resize still throws the error but I just moved the processed images to another folder. I then remove the retina face files and re-run the script.

Anonymous

Have a question: if i have image with relatively low res. e.g 720x1280 or 970x970, do you think it is a good idea to upscale it at least 2x before prepairing it to corpp/resise and learning? Becase there gonna be some artifacts from upscailing and while lerning process that artifacts gonna be piced up by network during learning process.

Furkan Gözükara

i find that upscaling is a no no. i would try to get better images. the model tends to learn those unnatural things so precisely :/ like fake background or upscale

Hassan Alhassan

for some reason the cropping is working fine but resizing isnt, have any faced this issue ?

Anonymous

I also have a question: is there an easy way to crop just the face with your script. I want to use it to prepare my Training-data.

Meito

getting this issue with the new one don't forget to run install bat and make sure that you have changed the paths in resizer_v3.py file moreover set your thread count according to your CPU C:\Users\PC\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\\Users\\PC\\Documents\\resize_images_v4\\resizer_v3.py': [Errno 2] No such file or directory

Meito

fixed it changed the bat file to have v4, it had v3 on it

Andre Bopp

Thanks for the amazing work :-) Sadly, ive encountered an error in the cropper: Processed 32/224 images. Remaining: 192. Average processing speed: 1009.74 ms/image An error occurred while processing atikh-bana-zPFws4toKhg-unsplash.jpg: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'rectangle' > Overload resolution failed: > - img marked as output argument, but provided NumPy array marked as readonly > - Expected Ptr for argument 'img' > - argument for rectangle() given by name ('thickness') and position (4) > - argument for rectangle() given by name ('thickness') and position (4) The images are getting cropped, so thats not the issue. But the error is still bothering me. Does anyone encounter the same error?

Furkan Gözükara

hello. this video explains the logic have you seen it? https://youtu.be/Fbuyu35TkE4 if there is nothing to crop it wont. then you will use resizer