hp1318 commited on
Commit
586298c
·
verified ·
1 Parent(s): 3a31f0d

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. README.md +59 -3
  2. best_alexnet.pth +3 -0
  3. config.json +13 -0
  4. labels.json +7 -0
  5. model.py +15 -0
  6. requirements.txt +4 -0
README.md CHANGED
@@ -1,3 +1,59 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ license: apache-2.0
4
+ tags:
5
+ - image-classification
6
+ - medical-imaging
7
+ - cervical-cancer
8
+ - pap-smear
9
+ - pytorch
10
+ ---
11
+
12
+ # AlexNet Fine-Tuned on HERLEV Dataset
13
+
14
+ This repository provides a fine-tuned AlexNet model trained on the HERLEV cervical cytology dataset for multi-class cervical cell classification.
15
+
16
+ ## Model Details
17
+ - Architecture: AlexNet
18
+ - Framework: PyTorch
19
+ - Input size: 224x224 RGB
20
+ - Classes: 5
21
+
22
+ ## Classes
23
+ 0: Superficial–Intermediate
24
+ 1: Parabasal
25
+ 2: Koilocytotic
26
+ 3: Dyskeratotic
27
+ 4: Metaplastic
28
+
29
+ ## How to Use
30
+
31
+ ```python
32
+ import torch
33
+ from PIL import Image
34
+ from torchvision import transforms
35
+ from model import load_model
36
+
37
+ device = "cuda" if torch.cuda.is_available() else "cpu"
38
+ model = load_model("best_alexnet.pth", device=device)
39
+
40
+ transform = transforms.Compose([
41
+ transforms.Resize((224,224)),
42
+ transforms.ToTensor(),
43
+ transforms.Normalize(
44
+ mean=[0.485, 0.456, 0.406],
45
+ std=[0.229, 0.224, 0.225]
46
+ )
47
+ ])
48
+
49
+ img = Image.open("cell_image.jpg").convert("RGB")
50
+ img = transform(img).unsqueeze(0).to(device)
51
+
52
+ with torch.no_grad():
53
+ pred = model(img).argmax(1)
54
+
55
+ print("Prediction:", pred.item())
56
+
57
+ Intended Use
58
+
59
+ Research and educational purposes only.
best_alexnet.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e3ac117fa20de155592a4c0198217da29ce74368f163fe7de961cfc0a7ea830
3
+ size 227540992
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "AlexNet",
3
+ "framework": "PyTorch",
4
+ "task": "Image Classification",
5
+ "domain": "Medical Imaging",
6
+ "dataset": "HERLEV",
7
+ "input_size": [
8
+ 224,
9
+ 224
10
+ ],
11
+ "num_classes": 5,
12
+ "finetuned": true
13
+ }
labels.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "Superficial-Intermediate",
3
+ "1": "Parabasal",
4
+ "2": "Koilocytotic",
5
+ "3": "Dyskeratotic",
6
+ "4": "Metaplastic"
7
+ }
model.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import torch.nn as nn
4
+ from torchvision import models
5
+
6
+ def load_model(model_path, num_classes=5, device="cpu"):
7
+ model = models.alexnet(weights=None)
8
+ model.classifier[6] = nn.Linear(4096, num_classes)
9
+
10
+ state_dict = torch.load(model_path, map_location=device)
11
+ model.load_state_dict(state_dict)
12
+
13
+ model.eval()
14
+ model.to(device)
15
+ return model
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ Pillow
4
+ numpy