TL;DR
Diffusion models, while amazing at image generation, notoriously struggle with rendering human hands, often producing anatomically incorrect or bizarre results. This paper introduces HandCraft, a plug-and-play framework that automatically detects malformed hands and uses a parametric hand model to guide diffusion models in restoring them to anatomical correctness while preserving the original image's style and integrity.
What Problem Does This Paper Address?
Generative AI models like Stable Diffusion have revolutionized image creation, but they exhibit a peculiar weakness: generating human hands. These hands frequently appear with extra or missing fingers, unnatural proportions, or generally distorted anatomy, leading to images that fall into the "uncanny valley" and detract from the overall realism. While prompt engineering and manual inpainting can offer some mitigation, they are often laborious and don't guarantee satisfactory results. This paper aims to solve the problem of anatomically incorrect hands in diffusion-generated images by providing an automated, efficient, and high-quality restoration method.
Methods
HandCraft is a three-stage framework:
- Hand Detection: It first uses a standard hand detector (like YOLOv8) to identify the hand's bounding box. Crucially, it also employs a body pose estimator (Mediapipe) to extract keypoints, even from malformed hands, which is vital for accurate alignment.
- Control Image Generation: This stage is the core innovation. It takes a pre-defined, anatomically correct hand template (a depth map) and aligns it with the detected hand's pose and position. This involves scaling, translating, and rotating the template to match the detected hand's keypoints and orientation. The output is a "control image" (depth map) and a corresponding mask that guides the restoration process.
- Hand Restoration: The generated control image and mask are then fed into a pre-trained diffusion model (specifically, ControlNet) along with the original image and a text prompt describing the desired hand pose. ControlNet uses these signals to edit the image, focusing solely on the hand region to correct its anatomy and pose, while ensuring seamless integration with the rest of the image. The framework is designed to be "plug-and-play," requiring no fine-tuning of the diffusion model itself.
Datasets
The authors introduce the MalHand datasets for training and evaluation.
- Training Data: Created by leveraging Stable Diffusion to generate malformed hands on images from the HaGRID dataset. Approximately 60,000 images with malformed hands were curated.
- Evaluation Data: Consists of 1,500 portrait images with malformed hands, split into:
- MalHand-realistic: 1,000 images in a realistic style.
- MalHand-artistic: 500 images in various artistic styles (e.g., Japanese anime, Disney cartoon).
- They also use unaltered images from HaGRID as a "non-malformed" control group for comparison.
Key Insights and Ideas
- Parametric Hand Model as a Powerful Conditioner: The key insight is using a pre-defined, anatomically correct hand template, guided by detected pose information, as a strong conditioning signal for diffusion models. This provides a precise target for anatomical correction.
- Mediapipe's Robustness for Malformed Hands: The paper highlights that Mediapipe, a general-purpose pose estimator, surprisingly performs well in extracting keypoints from malformed hands, which is crucial for aligning the hand template.
- Restoration Region for Integrity: Defining a specific "restoration region" (union of the detected hand bounding box and the aligned template mask) is critical for ensuring that the restoration process focuses only on the hand and preserves the integrity of the surrounding image content.
- Plug-and-Play Simplicity: The framework's ability to work with pre-trained diffusion models without requiring fine-tuning or additional training significantly lowers the barrier to adoption.
Key Results
- Superior Anatomical Correctness: HandCraft achieves the highest hand pose confidence scores (Cpose), indicating more natural and anatomically correct hand postures compared to baselines like HandRefiner and ControlNet variants.
- Comparable Classifier Confidence: The hand classifier confidence (Cclassifier) is comparable to HandRefiner, suggesting that the restored hands are also perceived as non-malformed by classifiers.
- Preservation of Image Integrity: HandCraft achieves high PSNR and SSIM scores in non-hand regions, demonstrating its ability to maintain the original image's quality and avoid unwanted perturbations.
- Qualitative Improvements: Visual comparisons show HandCraft seamlessly integrating corrected hands into diverse artistic and realistic portraits, outperforming HandRefiner in terms of naturalness and aesthetic coherence.
Limitations and Future Work
- Artifacts at Borders: The authors acknowledge that artifacts may emerge at the border of the regenerated area and propose a strategy of generating multiple results with slightly different scales to mitigate this.
- Potential for Altering Well-formed Hands: While the primary goal is malformed hand restoration, the framework can also be used to modify well-formed hands into desired gestures, though this aspect is not the main focus of the evaluation.
- Future Directions: The paper suggests that even if diffusion models improve their inherent hand generation capabilities, HandCraft's functionality for changing hand gestures and poses offers utility beyond just correcting malformed hands. The MalHand datasets are also provided for further research and benchmarking.
Summary updated