posts: automatically tag AI-generated on NovelAI posts.
Automatically add the AI-generated tag to posts that have the `PNG:Software=NovelAI` EXIF attribute. This is not foolproof because this metadata may get removed if an AI-generated post is resaved or uploaded to a site that strips EXIF metadata. It also only works for NovelAI. Currently it detects 29 out of 177 AI-generated uploads on Danbooru.
This commit is contained in:
@@ -80,6 +80,11 @@ class ExifTool
|
||||
loop_count.in?(0..10)
|
||||
end
|
||||
|
||||
# https://danbooru.donmai.us/media_assets?search[metadata][PNG:Software]=NovelAI
|
||||
def is_ai_generated?
|
||||
metadata["PNG:Software"] == "NovelAI"
|
||||
end
|
||||
|
||||
# @see http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
|
||||
# @see https://wiki.mozilla.org/APNG_Specification#.60acTL.60:_The_Animation_Control_Chunk
|
||||
# @see https://danbooru.donmai.us/posts?tags=-exif:GIF:AnimationIterations=Infinite+animated_gif
|
||||
|
||||
@@ -24,7 +24,7 @@ class MediaAsset < ApplicationRecord
|
||||
has_many :ai_tags
|
||||
|
||||
delegate :metadata, to: :media_metadata
|
||||
delegate :is_non_repeating_animation?, :is_greyscale?, :is_rotated?, to: :metadata
|
||||
delegate :is_non_repeating_animation?, :is_greyscale?, :is_rotated?, :is_ai_generated?, to: :metadata
|
||||
|
||||
scope :public_only, -> { where(is_public: true) }
|
||||
scope :private_only, -> { where(is_public: false) }
|
||||
|
||||
@@ -465,6 +465,7 @@ class Post < ApplicationRecord
|
||||
tags << "greyscale" if media_asset.is_greyscale?
|
||||
tags << "exif_rotation" if media_asset.is_rotated?
|
||||
tags << "non-repeating_animation" if media_asset.is_non_repeating_animation?
|
||||
tags << "ai-generated" if media_asset.is_ai_generated?
|
||||
|
||||
tags
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user