Image Classification
Transformers
Safetensors
timm
vit
detection
deepfake
forensics
deepfake_detection
community
opensight
Instructions to use buildborderless/CommunityForensics-DeepfakeDet-ViT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use buildborderless/CommunityForensics-DeepfakeDet-ViT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="buildborderless/CommunityForensics-DeepfakeDet-ViT") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT") model = AutoModelForImageClassification.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT") - timm
How to use buildborderless/CommunityForensics-DeepfakeDet-ViT with timm:
import timm model = timm.create_model("hf_hub:buildborderless/CommunityForensics-DeepfakeDet-ViT", pretrained=True) - Inference
- Notebooks
- Google Colab
- Kaggle
| import os | |
| import shutil | |
| def move_real_images(source_dir, dest_dir): | |
| if not os.path.exists(dest_dir): | |
| os.makedirs(dest_dir) | |
| # Walk through the source directory | |
| for root, dirs, files in os.walk(source_dir): | |
| if 'real' in dirs: | |
| # Construct the full path to the `real` directory | |
| real_dir = os.path.join(root, 'real') | |
| model_folder_name = os.path.basename(root) | |
| dest_model_dir = os.path.join(dest_dir, model_folder_name) | |
| if not os.path.exists(dest_model_dir): | |
| os.makedirs(dest_model_dir) | |
| for file in os.listdir(real_dir): | |
| source_file = os.path.join(real_dir, file) | |
| dest_file = os.path.join(dest_model_dir, file) | |
| shutil.move(source_file, dest_file) | |
| print(f"Moved: {source_file} to {dest_file}") | |
| def move_generated_images(source_dir): | |
| # Walk through the source directory | |
| for root, dirs, files in os.walk(source_dir): | |
| # Check if the current directory is a `generated` directory | |
| if 'generated' in dirs: | |
| # Construct the full path to the `generated` directory | |
| generated_dir = os.path.join(root, 'generated') | |
| # Move all files from the `generated` directory to the parent directory | |
| for file in os.listdir(generated_dir): | |
| source_file = os.path.join(generated_dir, file) | |
| dest_file = os.path.join(root, file) | |
| # Move the file | |
| shutil.move(source_file, dest_file) | |
| print(f"Moved: {source_file} to {dest_file}") | |
| def main(): | |
| source_dir = 'resampledSet' | |
| real_dest_dir = 'real' | |
| move_real_images(source_dir, real_dest_dir) | |
| move_generated_images(source_dir) | |
| if __name__ == "__main__": | |
| main() | |