KichangKim / DeepDanbooru

AI based multi-label girl image classification system, implemented by using TensorFlow.
MIT License
2.65k stars 260 forks source link

Where the neural network stores information about the tags? #11

Closed libid0nes closed 4 years ago

libid0nes commented 4 years ago

Hi, I have a question, what are json files used for in image folders, and why does a neural network need a database?

And also why these files are needed: tags.txt; tags-character.txt; tags-general.txt

I ask because I downloaded 150K images from sankaku, and 40K from rule34 (All images from the same anime universe). I'm going to combine them, but the problem is that their tags are different (mostly character names).

I want to bring all the tags to the same type, and I need to know which files to make corrections using the script.

Should I change the values only in the sqlite database? or I need to change the tags values as: tags.txt; tags-character.txt; tags-general.text? Or do I even include thousands of json files?

KichangKim commented 4 years ago

Json files in images folder are used for debugging purpose. It does not need to training. (also tags-xxx.txt are used for debugging too.)

Essential files are these: Image files in images folder, database sqlite file, tags.txt. Training data is loaded from images folder and database sqlite file, then model's output dimension is calculated by using tags.txt.

So if you want to merge multiple databases into single one, you should modify both database.sqlite and tags.txt.

libid0nes commented 4 years ago

Thank you for your detailed answer, I have new questions.

What happens if the tag that is specified in the database record is not present in the tags file.txt?

Speaking of dimension, I'm training a model for tagging on a specific anime universe (naruto), the total number of images will be no more than 200k. And the number of tags in them, about 60 for characters and 1000-3000 for General tags.

That is, in fact, in a project for 200k images can contain 1000-3500 unique tags, while in the file: tags.txt, unique tags will be more than 100k. Will this not affect the training or performance?

It might be better if I write a script that generates tags.txt only from those tags that are in the database? Or am I worrying for nothing?

KichangKim commented 4 years ago

If the output dimension increase, memory usage will be high and you need more memory and training time.

The best case is that tags.txt has only tags which you want to estimate. In ex, if you want to tag only characters, tags.txt have to contain only that character tags.

If the tag is not present in tags.txt, it will be simply ignored and do not affect training performance.