eltorio/ROCOv2-radiology
Viewer β’ Updated β’ 79.8k β’ 15.1k β’ 91
Run WafaaFraih/blip-roco-radiology-captioning on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/WafaaFraih/blip-roco-radiology-captioning. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/WafaaFraih/blip-roco-radiology-captioning on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use WafaaFraih/blip-roco-radiology-captioning with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "image-to-text" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("image-to-text", model="WafaaFraih/blip-roco-radiology-captioning") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("WafaaFraih/blip-roco-radiology-captioning")
model = AutoModelForMultimodalLM.from_pretrained("WafaaFraih/blip-roco-radiology-captioning", device_map="auto")This model is a fine-tuned version of BLIP on the ROCOv2 radiology dataset for generating captions of medical radiology images.
from transformers import BlipForConditionalGeneration, AutoProcessor
from PIL import Image
# Load model and processor
processor = AutoProcessor.from_pretrained("WafaaFraih/blip-roco-radiology-captioning")
model = BlipForConditionalGeneration.from_pretrained("WafaaFraih/blip-roco-radiology-captioning")
# Process image
image = Image.open("radiology_image.jpg")
inputs = processor(images=image, return_tensors="pt")
# Generate caption
generated_ids = model.generate(
pixel_values=inputs["pixel_values"],
max_new_tokens=64,
num_beams=5,
length_penalty=0.8
)
caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
print(caption)