Downloads · 30 days
103
0% of all-time downloads
angusleung100/bad-anatomy-realism-classifier
bad-anatomy-realism-classifier is a image classification model from angusleung100. Use it when you need a label for an image. It is set up for transformers.
A finetuned Vision Transformer model for classifying AI-generated pictures for bad anatomy and realism.
Downloads · 30 days
103
0% of all-time downloads
All-time downloads
219K
Public
Parameters
85.8M
346 MB on disk
Likes
8
Public
Click a slice to open those files.
.safetensors343 MB · 99%
From the Hugging Face model README
A finetuned Vision Transformer model for classifying AI-generated pictures for bad anatomy and realism.
This model is currently a support model for my Youtube series. Feel free to build on top of this.
Detecting Bad Anatomy in Realistic AI-Generated Images - Not all Image Generation models generate images with good anatomy. Some might generate the typical "bad hands" where the hand might have more than 5 fingers. This model's goaal is to detect such anatomy issues in AI-generated images.
Determining True Realism Versus AI Realism - AI-generated images tend to have an issue when attempting to achieve realism, which is the skin and generation style. Compared to a normal post on social media, a High-Definition upscaled AI-generated image can be easily identified by, characteristic such as shiny skin or very bright lighting. Below are some examples of such:
<img src="https://huggingface.co/angusleung100/bad-anatomy-realism-classifier/resolve/main/Unrealistic_Good_Anatomy_29.png" alt="Unrealistic Good Anatomy AI-generated image number 29" width="512" height="512"/> <img src="https://huggingface.co/angusleung100/bad-anatomy-realism-classifier/resolve/main/Unrealistic_Good_Anatomy_31.png" alt="Unrealistic Good Anatomy AI-generated image number 31" width="512" height="512"/>This was fine-tuned on the google/vit-base-patch16-224-in21k Vision Transformer (ViT).
This initial model was trained on images generated on Stable Diffusion v1.5 on the Beautiful Realistic Asians v6 checkpoint by pleasebankai.
The dataset for this model was only 134 images, with only 6 being Unrealistic Bad Anatomy. (Additions of dataset details will be placed in the model card in later updates to documentation)
Recommendation is to build on the dataset and continue training with more variety of characters to raise performance for images that do not conform to the characteristics of images used in training.
Please refer to the initial finetune script for this model in the supporting Github Repository here: https://github.com/angusleung100/barc-finetuning-gh
Please refer to the Hugging Face documentation example here for Image Classification: https://huggingface.co/docs/transformers/en/tasks/image_classification#inference
The criteria is more interesting for determining realism. Since a lot of people like to use filters now, it's actually quite hard to determine what is a good standard for realism. Here is what I narrowed it down to for this model:
Overall it is based on "gut feeling" for the sorting. The model also has a goal to be able to replicate "gut feeling" and just your underlying feel for the image.
Since the default data collator is used and images are primarily from SD 1.5, I am not entirely certain whether images and sizes from different models will break the training, even if the testing pipeline didn't have any problems for the 3 images we used later on.
Here are a list of models where default image sizes should work:
Number Images Per Label
=======================
Realistic Bad Anatomy: 6 (4.48%)
Realistic Good Anatomy: 15 (11.19%)
Unrealistic Bad Anatomy: 81 (60.45%)
Unrealistic Good Anatomy: 32 (23.88%)
Total Number of Images: 134
***** train metrics *****
epoch = 3.0
total_flos = 20135801GF
train_loss = 0.8453
train_runtime = 0:00:42.83
train_samples_per_second = 6.514
train_steps_per_second = 0.841
***** eval metrics *****
epoch = 3.0
eval_accuracy = 0.6341
eval_f1 = 0.513
eval_loss = 0.8219
eval_precision = 0.464
eval_recall = 0.6341
eval_runtime = 0:00:06.95
eval_samples_per_second = 5.893
eval_steps_per_second = 0.862
The initial dataset and finetune resulted in a 64.41% accuracy and 51.3% F1 score, which is low but expected for a small amateur dataset.
Hopefully I will have time to further build on the dataset and improve the model's performance in the future.
The next steps would be:
You can view example pipeline inferences and their results on the Initial Finetune notebook
The examples are at the bottom of the notebook. You can do ctr+f and search for Test Model With Custom Inputs to reach it faster.
Feel free to contact me if you have any questions or find me on Github