-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: category and export files by rank #143
Comments
Yes, this will be very useful. I spent a day ranking thousands of images and found it impossible to export them in bulk |
I've made a quick python script just for the time being. Then in the new folder, make a new python file "main.py" and paste the below: import sqlite3
from zipfile import ZipFile
from datetime import datetime
import os
MIN_RANK = 3
MAX_RANK = 4
CATEGORY = "txt2img-images" # txt2img-images, img2img-images, extras-images
def main():
connection = sqlite3.connect("wib.sqlite3")
cursor = connection.cursor()
results = cursor.execute(f"SELECT file, ranking FROM ranking WHERE ranking.ranking <= {MAX_RANK} AND ranking.ranking >= {MIN_RANK};")
results = results.fetchall()
to_be_ziped_images = []
print("Following images will be zipped: ")
counter = 1
for image in results:
if CATEGORY in str(image[0]):
print(f'{counter}: {image[0]}')
to_be_ziped_images.append(image[0])
counter = counter + 1
if len(to_be_ziped_images) > 0:
with ZipFile(f'bulk_extract_{datetime.now().strftime("%Y_%m_%d_%H_%M_%S")}.zip', 'w') as zip:
for image in to_be_ziped_images:
zip.write(filename=image, arcname=os.path.basename(image))
print('All images zipped successfully!')
else:
print("No images to be extracted")
if __name__ == "__main__":
main() Lastly, modify the variables (MIN_RANK, MAX_RANK, CATEGORY) to your needs. Then just run the script ("python main.py"), it will print the list of image that it found with your criteria, then a new zip file will be created with the images. Final notes, |
Since we have already done the function of manually adding rank tags, why not provide a way to classify and export them through rank (locally moving files may be sufficient, like six folder/zip, mapped each ranks).This feature may seem relatively simple, but I don't know how to organize/obtain rank information through wib.sqlite3——and the code is a bit heavy
BTW, I found that marking on the t2i interface and moving it to the save folder did not take effect. It doesn't seem like
https://github.com/tsngo/stable-diffusion-webui-aesthetic-image-scorer
is written in the file itself, but through the plugin's database. Should we include rank information when moving files?The text was updated successfully, but these errors were encountered: