Model Card for Model ID
Visual Analysis of Brain CT Image and Region of Interest.
Model Usage
load model
from transformers import AutoModelForCausalLM, AutoProcessor
# Set device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load fine-tuned model and processor
model_id_or_path = "mychen76/Florence2-FT-Med-brain-7"
model = AutoModelForCausalLM.from_pretrained(model_id_or_path, trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained(model_id_or_path, trust_remote_code=True)
Inference
def run_model_inference(task_prompt, text_input, image, device="cpu"):
if text_input is None:
prompt = task_prompt
else:
prompt = task_prompt + text_input
# print("PROMPT=",prompt)
# Ensure the image is in RGB mode
if image.mode != "RGB":
image = image.convert("RGB")
inputs = processor(text=prompt, images=image, return_tensors="pt").to(device)
generated_ids = model.generate(
input_ids=inputs["input_ids"],
pixel_values=inputs["pixel_values"],
max_new_tokens=1024,
num_beams=3
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
parsed_answer = processor.post_process_generation(generated_text, task=task_prompt, image_size=(image.width, image.height))
return parsed_answer
Task Image Caption
results = run_model_inference("<CAPTION>",None,test_image,device)
print(results)
result
{'<CAPTION>': '<CAPTION>The image is a non-contrast computed tomography (CT) scan of the brain, showing the cerebral hemispheres without any medical devices present. The region of interest, located centrally and in the middle of the image, occupies approximately 1.5% of the area and appears to have a different density compared to the surrounding brain tissue, which may indicate an intracranial hemorrhage. This abnormal area could be related to the brain structures, potentially leading to a mass effect or displacement of adjacent brain tissue.'}
Task Image Caption Details
results = run_model_inference("<CAPTION_DETAILS>",None,test_image,device)
print(results)
result
{'<CAPTION_DETAILS>': '<CAPTION_DETAILS>The image is a non-contrast computed tomography (CT) scan of the brain, showing the cerebral hemispheres without any medical devices present. The region of interest, located centrally and in the middle of the image, occupies approximately 1.5% of the area and appears to have a different density compared to the surrounding brain tissue, which may indicate an intracranial hemorrhage. This abnormality is likely related to the brain structures, potentially affecting them or being affected by a mass effect or displacement of adjacent brain tissue.'}
Task Region of Interest
results = run_model_inference("<REGION_OF_INTEREST>",None,test_image,device)
print(results)
result
{'<REGION_OF_INTEREST>': '<REGION_OF_INTEREST>The region of interest, located centrally and in the lower-middle area of the brain, occupies approximately 1.5% of the image area and appears to have a different density compared to the surrounding brain tissue, which may indicate an intracranial hemorrhage.\n<OBSERVATION>\nThis abnormality is likely related to the brain structures, potentially affecting them or being affected by a mass effect or displacement of adjacent brain tissue.'}
Task Json Record
results=run_model_inference("<JSON_RECORD>",None,test_image,device)
record=results["<JSON_RECORD>"].split("<JSON_RECORD>")[1]
record
result
"{'caption': 'The image is a non-contrast computed tomography (CT) scan of the brain, showing the cerebral hemispheres, ventricles, and subarachnoid spaces without any medical devices visible. The region of interest, located centrally and in the lower-middle area of the image, occupies approximately 1.5% of the area and appears to have a different density compared to the surrounding brain tissue, which may indicate an intracranial hemorrhage. This abnormal area could be related to or be affected by adjacent brain structures, potentially leading to a mass effect or displacement of adjacent brain tissue due to the presence of blood or a hematoma.'region of interest': 'This abnormal area is situated near the lateral ventricle, which is indicative of a hemorrhage, and could be exerting pressure or pressure on nearby brain structures due to its proximity to other cerebral structures.\\nThe relationship between this abnormal area and the surrounding cerebral structures suggests that the hemorrhage could be affecting or be affecting adjacent brain areas due to their proximity and displacement of nearby brain tissue.', 'observation': '', 'The abnormal area appears to be in a different area, possibly representing a hemorrhaged area, and is likely related to the adjacent brain regions, potentially affecting or being affected by nearby brain tissues due to it's proximity to nearby cerebral structures, although the relationship does not imply a significant difference in density or displacement within the brain tissue. 'bbox': '[212.7360076904297, 203.52000427246094, 252.16001892089844, 343.8080139160156]'}"
Task Detect Region of Interest Location
results=run_model_inference("<DETECT_REGION_LOC>",None,test_image,device)
print(results)
result
{'<DETECT_REGION_LOC>': '<DETECT_REGION_LOC>{"bloc": "<loc_213><loc_204><loc_253><loc_344>", "bbox": "[212.7360076904297, 203.52000427246094, 252.16001892089844, 343.8080139160156]"}'}
Task Region to Description
results=run_model_inference("<REGION_LOC_DESCRIPTION>",None,test_image,device)
print(results)
result
{'<REGION_LOC_DESCRIPTION>': '<REGION_LOC_DESCRIPTION>The image is a non-contrast computed tomography (CT) scan of the brain, showing the cerebral structures without any medical devices present. The region of interest, located centrally and in the middle of the image, occupies approximately 2.8% of the area and appears to have a different density compared to the surrounding brain tissue, which may indicate an intracranial hemorrhage. This abnormal area could be affecting or be affected by adjacent brain structures, potentially leading to a mass effect or displacement of adjacent tissues.'}
Model Description
Visual Analysis of Brain CT Image and Region of Interest.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
- Developed by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Model type: [More Information Needed]
- Language(s) (NLP): [More Information Needed]
- License: [More Information Needed]
- Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
- Downloads last month
- 25