Downloads · 30 days
8
3% of all-time downloads
mychen76/Florence2-FT-Med-brain-6
Florence2-FT-Med-brain-6 is a image-text-to-text model from mychen76. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Visual Analysis of Brain CT Image and Region of Interest.
Downloads · 30 days
8
3% of all-time downloads
All-time downloads
299
Public
Parameters
823M
3.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.3 GB · 100%
From the Hugging Face model README
Visual Analysis of Brain CT Image and Region of Interest.
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-6"
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]'}"
Visual Analysis of Brain CT Image and Region of Interest.
<!-- Provide a longer summary of what this model is. -->This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]