Spaces:
Runtime error
Runtime error
File size: 919 Bytes
65b0659 7bda545 65b0659 ff3a836 65b0659 ff3a836 7bda545 ff3a836 65b0659 7bda545 ff3a836 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import torch
import gc
import open_clip
class ModelLoader:
def __init__(self):
self.biomed_model = None
self.preprocess = None
def load_biomed_clip(self):
"""Universal Zero-Shot Auditor (BiomedCLIP)"""
if self.biomed_model is None:
print("π Loading BiomedCLIP Universal Auditor...")
model, _, preprocess = open_clip.create_model_and_transforms(
'hf-hub:microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224'
)
self.biomed_model = model.to("cuda").eval()
self.preprocess = preprocess
return self.biomed_model, self.preprocess
def clear_vram(self):
"""Safety flush to ensure Council stability on T4."""
gc.collect()
if torch.cuda.is_available():
torch.cuda.empty_cache()
# π THIS IS THE CRUCIAL LINE THAT WAS MISSING π
loader = ModelLoader() |