
This script is made for use with the Ruxx rule34 downloader!
I'll cut to the chase. This script separates the tags master file, that is generated when downloading images using Ruxx, into separate text files with the same names as the image files they correspond to. This is useful for getting extremely accurate tags for lora/model training without worrying about false-tags.
If any mp4 or GIF files are present in the folder, a (very unoptimized and time consuming) algorithm will separate it into unique frames and create duplicate tag files for each frame image, for easy use in training
Here is ChatGPT's step-by-step guide to using this script(based on me sending it the code):
-
Setup Environment:
-
Ensure Python is installed on your system.
-
Install the required Python packages:
os
,re
,cv2
,numpy
,imageio
,pathlib
, andconcurrent.futures
.
-
-
Place Script in Folder:
-
Save this script in a folder containing your media files (images, videos, GIFs).
-
-
Run the Script:
-
Open your terminal or command prompt.
-
Navigate to the folder containing the script.
-
Run the script by typing
python [script_name].py
, replacing[script_name]
with the name of your script file.
-
-
Script Execution:
-
The script automatically processes GIF files in the folder, converting them to MP4 format.
-
It then finds and processes video files (formats like
.mp4
,.avi
,.mkv
), extracting certain frames based on defined criteria (like sharpness and changes between frames). -
The script searches for a specific text file (tag file) and processes it by extracting and reformatting content based on regular expressions.
-
-
Function Details:
-
find_image_with_rx_value(rx_value)
: Finds images with a specific naming pattern. -
extract_frames_with_ffmpeg(video_path, skip_frames, downsample_factor)
: Extracts and saves frames from video files based on sharpness and difference from previous frames. -
process_and_delete_video(video_filename)
: Processes a video file and then deletes it. -
separate_and_delete_text_file(input_filename)
: Processes a text file for tags, links them with corresponding images, creates new text files, and then deletes the original. -
convert_gif_to_mp4(gif_path)
: Converts a GIF file to an MP4 format. -
process_and_delete_gifs()
: Processes all GIF files in the folder, converting them to MP4 and then deleting the original GIFs. -
auto_detect_tags_file()
: Automatically detects a specific tags text file in the directory.
-
-
Output:
-
The script generates new files (like extracted frames from videos, converted MP4s from GIFs, and new tag text files) in the same directory.
-
Original video and GIF files are deleted after processing.
-
描述:
First version
训练词语:
名称: ruxxTagCompanionScript_v10.zip
大小 (KB): 2
类型: Archive
Pickle 扫描结果: Success
Pickle 扫描信息: No Pickle imports
病毒扫描结果: Success