Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
ECOFRI b7403b7e4f | 1 month ago | |
---|---|---|
CXR_LLAVA_HF | 3 months ago | |
IMG | 6 months ago | |
README.md | 1 month ago | |
main.py | 6 months ago | |
requirements.txt | 3 months ago |
CXR LLaVA is an innovative open-source, multimodal large language model specifically designed for generating radiologic reports from chest X-ray images.
Version | Input CXR resolution | Channels | Vision Encoder | Base LLM | Weight |
---|---|---|---|---|---|
v1.0 | 512x512 | RGB | RN50 | LLAMA2-13B-CHAT | Deprecated |
v2.0.1 (Latest) | 512x512 | Grayscale | ViT-L/16 | LLAMA2-7B-CHAT | Link |
You can interpret CXR with just 6 lines of code.
(NVIDIA GPU VRAM>14GB needed)
from transformers import AutoModel
from PIL import Image
model = AutoModel.from_pretrained("ECOFRI/CXR-LLAVA-v2", trust_remote_code=True)
model = model.to("cuda")
cxr_image = Image.open("img.jpg")
response = model.write_radiologic_report(cxr_image)
The radiologic report reveals a large consolidation in the right upper lobe of the lungs. There is no evidence of pleural effusion or pneumothorax. The cardiac and mediastinal contours are normal.
Before you begin, make sure you have PyTorch installed. After confirming that PyTorch is installed, you can install the additional required dependencies. Run the following command in your terminal or command prompt:
pip install transformers sentencepiece protobuf pillow
from transformers import AutoModel
from PIL import Image
Ensure you have an CXR image file ready, such as 'img.jpg'.
Use the following code to load the image
cxr_image = Image.open("img.jpg")
Loading the CXR-LLAVA model is straightforward and can be done in one line of code.
model = AutoModel.from_pretrained("ECOFRI/CXR-LLAVA-v2", trust_remote_code=True)
model = model.to("cuda")
To write a radiologic report of a chest radiograph:
response = model.write_radiologic_report(cxr_image)
The radiologic report reveals a large consolidation in the right upper lobe of the lungs. There is no evidence of pleural effusion or pneumothorax. The cardiac and mediastinal contours are normal.
For differential diagnosis:
response = model.write_differential_diagnosis(cxr_image)
Possible differential diagnoses for this patient include pneumonia,tuberculosis, lung abscess, or a neoplastic process such as lung cancer.
To ask a question:
question = "What is true meaning of consolidation?"
response = model.ask_question(question=question, image=cxr_image)
Consolidation refers to the filling of the airspaces in the lungs with fluid, pus, blood, cells or other substances, resulting in a region of lung tissue that has become dense and solid rather than containing air.
For custom interactions:
img = Image.open("img.jpg")
chat = [
{"role": "system",
"content": "You are a helpful radiologist. Try to interpret chest x ray image and answer to the question that user provides."},
{"role": "user",
"content": "<image>\nWrite a radiologic report on the given chest radiograph, including information about atelectasis, cardiomegaly, consolidation, pulmonary edema, pleural effusion, and pneumothorax.\n"}
]
response = model.generate_cxr_repsonse(chat=chat,pil_image=img, temperature=0, top_p=1)
CXR LLaVA is available under a Creative Commons NonCommercial License.
Users must obtain the LLAMA-2 license prior to use. More details can be found here.
Lastly, we extend our heartfelt thanks to all the contributors of the LLaVA project.
No Description
Python Text
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》