Giter VIP home page Giter VIP logo

tommyix / cxr-llava Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haotian-liu/llava

1.0 0.0 0.0 13.65 MB

CXR-LLaVA for Chest X-ray images report generation. This is the code repository for MBZUAI 23fall AI701 project of Group-7, members: Jinhong Wang, Yongxin Wang, Haokun Lin

Home Page: https://huggingface.co/spaces/TommyIX/CXR-LLaVA

License: Apache License 2.0

Shell 0.52% JavaScript 2.38% Python 94.83% CSS 0.43% HTML 1.83%

cxr-llava's Introduction

CXR-LLaVA: Chest X-Ray Large Language and Vision Assistant

πŸ₯° This project is based on the codebase of LLaVA by Haotian Liu et al. Many thanks to them! As CXR-LLaVA is temporarily not released as a paper, please cite their work if you are further developing on CXR-LLaVA.

πŸ€— We have set up an Online Demo on Huggingface. Try it out!

Install Dependencies

  1. Clone this repository and navigate to LLaVA folder
git clone https://github.com/TommyIX/CXR-LLaVA.git
cd LLaVA
  1. Install Package
conda create -n llava python=3.10 -y
conda activate llava
pip install --upgrade pip  # enable PEP 660 support
pip install -e .
pip install open-clip-torch
  1. If you are going to train the model, you need to run:
pip install -e ".[train]"
pip install flash-attn --no-build-isolation
  1. If you want to rerun the evaluation, please install two mandatory libraries using:
pip install pycocotools pycocoevalcap

Get the model weight

You can download the pretrained weight from Huggingface: CXR-LLaVA-7b if you intend to do the evaluation.

As we are using meta-llama/Llama-2-7b as the base model, you need to follow its instruction to get the model if you want to train CXR-LLaVA from scratch. We are using openai/clip-vit-large-patch14 or microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16 as the vision tower, you can download each weight and change the directory in each training scripts to it. (Relative path is accepted)

Inference on CLI

CXR-LLaVA supports the inference pipeline on LLaVA. Inference on 16-bit can be run on a single 4090. You can refer to llava’s documentation for more details.

python -m llava.serve.cli \
    --model-path TommyIX/CXR-LLaVA-7b \
    --image-file "path/to/your/image.jpg

Train

The pretraining alignment and finetuning are using same set of data. The tuning instructions json file can be downloaded using this link.

Please follow Visual Instruction Tuning part to download the required influencing natural data in /data/images, as saving the open-i data to /data/openi-images. So the data organization would be like:

images
β”œβ”€β”€ coco
β”‚   └── train2017
β”œβ”€β”€ gqa
β”‚   └── images
β”œβ”€β”€ ocr_vqa
β”‚   └── images
β”œβ”€β”€ textvqa
β”‚   └── train_images
β”œβ”€β”€ vg
β”‚   β”œβ”€β”€ VG_100K
β”‚   └── VG_100K_2
β”œβ”€β”€ p11  // These are the MIMIC-CXR data folders
β”œβ”€β”€ p12
β”œβ”€β”€ ...
β”œβ”€β”€ p19
β”œβ”€β”€ xxx1.png  // These are all Open-I raw images.
β”œβ”€β”€ xxx2.png
└── ...

You can download OpenI data on their official website. For the MIMIC-CXR data, please apply for usage on PhysioNet.

You can use scripts/pretrain7b.sh and scripts/finetune7b.sh to conduct stage 1 and stage 2 training.

Evaluation

We are providing eval_caption.py,mimic_caption.py and openi_caption.py in the eval folder. This covers all the experiments conducted in the report. You can specify the model directory and use them to reproduce the results.

Appendices

You are welcomed to open a issue or send me an email if you are encountering any problem in using MIMIC-CXR.

cxr-llava's People

Contributors

haotian-liu avatar chunyuanli avatar mattmazzola avatar eggry avatar yorickvp avatar didier-durand avatar eltociear avatar guanlaoda avatar mao-code avatar hill2hill avatar tommyix avatar abdullamatar avatar teowu avatar dribnet avatar tonywang10101 avatar fvaysh avatar winglian avatar hirethehero avatar yvrjsharma avatar paradoxzw avatar kishida avatar l-salewski avatar omahs avatar payne911 avatar diracdeltas avatar hyj1991 avatar subash-lamichhane avatar simonw avatar shimonmalnick avatar cene555 avatar

Stargazers

Ammar Alfeky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.