Spaces:
Runtime error
Runtime error
| 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() |