CristianLazoQuispe commited on
Commit
ffee944
·
1 Parent(s): b9963e2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -24
README.md CHANGED
@@ -10,38 +10,43 @@ metrics:
10
  pipeline_tag: image-classification
11
  ---
12
 
13
- Image Classification
 
14
 
15
  This project is about an image classification task of artificial and natural classes.
16
 
 
17
  Setup:
18
 
19
- pip install -r requirements.txt
20
 
21
 
22
  Inference:
23
 
24
 
25
- from torchvision import transforms
26
- import torch
27
- inference_transform = transforms.Compose([
28
- transforms.Resize(128),
29
- transforms.ToTensor(),
30
- transforms.Normalize(mean=[0.4914, 0.4822, 0.4465],
31
- std=[0.2023, 0.1994, 0.2010]),
32
- ])
33
-
34
- #load image and model
35
- img_example = Image.open("image_example.png").convert('RGB')
36
- print("image loaded!")
37
- model_loaded = torch.load("fatima_challenge_model_exp3.pt")
38
- model_loaded.eval()
39
- print("model loaded!")
40
-
41
-
42
- img_example_transformed = inference_transform(img_example)
43
- out = model_loaded(img_example_transformed.to(torch.device("cuda:0")).unsqueeze(0)) # Generate predictions
44
- _, outs = torch.max(out, 1)
45
- prediction = "natural" if int(outs.cpu().numpy())==0 else "artificial"
46
- print("prediction = ",prediction)
 
 
 
47
 
 
10
  pipeline_tag: image-classification
11
  ---
12
 
13
+ Fatima 2023 Application
14
+
15
 
16
  This project is about an image classification task of artificial and natural classes.
17
 
18
+
19
  Setup:
20
 
21
+ pip install -r requirements.txt
22
 
23
 
24
  Inference:
25
 
26
 
27
+ from torchvision import transforms
28
+ from PIL import Image
29
+ import torch
30
+
31
+
32
+ inference_transform = transforms.Compose([
33
+ transforms.Resize(128),
34
+ transforms.ToTensor(),
35
+ transforms.Normalize(mean=[0.4914, 0.4822, 0.4465],
36
+ std=[0.2023, 0.1994, 0.2010]),
37
+ ])
38
+
39
+ #load image and model
40
+ img_example = Image.open("image_example.png").convert('RGB')
41
+ print("image loaded!")
42
+ model_loaded = torch.load("fatima_challenge_model_exp3.pt")
43
+ model_loaded.eval()
44
+ print("model loaded!")
45
+
46
+
47
+ img_example_transformed = inference_transform(img_example)
48
+ out = model_loaded(img_example_transformed.to(torch.device("cuda:0")).unsqueeze(0)) # Generate predictions
49
+ _, outs = torch.max(out, 1)
50
+ prediction = "natural" if int(outs.cpu().numpy())==0 else "artificial"
51
+ print("prediction = ",prediction)
52