File size: 1,200 Bytes
46b1489 fd25ba9 b9963e2 ffee944 b9963e2 ffee944 b9963e2 ffee944 b9963e2 ffee944 b9963e2 |
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 |
---
license: mit
datasets:
- competitions/aiornot
language:
- en
metrics:
- accuracy
- f1
pipeline_tag: image-classification
---
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)
|