
Fatima 2023 Application


This project is about an image classification task of artificial and natural classes.


Setup:

    pip install -r requirements.txt


Inference:


    from torchvision import transforms
    from PIL import Image
    import torch
    
    
    inference_transform = transforms.Compose([
        transforms.Resize(128),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.4914, 0.4822, 0.4465],
                             std=[0.2023, 0.1994, 0.2010]),
    ])
    
    #load image and model
    img_example = Image.open("image_example.png").convert('RGB')
    print("image loaded!")
    model_loaded = torch.load("fatima_challenge_model_exp3.pt")
    model_loaded.eval()
    print("model loaded!")
    
    
    img_example_transformed = inference_transform(img_example)
    out = model_loaded(img_example_transformed.to(torch.device("cuda:0")).unsqueeze(0)) # Generate predictions
    _, outs = torch.max(out, 1)
    prediction = "natural" if int(outs.cpu().numpy())==0 else "artificial"
    print("prediction = ",prediction)


{"language": ["en"], "license": "mit", "datasets": ["competitions/aiornot"], "metrics": ["accuracy", "f1"], "pipeline_tag": "image-classification"}
image-classification en dataset:competitions/aiornot license:mit region:us
TAGS
#image-classification #en #dataset-competitions/aiornot #license-mit #region-us 


Fatima 2023 Application


This project is about an image classification task of artificial and natural classes.


Setup:

    pip install -r URL


Inference:


    from torchvision import transforms
    from PIL import Image
    import torch
    
    
    inference_transform = transforms.Compose([
        transforms.Resize(128),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.4914, 0.4822, 0.4465],
                             std=[0.2023, 0.1994, 0.2010]),
    ])
    
    #load image and model
    img_example = URL("image_example.png").convert('RGB')
    print("image loaded!")
    model_loaded = URL("fatima_challenge_model_exp3.pt")
    model_loaded.eval()
    print("model loaded!")
    
    
    img_example_transformed = inference_transform(img_example)
    out = model_loaded(img_example_transformed.to(URL("cuda:0")).unsqueeze(0)) # Generate predictions
    _, outs = URL(out, 1)
    prediction = "natural" if int(URL().numpy())==0 else "artificial"
    print("prediction = ",prediction)


# Generate predictions
    _, outs = URL(out, 1)
    prediction = "natural" if int(URL().numpy())==0 else "artificial"
    print("prediction = ",prediction)
TAGS
#image-classification #en #dataset-competitions/aiornot #license-mit #region-us 
 # Generate predictions
    _, outs = URL(out, 1)
    prediction = "natural" if int(URL().numpy())==0 else "artificial"
    print("prediction = ",prediction)
TAGS
#image-classification #en #dataset-competitions/aiornot #license-mit #region-us 
# Generate predictions
    _, outs = URL(out, 1)
    prediction = "natural" if int(URL().numpy())==0 else "artificial"
    print("prediction = ",prediction)