Views
No views yet
chhatramani/Gemma3n_Radiology_v1, a vision-language model (VLM) fine-tuned on the ROCOv2 radiography dataset for Medical Visual Question Answering (VQA). This model leverages the latest Gemma 3N architecture from Google's Gemmaverse, with both its vision and language components fine-tuned for improved performance in the medical domain.chhatramani/Gemma3n_Radiology_v1 is built upon the powerful unsloth/gemma-3n-E2B-it base model. It has undergone parameter-efficient fine-tuning (PEFT) using LoRA adapters, specifically targeting both the vision and language layers, including attention and MLP modules. This approach allows for efficient training by updating only a small percentage of the model's parameters while achieving significant performance gains.unsloth/gemma-3n-E2B-itUnSloth, HuggingFace, TRLfinetune_vision_layers: Truefinetune_language_layers: Truefinetune_attention_modules: Truefinetune_mlp_modules: Truer: 16lora_alpha: 16lora_dropout: 0bias: "none"random_state: 3407use_rslora: Falseloftq_config: Nonetarget_modules: "all-linear"modules_to_save: ["lm_head", "embed_tokens"]UnSloth for optimized performance.1# For Colab notebooks (or similar environments)
2!pip install --no-deps bitsandbytes accelerate xformers==0.0.29.post3 peft trl triton cut_cross_entropy unsloth_zoo
3!pip install sentencepiece protobuf "datasets>=3.4.1,<4.0.0" huggingface_hub hf_transfer
4!pip install --no-deps unsloth
5
6# Install latest transformers and timm for Gemma 3N compatibility
7!pip install --no-deps transformers==4.53.1
8!pip install --no-deps --upgrade timm
9
10Usage (Inference)
11To use this model for inference, you can load it directly from Hugging Face Transformers.
12
13from unsloth import FastVisionModel
14from transformers import AutoProcessor
15import torch
16from PIL import Image
17
18# Load the model and processor
19model, processor = FastVisionModel.from_pretrained(
20 "chhatramani/Gemma3n_Radiology_v1",
21 load_in_4bit = True, # Use 4bit for inference to reduce memory use
22)
23
24# Example Usage:
25# You can replace this with your own medical image and question
26image_path = "path/to/your/medical_image.jpg" # Replace with an actual image path
27image = Image.open(image_path).convert("RGB")
28
29# Prepare inputs
30prompt = "What medical condition is shown in this image?"
31inputs = processor(images=image, text=prompt, return_tensors="pt").to("cuda")
32
33# Generate response
34outputs = model.generate(**inputs, max_new_tokens=200)
35
36# Decode and print the output
37generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0]
38print(generated_text)
39
40Dataset Information
41The ROCOv2 (Radiology Objects in Context) dataset is a comprehensive collection of radiology images and their corresponding expert-written captions. The sampled version used for this fine-tuning, unsloth/Radiology_mini, provides a subset suitable for efficient experimentation and training.
42
43Dataset Features:
44
45image: The medical image (X-ray, CT scan, ultrasound).
46
47image_id: Unique identifier for the image.
48
49caption: Expert-written description of the medical image.
50
51cui: Concept Unique Identifier (from UMLS Metathesaurus), providing standardized medical terminology.