Giter Site home page Giter Site logo

expl0dingcat / danbooru-tag-formatter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 22 KB

Automatically format and pull tags from danbooru for use with Stable Diffusion models.

License: GNU General Public License v3.0

Python 100.00%
danbooru formatter tagging

danbooru-tag-formatter's Introduction

Danbooru Tag Formatter

Automatically format tags for use with Stable Diffusion models.

This is a Python script that formats tags from various inputs for use with Stable Diffusion models. The script can accept either a danbooru post URL, a file containing tags, or unformatted tags themselves.

If given a URL, the script uses the pybooru library to extract the tags associated with the post. It then formats the tags by replacing underscores with spaces and adding commas between tags.

If given a file, the script reads through each line of the file and formats the tags in the same way as for URLs. If the file contains additional URLs or file paths, the script will also recursively process them.

Usage: tag_formatter.py <input>

Examples

URL

Command

python tag_formatter.py https://danbooru.donmai.us/posts/6087730

Output

Detected as a URL: https://danbooru.donmai.us/posts/6087730
Post ID: 6087730
Formatted tags: 1boy, absurdres, arm behind back, chinese clothes, dress, fire, flower, glowing, hanfu, highres, hua cheng, long hair, looking at another, mumuda13531, red flower, red rose, rose, smoke, string, string of fate, tian guan ci fu, wedding dress, xie lian

Unformatted tags

Command

python tag_formatter.py "1girl bangs belt_collar blue_bow blue_eyes blue_ribbon bow collar dress flower frilled_dress frills hair_flower hair_ornament happy_birthday horns long_hair long_sleeves looking_at_viewer magic pink_flower pink_ribbon ribbon sheep_horns smile solo white_dress white_hair white_headdress"

Output

Tags detected: 1girl bangs belt_collar blue_bow blue_eyes blue_ribbon bow collar dress flower frilled_dress frills hai...
Formatted tags: 1girl, bangs, belt collar, blue bow, blue eyes, blue ribbon, bow, collar, dress, flower, frilled dress, frills, hair flower, hair ornament, happy birthday, horns, long hair, long sleeves, looking at viewer, magic, pink flower, pink ribbon, ribbon, sheep horns, smile, solo, white dress, white hair, white headdress

3 Nested files

Command

python tag_formatter.py C:\Users\admin\Documents\tag_formatter_test\test_input.txt

Output

[BASE FILE] (test_input.txt) Detected as a URL: https://danbooru.donmai.us/posts/6087459
[BASE FILE] (test_input.txt) Post ID: 6087459
[BASE FILE] (test_input.txt) Nested file detected: C:\Users\admin\Documents\tag_formatter_test\test_input_2.txt
[NESTED FILE] (test_input_2.txt) Detected as a URL: https://danbooru.donmai.us/posts/6087739
[NESTED FILE] (test_input_2.txt) Post ID: 6087739
[NESTED FILE] (test_input_2.txt) Nested file detected: C:\Users\admin\Documents\tag_formatter_test\test_input_3.txt
[NESTED FILE] (test_input_3.txt) Tags detected: rokugou_daisuke touhou goutokuji_mike 1girl animal_ears barefoot bell blush cat_ears cat_tail closed_ey...
[NESTED FILE] (test_input_3.txt) Formatted tags saved to: C:\Users\admin\Documents\tag_formatter_test\test_input_3_formatted.txt
[NESTED FILE] (test_input_2.txt) Formatted tags saved to: C:\Users\admin\Documents\tag_formatter_test\test_input_2_formatted.txt
[BASE FILE] (test_input.txt) Tags detected: reitou_mkn hololive nekomata_okayu onigirya_(nekomata_okayu) absurdres commentary_request highres 1girl...
[BASE FILE] (test_input.txt) Formatted tags saved to: C:\Users\admin\Documents\tag_formatter_test\test_input_formatted.txt

Credits

danbooru-tag-formatter's People

Contributors

expl0dingcat avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.