Update README.md
Browse filesFixed Readme: Usage and Cloning
README.md
CHANGED
|
@@ -29,28 +29,36 @@ This model is a deep learning-based classifier designed to detect and classify d
|
|
| 29 |
The model aims to assist in early diagnosis and grading of diabetic retinopathy, reducing the workload for ophthalmologists and improving accessibility to screening.
|
| 30 |
|
| 31 |
## Usage
|
| 32 |
-
You can use this model
|
| 33 |
|
| 34 |
-
### Installation
|
| 35 |
Ensure you have the required dependencies installed:
|
| 36 |
```bash
|
| 37 |
pip install torch torchvision transformers opencv-python pandas
|
| 38 |
```
|
| 39 |
|
| 40 |
### Loading the Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
```python
|
| 42 |
import torch
|
| 43 |
-
from torchvision import transforms
|
| 44 |
from PIL import Image
|
| 45 |
-
from transformers import AutoModel
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
model = AutoModel.from_pretrained("your-huggingface-username/model-name")
|
| 49 |
model.eval()
|
| 50 |
```
|
| 51 |
|
| 52 |
### Transformer Application
|
| 53 |
```python
|
|
|
|
|
|
|
| 54 |
transform = transforms.Compose([
|
| 55 |
transforms.Resize((224, 224)), # Resize image to match input size
|
| 56 |
transforms.ToTensor(), # Convert image to tensor
|
|
@@ -60,6 +68,8 @@ transform = transforms.Compose([
|
|
| 60 |
|
| 61 |
### Function to preprocess image and get predictions
|
| 62 |
```python
|
|
|
|
|
|
|
| 63 |
def predict(image_path):
|
| 64 |
# Load and preprocess the input image
|
| 65 |
image = Image.open(image_path).convert('RGB') # Ensure RGB format
|
|
|
|
| 29 |
The model aims to assist in early diagnosis and grading of diabetic retinopathy, reducing the workload for ophthalmologists and improving accessibility to screening.
|
| 30 |
|
| 31 |
## Usage
|
| 32 |
+
You can use this model by cloning the repository and using the pickled model by <i>torch.load()</i>.
|
| 33 |
|
| 34 |
+
### Dependencies Installation
|
| 35 |
Ensure you have the required dependencies installed:
|
| 36 |
```bash
|
| 37 |
pip install torch torchvision transformers opencv-python pandas
|
| 38 |
```
|
| 39 |
|
| 40 |
### Loading the Model
|
| 41 |
+
|
| 42 |
+
Clone the repository (with GIT LFS enabled)
|
| 43 |
+
```bash
|
| 44 |
+
git lfs install
|
| 45 |
+
|
| 46 |
+
git clone https://huggingface.co/sakshamkr1/ResNet50-APTOS-DR
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Load the Model
|
| 50 |
```python
|
| 51 |
import torch
|
|
|
|
| 52 |
from PIL import Image
|
|
|
|
| 53 |
|
| 54 |
+
model = torch.load(model_path, map_location=torch.device('gpu'), weights_only=False) #Change torch.device to 'cpu' if using CPU
|
|
|
|
| 55 |
model.eval()
|
| 56 |
```
|
| 57 |
|
| 58 |
### Transformer Application
|
| 59 |
```python
|
| 60 |
+
from torchvision import transforms
|
| 61 |
+
|
| 62 |
transform = transforms.Compose([
|
| 63 |
transforms.Resize((224, 224)), # Resize image to match input size
|
| 64 |
transforms.ToTensor(), # Convert image to tensor
|
|
|
|
| 68 |
|
| 69 |
### Function to preprocess image and get predictions
|
| 70 |
```python
|
| 71 |
+
import numpy as np
|
| 72 |
+
|
| 73 |
def predict(image_path):
|
| 74 |
# Load and preprocess the input image
|
| 75 |
image = Image.open(image_path).convert('RGB') # Ensure RGB format
|