Zahaab commited on
Commit
26ca5b4
·
verified ·
1 Parent(s): 2920b75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -22
README.md CHANGED
@@ -59,7 +59,7 @@ class CNNV0(nn.Module):
59
  x = self.conv_block_2(x)
60
  x = self.classifier(x)
61
  return x
62
-
63
  ## Requirements
64
 
65
  - **Python** 3.7 or higher
@@ -73,28 +73,29 @@ class CNNV0(nn.Module):
73
  git clone <repository-url>
74
  cd <repository-folder>
75
  pip install torch torchvision
76
-
 
77
  2. Load and use the model in your Python script:
78
  ```python
79
  import torch
80
- from torchvision import transforms
81
- from PIL import Image
82
-
83
- # Load the model
84
- model = torch.load('model_0.pth')
85
- model.eval() # Set to evaluation mode
86
-
87
- # Load and preprocess the image
88
- transform = transforms.Compose([
89
- transforms.Resize((224, 224)),
90
- transforms.ToTensor(),
91
- ])
92
- img = Image.open('path_to_image.jpg')
93
- img = transform(img).view(1, 3, 224, 224) # Reshape to (1, 3, 224, 224) for batch processing
94
-
95
- # Predict
96
- with torch.no_grad():
97
- output = model(img)
98
- _, predicted = torch.max(output, 1)
99
- print("Predicted Aircraft Type:", predicted.item())
100
 
 
 
 
 
 
 
 
59
  x = self.conv_block_2(x)
60
  x = self.classifier(x)
61
  return x
62
+ ```
63
  ## Requirements
64
 
65
  - **Python** 3.7 or higher
 
73
  git clone <repository-url>
74
  cd <repository-folder>
75
  pip install torch torchvision
76
+ ```
77
+
78
  2. Load and use the model in your Python script:
79
  ```python
80
  import torch
81
+ from torchvision import transforms
82
+ from PIL import Image
83
+
84
+ # Load the model
85
+ model = torch.load('model_0.pth')
86
+ model.eval() # Set to evaluation mode
87
+
88
+ # Load and preprocess the image
89
+ transform = transforms.Compose([
90
+ transforms.Resize((224, 224)),
91
+ transforms.ToTensor(),
92
+ ])
93
+ img = Image.open('path_to_image.jpg')
94
+ img = transform(img).view(1, 3, 224, 224) # Reshape to (1, 3, 224, 224) for batch processing
 
 
 
 
 
 
95
 
96
+ # Predict
97
+ with torch.no_grad():
98
+ output = model(img)
99
+ _, predicted = torch.max(output, 1)
100
+ print("Predicted Aircraft Type:", predicted.item())
101
+ ```