Views
No views yet
| Fichier | Description |
|---|---|
rcmt_unet_v4_final.pth | Poids segmentation RCMTUNetV4 |
pipeline.py | Architecture complète (toutes classes) |
rag_who_chunks.json | 40 chunks RAG WHO CNS 2021 |
rag_faiss.index | Index FAISS pré-calculé |
rag_embeddings.npy | Embeddings numpy (backup) |
prompts.json | Tous les prompts v3.2 + profils ACP |
config.json | Configuration et métriques |
evaluation_metrics.json | Résultats détaillés |
| Métrique | Score | vs Baseline |
|---|---|---|
| BERTScore-F | 0.814 | > MediVLM (0.616) ✅ |
| TBFact | 0.922 | > BTReport (0.353) ✅ |
| RadGraph-F1 | 0.871 | > AutoRG (0.380) ✅ |
| Anti-hallucination | 1.000 | UNIQUE ✅ |
| Cross-validation | 1.000 | UNIQUE ✅ |
| Global score | 0.852 | Classe A ✅ |
1import torch, json, faiss, numpy as np
2from huggingface_hub import hf_hub_download, snapshot_download
3from sentence_transformers import SentenceTransformer
4
5# 1. Télécharger tous les fichiers
6local_dir = snapshot_download(repo_id="mayoula/rcmt-unet-v4-vlm")
7
8# 2. Charger l'architecture
9import sys; sys.path.insert(0, local_dir)
10from pipeline import RCMTUNetV4
11
12# 3. Charger les poids segmentation
13seg_model = RCMTUNetV4(in_channels=4, out_channels=4, features=(24,48,96,192))
14seg_model.load_state_dict(torch.load(f"{local_dir}/rcmt_unet_v4_final.pth", map_location="cpu"))
15seg_model.eval()
16
17# 4. Charger le RAG
18with open(f"{local_dir}/rag_who_chunks.json") as f:
19 rag_data = json.load(f)
20WHO_CHUNKS = rag_data["chunks"]
21faiss_idx = faiss.read_index(f"{local_dir}/rag_faiss.index")
22embedder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
23
24# 5. Charger les prompts
25with open(f"{local_dir}/prompts.json") as f:
26 prompts = json.load(f)
27
28# 6. Charger le VLM (LLaVA-Med — non fine-tuné, rechargé depuis HF)
29from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration, BitsAndBytesConfig
30bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16,
31 bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True)
32vlm_processor = LlavaNextProcessor.from_pretrained("microsoft/llava-med-v1.5-mistral-7b")
33vlm_model = LlavaNextForConditionalGeneration.from_pretrained(
34 "microsoft/llava-med-v1.5-mistral-7b", quantization_config=bnb, device_map="auto")
35
36# 7. Fonction RAG retrieve
37def rag_retrieve(query, top_k=4):
38 emb = embedder.encode([query], normalize_embeddings=True)
39 D, I = faiss_idx.search(emb.astype(np.float32), top_k)
40 refs = [f"[REF-{r+1}] {WHO_CHUNKS[i]}" for r, (d, i) in enumerate(zip(D[0], I[0])) if d > 0.10]
41 return "\n".join(refs) if refs else "Standard glioma protocol (WHO CNS 2021)."