Instructions to use haresh2792005/MFAF-Net with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MediaPipe
How to use haresh2792005/MFAF-Net with MediaPipe:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download mfaf_net/dataset_analysis.py from haresh2792005/MFAF-Net: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/haresh2792005/MFAF-Net/resolve/main/mfaf_net/dataset_analysis.py
- Command line
-
hf download hf://haresh2792005/MFAF-Net/mfaf_net/dataset_analysis.py
-
curl -L -o dataset_analysis.py https://huggingface.co/haresh2792005/MFAF-Net/resolve/main/mfaf_net/dataset_analysis.py
3.16 kB
| """ | |
| Dataset Analysis Tool for MFAF-Net. | |
| Runs comprehensive analysis on the Complete_PlasticSurgery_Datasets extracted | |
| into the `data/` directory and formats findings for inclusion in academic conference papers. | |
| """ | |
| import os | |
| import sys | |
| from PIL import Image | |
| from mfaf_net.dataset_loader import DatasetLoader, get_dataset_stats, load_metadata | |
| def analyze_dataset(data_dir: str = 'data'): | |
| print("=" * 70) | |
| print(" MFAF-Net: Complete Plastic Surgery Dataset Analysis Report") | |
| print("=" * 70) | |
| loader = DatasetLoader(data_dir) | |
| if not loader.exists(): | |
| print(f"\n[!] Data directory not found at: {loader.data_dir}") | |
| print("Please extract 'Complete_PlasticSurgery_Datasets.zip' into this directory.") | |
| return | |
| stats = loader.get_stats() | |
| print("\n1. Overview:") | |
| print(f" - Data Root Directory: {stats.get('data_root', loader.data_dir)}") | |
| print(f" - Total Image Pairs Identified: {stats.get('total_pairs', 0)}") | |
| print(f" - Total Individual Images: {stats.get('total_images', 0)}") | |
| print(f" - Procedures Found: {stats.get('procedures_found', 0)}") | |
| print(f" - Metadata Found: {'Yes' if stats.get('has_metadata') else 'No'}") | |
| if stats.get('has_metadata'): | |
| print(f" - Metadata File: {stats.get('metadata_file')}") | |
| print(f" - Metadata Format / Records: {stats.get('metadata_format')} ({stats.get('metadata_rows', 0)} rows)") | |
| print("\n2. Distribution Across Procedures / Categories:") | |
| by_proc = stats.get('by_procedure', {}) | |
| if by_proc: | |
| print(f" {'Category':<25} | {'Pairs':<10} | {'Images':<10}") | |
| print(f" {'-' * 25}-|-{'-' * 10}-|-{'-' * 10}") | |
| for proc, info in by_proc.items(): | |
| pairs_c = info.get('pairs', 0) if isinstance(info, dict) else 0 | |
| imgs_c = info.get('count', 0) if isinstance(info, dict) else info | |
| print(f" {proc:<25} | {pairs_c:<10} | {imgs_c:<10}") | |
| else: | |
| print(" No procedure-specific subfolders or images detected yet.") | |
| # Sample image dimensions from first few pairs | |
| sample_pairs = loader.get_pairs(limit=5) | |
| if sample_pairs: | |
| print("\n3. Sample Image Dimensions:") | |
| for i, (b_path, a_path) in enumerate(sample_pairs, 1): | |
| try: | |
| with Image.open(b_path) as b_img, Image.open(a_path) as a_img: | |
| print( | |
| f" Pair #{i}: before={b_img.size[0]}x{b_img.size[1]}, " | |
| f"after={a_img.size[0]}x{a_img.size[1]} ({os.path.basename(b_path)})" | |
| ) | |
| except Exception as exc: | |
| print(f" Pair #{i}: could not read dimensions ({exc})") | |
| meta = load_metadata(data_dir) | |
| if meta: | |
| print("\n4. Patient Demographic Metadata Sample (First 5 records):") | |
| print(f" Columns: {list(meta[0].keys())}") | |
| for i, row in enumerate(meta[:5], 1): | |
| print(f" Record #{i}: {row}") | |
| print("=" * 70 + "\n") | |
| if __name__ == '__main__': | |
| data_path = sys.argv[1] if len(sys.argv) > 1 else 'data' | |
| analyze_dataset(data_path) | |