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", device_map="auto") - 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
File size: 1,938 Bytes
33341d9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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()
|