Update README.md
Browse files
README.md
CHANGED
|
@@ -1,39 +1,40 @@
|
|
| 1 |
-
---
|
| 2 |
-
model_name: "Wheat Anomaly Detection Model"
|
| 3 |
-
tags:
|
| 4 |
-
- pytorch
|
| 5 |
-
- resnet
|
| 6 |
-
- agriculture
|
| 7 |
-
- anomaly-detection
|
| 8 |
-
license: apache-2.0
|
| 9 |
-
library_name: pytorch
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
import
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
model
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
inputs =
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
model_name: "Wheat Anomaly Detection Model"
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- resnet
|
| 6 |
+
- agriculture
|
| 7 |
+
- anomaly-detection
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
library_name: pytorch
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Wheat Anomaly Detection Model
|
| 13 |
+
|
| 14 |
+
This model is a PyTorch-based ResNet model trained to detect anomalies in wheat crops, such as diseases, pests, and nutrient deficiencies.
|
| 15 |
+
|
| 16 |
+
## How to Load the Model
|
| 17 |
+
|
| 18 |
+
To load the trained model, use the following code:
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
from transformers import AutoModelForImageClassification
|
| 22 |
+
import torch
|
| 23 |
+
|
| 24 |
+
# Load the pre-trained model
|
| 25 |
+
model = AutoModelForImageClassification.from_pretrained('your_huggingface_username/your_model_name')
|
| 26 |
+
|
| 27 |
+
# Put the model in evaluation mode
|
| 28 |
+
model.eval()
|
| 29 |
+
|
| 30 |
+
# Example of making a prediction
|
| 31 |
+
image_path = "path_to_your_image.jpg" # Replace with your image path
|
| 32 |
+
image = Image.open(image_path)
|
| 33 |
+
inputs = transform(image).unsqueeze(0) # Apply the necessary transformations to the image
|
| 34 |
+
inputs = inputs.to(device)
|
| 35 |
+
|
| 36 |
+
# Make a prediction
|
| 37 |
+
with torch.no_grad():
|
| 38 |
+
outputs = model(inputs)
|
| 39 |
+
predicted_class = torch.argmax(outputs.logits, dim=1)
|
| 40 |
+
print(f"Predicted Class: {predicted_class.item()}")
|