KichangKim / DeepDanbooru

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

feat: add webp decode support by adding tfio #51

Closed fumiama closed 2 years ago

fumiama commented 2 years ago

The method

tfio.experimental.color.rgba_to_rgb

is experimental and I'm not sure whether this will effect training or predicting. I have tested under the Pretrained Model and found just a little different between webp and png.

webp format

(0.999) 1girl
(0.575) areolae
(0.715) arm_up
(0.641) armpits
(0.802) blue_eyes
(0.653) blush
(0.982) breasts
(0.674) brown_hair
(0.515) collarbone
(0.546) double_bun
(0.648) eyebrows_visible_through_hair
(0.956) long_hair
(0.892) looking_at_viewer
(0.820) lying
(0.735) medium_breasts
(0.845) navel
(0.824) nude
(0.778) on_back
(0.682) parted_lips
(0.589) smile
(0.986) solo
(0.956) rating:questionable

png format

(0.999) 1girl
(0.585) areolae
(0.647) arm_up
(0.626) armpits
(0.681) blue_eyes
(0.655) blush
(0.984) breasts
(0.519) brown_hair
(0.602) collarbone
(0.713) double_bun
(0.731) eyebrows_visible_through_hair
(0.637) hair_bun
(0.967) long_hair
(0.892) looking_at_viewer
(0.855) lying
(0.743) medium_breasts
(0.795) navel
(0.843) nude
(0.838) on_back
(0.746) parted_lips
(0.519) pasties
(0.987) solo
(0.934) rating:questionable
KichangKim commented 2 years ago

Current training script uses only png and jpeg files. So I think it does not effect to training.

fumiama commented 2 years ago

OK, then I hope my modification would make it possible to evaluate custom webp images.

DHG-Dav commented 1 year ago

Hello, i'm just passing by and noticed you finally added webp compatibility, however you may want to also add the ability to evaluate folders containing webp and train on webp : main.py line 82 : @click.option('--folder-filters', default='.[Pp][Nn][Gg],.[Jj][Pp][Gg],.[Jj][Pp][Ee][Gg],.[Gg][Ii][Ff],*.[Ww][Ee][Bb][Pp]'

and dataset.py line 21 : cursor.execute( "SELECT md5, file_ext, tag_string FROM posts WHERE (file_ext = 'png' OR file_ext = 'jpg' OR file_ext = 'JPG' OR file_ext = 'PNG' OR file_ext = 'jpeg' OR file_ext = 'webp') AND (tag_count_general >= ?) ORDER BY id", (minimum_tag_count,), )

thanks again for that great project !

fumiama commented 1 year ago

Exactly. I only fixed the predict part because I had never used it to train a model. Maybe you can open a new PR for that.