Code Monkey home page Code Monkey logo

Comments (17)

KichangKim avatar KichangKim commented on June 10, 2024

Hi. This is my toy project, so I don't have any plan to accept donation now (at least).

  1. Does DeepDanbooru also works on real people?

Yes. DeepDanbooru is based on reset network, originally developed for photo-real image classification. But you need to train with real photos.

  1. Do I need to prepare images set doesn't contains black pantyhose?

Yes. You must prepare positive/negative samples for training. But does not need for tagging "No BlackPantyhose". You can simply feed non-blackpantyhose images without "BlackPantyhose" tag. Then AI will estimate blackpantyhose scores as 0.0 (no blackpantyhose) ~ 1.0 (totally blackpantyhose).

3.How many images I need to prepare?

There is no rules for that. But if you prepare as many as images, your AI estimates more accurately. I recommend preparing at least thousands of images. If you can't, use image augmentation technique (using single image with multiple variation, like rotation, translation, resizing, adding noise and so on).

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

Thanks! That really helps!
Sadly you don't accept donation, this repo really help me, you deserve some donation.

I got an off-topic idea suddenly.
I need to convert a non-blackpantyhose image to a blackpantyhose image, which is use AI to wearing black pantyhose for girls.
Is that possible for AI?
Is there any existing algorithm or model can do this?

from deepdanbooru.

yozhikoff avatar yozhikoff commented on June 10, 2024

Pardon the interruption, I just wanted to add that in many cases DeepDanbooru works surprisingly well on real-world images - not perfect, of course, but much better than I expected it to work on a previously unseen data domain. It seems the generalization has done its trick.

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

After some practice, I got some new questions.

1. How should I deal with categories.json tags-character.txt tags-general.txt tags_log.json?
After executing deepdanbooru download-tags [your_project_folder], those files are generated, should I create those files too?
Or I just need to create a file named tags.txt, and it contains only one line "BlackPantyhose", and that's all, I don't need to create above files?

2.How should I set "tag_count_general" in SQLite database file?
That said, I have 2 images
One contains black pantyhose named f4c902c9ae5a2a9d8f84868ad064e706.jpg
Another doesn't contains black pantyhose named 28406bef86a21228683f140f3317d194.jpg

id md5 file_ext tag_string tag_count_general
1 f4c902c9ae5a2a9d8f84868ad064e706 jpg BlackPantyhose 1
2 28406bef86a21228683f140f3317d194 jpg 0

Is this correct?
Has BlackPantyhose tag, set tag_count_general to 1
Hasn't BlackPantyhose tag, set tag_count_general to 0

3.How should I set "minimum_tag_count" in project.json?

tag_count_general is used for the project setting, minimum_tag_count. Images which has equal or larger value of tag_count_general are used for training.

According to this, I want BlackPantyhose and non-BlackPantyhose all used for training, so I need to set it to 0?

from deepdanbooru.

KichangKim avatar KichangKim commented on June 10, 2024
  1. How should I deal with categories.json tags-character.txt tags-general.txt tags_log.json?

You only need tags.txt for training. categories.json is used for web-interface (not included this repository). Other tags-xxx variations are generated for debugging.

2.How should I set "tag_count_general" in SQLite database file?
3.How should I set "minimum_tag_count" in project.json?

Yes. DeepDanbooru filters input data by using tag_count_general field, so if you set it to 1, you should modify minimum_tag_count in project.json too.

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024
MyDataset/
├── images/
│   ├── 00/
│   │   ├── 00000000000000000000000000000000.jpg
│   │   ├── ...
│   ├── 01/
│   │   ├── ...
│   └── ff/
│       ├── ...
└── my-dataset.sqlite

There are many sub folders in images folder, 00,01,ff, why?
Too many files in same folder may cause file explorer crash?
So split images to multi folder?
Is it ok to move an image from 00 to 01? Will that cause any problem?

from deepdanbooru.

KichangKim avatar KichangKim commented on June 10, 2024

Yes, too many files in single folder makes difficult to explore it. It is totally fine that all of images in single 00 folder if your images are not too much.

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

Total images:17581
Black Pantyhose images:6184
Non Black Pantyhose images:11397

Model has been train for half day in a RTX 3090. Now I got some new questions.

1.How you consider trainning is finished?

You said you finish trainning after a month, but if I use default project.json, trainning will be finish in 10 minutes, and the model generated is useless, it consider every image contains black pantyhose even there is not.
After I change "epoch_count" in project.json to a big number, trainning can keep running.
But when will it give me a good result? I have no idea.

2.What model and optimizer I should use?

Default model is v2, default optimizer is Adam, but in the model you realease, model is v4, optimizer is sgd.
which one is better in my case?

3.How can I adjust checkpoint saving interval without modify code?

By default, it take 10 seconds to finish an epoch, but only 2 seconds is for trainning, others 8 seconds is for saving checkpoint, that really slow trainning effective, so I want to slow down saving.

4.How do I know model is getting better?

Shuffling samples (epoch 26863) ...
Trying to change learning rate to 0.001 ...
Learning rate is changed to <tf.Variable 'learning_rate:0' shape=() dtype=float32, numpy=0.001> ...
Epoch[26863] Loss=0.000171, P=1.000000, R=1.000000, F1=1.000000, Speed = 18.9 samples/s, 0.01 %, ETA = 2051-01-08 19:43:41
Shuffling samples (epoch 26864) ...
Trying to change learning rate to 0.001 ...
Learning rate is changed to <tf.Variable 'learning_rate:0' shape=() dtype=float32, numpy=0.001> ...
Shuffling samples (epoch 26865) ...
Trying to change learning rate to 0.001 ...
Learning rate is changed to <tf.Variable 'learning_rate:0' shape=() dtype=float32, numpy=0.001> ...
Shuffling samples (epoch 26866) ...
Trying to change learning rate to 0.001 ...
Learning rate is changed to <tf.Variable 'learning_rate:0' shape=() dtype=float32, numpy=0.001> ...
Epoch[26866] Loss=0.000428, P=1.000000, R=1.000000, F1=1.000000, Speed = 23.0 samples/s, 0.01 %, ETA = 2045-10-24 13:20:11
Shuffling samples (epoch 26867) ...

Right now it's already Epoch 26867, loss is lesser than 0.001
But the predict result is pretty bad.
In predictions of 6184 Black Pantyhose Images: 2498 images score > 0.5, 3686 images score < 0.5, only 40% precision.
In predictions of 11397 Non-Black Pantyhose Images, 20% chance score > 0.5

Here's detail prediction result for Black Pantyhose Images, only score and is_it_greater_than_0.5 has been output.
https://pastebin.com/raw/vCDNSCbX

It looks like AI just randomly throw me a True or False when I ask for an answer.
Is it normal? Trainning more time will make it more accurate?
Or my settings somehow wrong, spend more time won't get better result?
How do I know which situation I am in?

I am post every settings below anyway.

project.json

{
    "image_width": 400,
    "image_height": 400,
    "database_path": "D:\\DeepDanbooru-master\\BlackPantyhoseDetector\\BlackPantyhose.sqlite",
    "minimum_tag_count": 0,
    "model": "resnet_custom_v4",
    "minibatch_size": 32,
    "epoch_count": 990000,
    "export_model_per_epoch": 500,
    "checkpoint_frequency_mb": 1000,
    "console_logging_frequency_mb": 10,
    "optimizer": "sgd",
    "learning_rate": 0.001,
    "rotation_range": [
        0.0,
        360.0
    ],
    "scale_range": [
        0.9,
        1.1
    ],
    "shift_range": [
        -0.1,
        0.1
    ],
    "mixed_precision": false
}

Database screenshot:https://i.imgur.com/fSvsIuU.png

tags.txt
BlackPantyhose

5.What do you think I should do next?

I will put more images in tranning, 100k at least, but is there anything I can do to improve predict quality?
Increase image_width, image_height, minibatch_size in project.json?
More epoch?
Anything other I can do?

from deepdanbooru.

KichangKim avatar KichangKim commented on June 10, 2024

Total images : 17581, minibatch size is 32, logging frequency is 10, so there should be multiple logging messages (it should show training log per every 320 samples) between epoch. But your log shows only one log per epoch, so seems that something wrong.

Can you sure that SQLite database is correct and training images are placed at correct location?

Generally, P and R starts from 0.5 (totally not trained, so it return random output) and gradually decreased to 0 for a while, then increased to 1.0 again as learning progresses.

from deepdanbooru.

yozhikoff avatar yozhikoff commented on June 10, 2024

I feel like with such a small amount of data there is no way of getting plausible results besides transfer learning.
Of course Resnet-152 will easily overfit on dataset of that size, especially after 26867 epochs.

I'm happy to look at the code and help, by the way. My own workstation got broken and now I have coding withdrawal syndrome...

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

Can you sure that SQLite database is correct and training images are placed at correct location?

https://i.imgur.com/fSvsIuU.png
Here's my database screenshot, it looks correct to me, I insert log after these code

image_records = dd.data.load_image_records(
        database_path, minimum_tag_count)

It reads 17581 images, so all images should be loaded

Here's folder structure, should be right too

BlackPantyhoseDetector/
├── images/
│   ├── 00/
│   │   ├── 00000000000000000000000000000000.jpg
│   │   ├── And so on, all images here
└── project.json
└── BlackPantyhose.sqlite
└── tags.txt

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

@yozhikoff
It's good to hear you happy to help, I just rent a RTX 3090 server, you can use it
I want to spend time on collect more images, build bigger database
You got an telegram account or what?

from deepdanbooru.

KichangKim avatar KichangKim commented on June 10, 2024

Can you show some records in BlackPantyhose.sqlite?

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

https://i.imgur.com/fSvsIuU.png
This image is showing some records, can't you access that? this image should be public

from deepdanbooru.

yozhikoff avatar yozhikoff commented on June 10, 2024

@d222gfxx

Drop me an email, please.

[email protected]

from deepdanbooru.

KichangKim avatar KichangKim commented on June 10, 2024

https://i.imgur.com/fSvsIuU.png This image is showing some records, can't you access that? this image should be public

It seems fine. v4 model is experimental and unstable, so I recommend to use v3. You can find my parameters in https://github.com/KichangKim/DeepDanbooru/releases/tag/v3-20200915-sgd-e30
It contains project.json which currently used in web-demo.

from deepdanbooru.

d222gfxx avatar d222gfxx commented on June 10, 2024

Cool, I will build bigger database and retrain it again

from deepdanbooru.

Related Issues (20)

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.