cgus commited on
Commit
0944b18
·
verified ·
1 Parent(s): 404b0f8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +170 -0
README.md ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - prithivMLmods/Radiology-Infer-Mini
7
+ pipeline_tag: image-text-to-text
8
+ tags:
9
+ - Radiology
10
+ - Infer
11
+ - Qwen2
12
+ - 2B
13
+ ---
14
+ # Radiology-Infer-Mini-iMat-GGUF
15
+ Original model: [Radiology-Infer-Mini](https://huggingface.co/prithivMLmods/Radiology-Infer-Mini) by [prithivMLmods](https://huggingface.co/prithivMLmods)
16
+ Based on: [Qwen2-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct) by [Qwen](https://huggingface.co/Qwen)
17
+
18
+ ## Quantization notes
19
+ Made with llama.cpp-b4608 with imatrix file based on Exllamav2 calibration data.
20
+
21
+ # Original model card
22
+ ![3.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/lLU2lEv76EIL3aNeMHy0Q.png)
23
+
24
+ # **Radiology-Infer-Mini**
25
+
26
+ Radiology-Infer-Mini is a vision-language model fine-tuned from the Qwen2-VL-2B framework, specifically designed to excel in radiological analysis, text extraction, and medical report generation. It integrates advanced multi-modal capabilities with domain-specific expertise, ensuring accurate and efficient processing of radiology-related tasks.
27
+
28
+ ### Key Enhancements:
29
+
30
+ 1. **State-of-the-Art Understanding of Medical Images**
31
+ Radiology-Infer-Mini achieves cutting-edge performance in interpreting complex medical imagery, including X-rays, MRIs, CT scans, and ultrasounds. It is fine-tuned on healthcare-specific benchmarks to ensure precise recognition of anatomical and pathological features.
32
+
33
+ 2. **Support for Extended Medical Reports and Cases**
34
+ Capable of processing and analyzing extensive radiology case studies, Radiology-Infer-Mini can generate high-quality diagnostic reports and answer complex medical queries with detailed explanations. Its proficiency extends to multi-page radiology documents, ensuring comprehensive visual and textual understanding.
35
+
36
+ 3. **Integration with Medical Devices**
37
+ With robust reasoning and decision-making capabilities, Radiology-Infer-Mini can seamlessly integrate with medical imaging systems and robotic platforms. It supports automated workflows for tasks such as diagnosis support, triaging, and clinical decision-making.
38
+
39
+ 4. **Math and Diagram Interpretation**
40
+ Equipped with LaTeX support and advanced diagram interpretation capabilities, Radiology-Infer-Mini handles mathematical annotations, statistical data, and visual charts present in medical reports with precision.
41
+
42
+ 5. **Multilingual Support for Medical Text**
43
+ Radiology-Infer-Mini supports the extraction and interpretation of multilingual texts embedded in radiological images, including English, Chinese, Arabic, Korean, Japanese, and most European languages. This feature ensures accessibility for a diverse global healthcare audience.
44
+
45
+ Radiology-Infer-Mini represents a transformative step in radiology-focused AI, enhancing productivity and accuracy in medical imaging and reporting.
46
+
47
+ ![radiology.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/S0JuOoKkXmXgj4li6a9OZ.png)
48
+
49
+ ### How to Use
50
+
51
+ ```python
52
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
53
+ from qwen_vl_utils import process_vision_info
54
+
55
+ # default: Load the model on the available device(s)
56
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
57
+ "prithivMLmods/Radiology-Infer-Mini", torch_dtype="auto", device_map="auto"
58
+ )
59
+
60
+ # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
61
+ # model = Qwen2VLForConditionalGeneration.from_pretrained(
62
+ # "prithivMLmods/Radiology-Infer-Mini",
63
+ # torch_dtype=torch.bfloat16,
64
+ # attn_implementation="flash_attention_2",
65
+ # device_map="auto",
66
+ # )
67
+
68
+ # default processer
69
+ processor = AutoProcessor.from_pretrained("prithivMLmods/Radiology-Infer-Mini")
70
+
71
+ # The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
72
+ # min_pixels = 256*28*28
73
+ # max_pixels = 1280*28*28
74
+ # processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
75
+
76
+ messages = [
77
+ {
78
+ "role": "user",
79
+ "content": [
80
+ {
81
+ "type": "image",
82
+ "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
83
+ },
84
+ {"type": "text", "text": "Describe this image."},
85
+ ],
86
+ }
87
+ ]
88
+
89
+ # Preparation for inference
90
+ text = processor.apply_chat_template(
91
+ messages, tokenize=False, add_generation_prompt=True
92
+ )
93
+ image_inputs, video_inputs = process_vision_info(messages)
94
+ inputs = processor(
95
+ text=[text],
96
+ images=image_inputs,
97
+ videos=video_inputs,
98
+ padding=True,
99
+ return_tensors="pt",
100
+ )
101
+ inputs = inputs.to("cuda")
102
+
103
+ # Inference: Generation of the output
104
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
105
+ generated_ids_trimmed = [
106
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
107
+ ]
108
+ output_text = processor.batch_decode(
109
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
110
+ )
111
+ print(output_text)
112
+ ```
113
+ ### Buf
114
+ ```python
115
+ buffer = ""
116
+ for new_text in streamer:
117
+ buffer += new_text
118
+ # Remove <|im_end|> or similar tokens from the output
119
+ buffer = buffer.replace("<|im_end|>", "")
120
+ yield buffer
121
+ ```
122
+ ### **Intended Use**
123
+
124
+ **Radiology-Infer-Mini** is designed to support healthcare professionals and researchers in tasks involving medical imaging and radiological analysis. Its primary applications include:
125
+
126
+ 1. **Diagnostic Support**
127
+ - Analyze medical images (X-rays, MRIs, CT scans, ultrasounds) to identify abnormalities, annotate findings, and assist radiologists in forming diagnostic conclusions.
128
+
129
+ 2. **Medical Report Generation**
130
+ - Automatically generate structured radiology reports from image data, reducing documentation time and improving workflow efficiency.
131
+
132
+ 3. **Educational and Research Tools**
133
+ - Serve as a teaching aid for radiology students and support researchers in large-scale studies by automating image labeling and data extraction.
134
+
135
+ 4. **Workflow Automation**
136
+ - Integrate with medical devices and hospital systems to automate triaging, anomaly detection, and report routing in clinical settings.
137
+
138
+ 5. **Multi-modal Applications**
139
+ - Handle complex tasks involving both images and text, such as extracting patient data from images and synthesizing text-based findings with visual interpretations.
140
+
141
+ 6. **Global Accessibility**
142
+ - Support multilingual radiological text understanding for use in diverse healthcare settings around the world.
143
+
144
+ ### **Limitations**
145
+
146
+ While **Radiology-Infer-Mini** offers advanced capabilities, it has the following limitations:
147
+
148
+ 1. **Medical Expertise Dependency**
149
+ - The model provides supplementary insights but cannot replace the expertise and judgment of a licensed radiologist or clinician.
150
+
151
+ 2. **Data Bias**
152
+ - Performance may vary based on the training data, which might not fully represent all imaging modalities, patient demographics, or rare conditions.
153
+
154
+ 3. **Edge Cases**
155
+ - Limited ability to handle edge cases, highly complex images, or uncommon medical scenarios that were underrepresented in its training dataset.
156
+
157
+ 4. **Regulatory Compliance**
158
+ - It must be validated for compliance with local medical regulations and standards before clinical use.
159
+
160
+ 5. **Interpretation Challenges**
161
+ - The model may misinterpret artifacts, noise, or low-quality images, leading to inaccurate conclusions in certain scenarios.
162
+
163
+ 6. **Multimodal Integration**
164
+ - While capable of handling both visual and textual inputs, tasks requiring deep contextual understanding across different modalities might yield inconsistent results.
165
+
166
+ 7. **Real-Time Limitations**
167
+ - Processing speed and accuracy might be constrained in real-time or high-throughput scenarios, especially on hardware with limited computational resources.
168
+
169
+ 8. **Privacy and Security**
170
+ - Radiology-Infer-Mini must be used in secure environments to ensure the confidentiality and integrity of sensitive medical data.