Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,22 +46,9 @@ dinov2 = torch.hub.load('facebookresearch/dinov2', 'dinov2_vitg14_reg')
|
|
| 46 |
print("Loading custom pathology checkpoint...")
|
| 47 |
#ours = torch.load("/data/linears/teacher_checkpoint.pth")
|
| 48 |
|
| 49 |
-
|
| 50 |
-
checkpoint = ours#["teacher"]
|
| 51 |
-
checkpoint_new = {}
|
| 52 |
|
| 53 |
-
# Remove dino and ibot keys
|
| 54 |
-
#for key in list(checkpoint.keys()):
|
| 55 |
-
# if "dino" in str(key) or "ibot" in str(key):
|
| 56 |
-
# checkpoint.pop(key, None)
|
| 57 |
|
| 58 |
-
# Align keys with dinov2 state dict
|
| 59 |
-
#for key, keyb in zip(checkpoint.keys(), dinov2.state_dict().keys()):
|
| 60 |
-
# checkpoint_new[keyb] = checkpoint[key]
|
| 61 |
-
|
| 62 |
-
#checkpoint = checkpoint_new
|
| 63 |
-
|
| 64 |
-
# Update pos_embed
|
| 65 |
|
| 66 |
new_shape = checkpoint["pos_embed"]
|
| 67 |
dinov2.pos_embed = torch.nn.parameter.Parameter(new_shape)
|
|
@@ -102,16 +89,16 @@ def setup_linear_crc(path):
|
|
| 102 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 103 |
dinov2 = dinov2.to(device)
|
| 104 |
|
| 105 |
-
breakhis_path = "
|
| 106 |
breakhis_linear = setup_linear(breakhis_path).to(device)
|
| 107 |
|
| 108 |
-
gleason_path = "
|
| 109 |
gleason_linear = setup_linear(gleason_path).to(device)
|
| 110 |
|
| 111 |
-
bach_path = "
|
| 112 |
bach_linear = setup_linear(bach_path).to(device)
|
| 113 |
|
| 114 |
-
crc_path = "
|
| 115 |
crc_linear = setup_linear_crc(crc_path).to(device)
|
| 116 |
|
| 117 |
|
|
@@ -296,4 +283,4 @@ demo = gr.TabbedInterface([breakhis, gleason, crc, bach],["BreakHis", "Gleason",
|
|
| 296 |
|
| 297 |
|
| 298 |
if __name__ == "__main__":
|
| 299 |
-
demo.launch(
|
|
|
|
| 46 |
print("Loading custom pathology checkpoint...")
|
| 47 |
#ours = torch.load("/data/linears/teacher_checkpoint.pth")
|
| 48 |
|
| 49 |
+
checkpoint = torch.load("./teacher_checkpoint_load.pt")
|
|
|
|
|
|
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
new_shape = checkpoint["pos_embed"]
|
| 54 |
dinov2.pos_embed = torch.nn.parameter.Parameter(new_shape)
|
|
|
|
| 89 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 90 |
dinov2 = dinov2.to(device)
|
| 91 |
|
| 92 |
+
breakhis_path = "./breakhis_best.ckpt"
|
| 93 |
breakhis_linear = setup_linear(breakhis_path).to(device)
|
| 94 |
|
| 95 |
+
gleason_path = "./gleason_best.ckpt"
|
| 96 |
gleason_linear = setup_linear(gleason_path).to(device)
|
| 97 |
|
| 98 |
+
bach_path = "./bach_best.ckpt"
|
| 99 |
bach_linear = setup_linear(bach_path).to(device)
|
| 100 |
|
| 101 |
+
crc_path = "./crc_best.ckpt"
|
| 102 |
crc_linear = setup_linear_crc(crc_path).to(device)
|
| 103 |
|
| 104 |
|
|
|
|
| 283 |
|
| 284 |
|
| 285 |
if __name__ == "__main__":
|
| 286 |
+
demo.launch()
|