Anonymous-AC commited on
Commit
38c2252
·
verified ·
1 Parent(s): 5287d1a

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ examples/26746130963764173994750391023442607773-2_mukhp1.png filter=lfs diff=lfs merge=lfs -text
37
+ examples/f1eb2216d773ced6330b1f31e18f04f8.png filter=lfs diff=lfs merge=lfs -text
38
+ examples/fb4dfacc089f4b5550f03f52e706b6f2.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,14 +1,14 @@
1
  ---
2
- title: Demo
3
- emoji: 📊
4
- colorFrom: green
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.38.0
8
  app_file: app.py
9
  pinned: false
10
- license: apache-2.0
11
- short_description: This is a Demo for our K2Sight Model :)
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: K2-Sight Anonymous Demo
3
+ emoji: 🚀
4
+ colorFrom: yellow
5
+ colorTo: gray
6
+ sdk: streamlit
7
+ sdk_version: 1.42.2
8
  app_file: app.py
9
  pinned: false
10
+ license: cc-by-4.0
11
+ short_description: The demo allows users to upload and analyze chest X-ray.
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import os
2
+ # os.environ["HF_HOME"] = "/tmp/hf_cache"
3
+ import streamlit as st
4
+ from PIL import Image
5
+ import torch
6
+ from transformers import AutoModelForCausalLM, AutoProcessor
7
+ import numpy as np
8
+ import supervision as sv
9
+ import albumentations as A
10
+ import cv2
11
+ from transformers import AutoConfig
12
+ import yaml
13
+
14
+ # Set Streamlit page configuration for a wide layout
15
+ st.set_page_config(layout="wide")
16
+
17
+ # Custom CSS for better layout and mobile responsiveness
18
+ st.markdown("""
19
+ <style>
20
+ .main {
21
+ max-width: 1200px; /* Max width for content */
22
+ margin: 0 auto;
23
+ }
24
+ .block-container {
25
+ padding-top: 2rem;
26
+ padding-bottom: 2rem;
27
+ padding-left: 3rem;
28
+ padding-right: 3rem;
29
+ }
30
+ .title {
31
+ font-size: 3.2rem;
32
+ text-align: center;
33
+ background: linear-gradient(135deg, #0575e6 0%, #ff0080 50%, #7928ca 100%);
34
+ -webkit-background-clip: text;
35
+ -webkit-text-fill-color: transparent;
36
+ background-clip: text;
37
+ }
38
+
39
+ @keyframes gradientShift {
40
+ 0% { background-position: 0% 50%; }
41
+ 50% { background-position: 100% 50%; }
42
+ 100% { background-position: 0% 50%; }
43
+ }
44
+ .subheader {
45
+ font-size: 1.5rem;
46
+ margin-bottom: 20px;
47
+ }
48
+ .btn {
49
+ font-size: 1.1rem;
50
+ padding: 10px 20px;
51
+ background-color: #FF6347;
52
+ color: white;
53
+ border-radius: 5px;
54
+ border: none;
55
+ cursor: pointer;
56
+ }
57
+ .btn:hover {
58
+ background-color: #FF4500;
59
+ }
60
+ .column-spacing {
61
+ display: flex;
62
+ justify-content: space-between;
63
+ }
64
+ .col-half {
65
+ width: 48%;
66
+ }
67
+ .col-full {
68
+ width: 100%;
69
+ }
70
+ .instructions {
71
+ padding: 20px;
72
+ background-color: #f9f9f9;
73
+ border-radius: 8px;
74
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
75
+ }
76
+ </style>
77
+ """, unsafe_allow_html=True)
78
+
79
+ # Load Model and Processor
80
+ @st.cache_resource
81
+ def load_model():
82
+ MODEL_NAME = 'Anonymous-AC/K2Sight-Lite'
83
+ DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
84
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, trust_remote_code=True).to(DEVICE)
85
+ processor = AutoProcessor.from_pretrained(MODEL_NAME, trust_remote_code=True)
86
+ processor.image_processor.size = 512
87
+ processor.image_processor.crop_size = 512
88
+
89
+ return model, processor, DEVICE
90
+
91
+ model, processor, DEVICE = load_model()
92
+
93
+ # Load Definitions
94
+ @st.cache_resource
95
+ def load_definitions():
96
+ vindr_path = 'configs/vindr_definition.yaml'
97
+ padchest_path = 'configs/padchest_definition.yaml'
98
+ prompt_path = 'examples/prompt.yaml'
99
+
100
+ with open(vindr_path, 'r') as file:
101
+ vindr_definitions = yaml.safe_load(file)
102
+ with open(padchest_path, 'r') as file:
103
+ padchest_definitions = yaml.safe_load(file)
104
+ with open(prompt_path, 'r') as file:
105
+ prompt_definitions = yaml.safe_load(file)
106
+
107
+ return vindr_definitions, padchest_definitions, prompt_definitions
108
+
109
+ vindr_definitions, padchest_definitions, prompt_definitions = load_definitions()
110
+
111
+ dataset_options = {"Vindr": vindr_definitions, "PadChest": padchest_definitions}
112
+
113
+ def load_example_images():
114
+ return list(prompt_definitions.keys())
115
+
116
+ example_images = load_example_images()
117
+
118
+ def apply_transform(image, size_mode=512):
119
+ pad_resize_transform = A.Compose([
120
+ A.LongestMaxSize(max_size=size_mode, interpolation=cv2.INTER_AREA),
121
+ A.PadIfNeeded(min_height=size_mode, min_width=size_mode, border_mode=cv2.BORDER_CONSTANT, value=(0, 0, 0)),
122
+ A.Resize(height=512, width=512, interpolation=cv2.INTER_AREA),
123
+ ])
124
+ image_np = np.array(image)
125
+ transformed = pad_resize_transform(image=image_np)
126
+ return transformed["image"]
127
+
128
+ # Streamlit UI with Colorful Title and Emojis
129
+ # st.markdown("<div style='text-align: center;'><span style='font-size: 3rem;'>🩺</span></div>", unsafe_allow_html=True)
130
+ st.markdown("<h1 class='title'>Knowledge to Sight: Reasoning over Visual Attributes via Knowledge Decomposition for Abnormality Grounding</h1>", unsafe_allow_html=True)
131
+ # st.markdown("<div style='text-align: center;'><span style='font-size: 3rem;'>🚀</span></div>", unsafe_allow_html=True)
132
+ st.markdown(
133
+ "<p style='text-align: center; font-size: 18px;'>Welcome to a simple demo of our work! 🎉 Choose an example or upload your own image to get started! 👇</p>",
134
+ unsafe_allow_html=True
135
+ )
136
+
137
+ # Display Example Images First
138
+ st.subheader("🌄 Example Images")
139
+ selected_example = st.selectbox("Choose an example", example_images)
140
+ image = Image.open(selected_example).convert("RGB")
141
+ example_diseases = prompt_definitions.get(selected_example, [])
142
+ st.write("**Associated Diseases:**", ", ".join(example_diseases))
143
+
144
+ # Layout for Original Image and Instructions
145
+ col1, col2 = st.columns([1, 2])
146
+
147
+ # Left column for original image
148
+ with col1:
149
+ st.image(image, caption=f"Original Example Image: {selected_example}", width=400)
150
+
151
+ # Right column for Instructions and Run Inference Button
152
+ with col2:
153
+ st.subheader("⚙️ Instructions to Get Started:")
154
+ st.write("""
155
+ - **Run Inference**: Click the "Run Inference on Example" button to process the image and display the results.
156
+ - **Choose an Example**: 🌄 Select an example image from the dataset to view its associated diseases.
157
+ - **Upload Your Own Image**: 📤 Upload an image of your choice to analyze it for diseases.
158
+ - **Select Dataset**: 📚 Choose between available datasets (Vindr or PadChest) for disease information.
159
+ - **Select Disease**: 🦠 Pick the disease to be analyzed from the list of diseases in the selected dataset.
160
+ """)
161
+
162
+ st.subheader("⚠️ Warning:")
163
+ st.write("""
164
+ - **🚫 Please avoid uploading non-frontal chest X-ray images.** Our model has been specifically trained on **frontal chest X-ray images** only.
165
+ - This demo is intended for **🔬 research purposes only** and should **❌ not be used for medical diagnoses**.
166
+ - The model’s responses may contain **<span style='color:#dc3545; font-weight:bold;'>🤖 hallucinations or incorrect information</span>**.
167
+ - Always consult a **<span style='color:#dc3545; font-weight:bold;'>👨‍⚕️ medical professional</span>** for accurate diagnosis and advice.
168
+ """, unsafe_allow_html=True)
169
+
170
+
171
+ st.markdown("</div>", unsafe_allow_html=True)
172
+
173
+ # Run Inference Button
174
+ if st.button("Run Inference on Example", key="example"):
175
+ if image is None:
176
+ st.error("❌ Please select an example image first.")
177
+ else:
178
+ # Use the selected example's disease and definition for inference
179
+ disease_choice = example_diseases[0] if example_diseases else ""
180
+ definition = vindr_definitions.get(disease_choice, padchest_definitions.get(disease_choice, ""))
181
+
182
+ # Generate the prompt for the model
183
+ det_obj = f"{disease_choice} means {definition}."
184
+ st.write(f"**Definition:** {definition}")
185
+ prompt = f"Locate the phrases in the caption: {det_obj}."
186
+ prompt = f"<CAPTION_TO_PHRASE_GROUNDING>{prompt}"
187
+
188
+ # Prepare the image and input
189
+ np_image = np.array(image)
190
+ inputs = processor(text=[prompt], images=[np_image], return_tensors="pt", padding=True).to(DEVICE)
191
+
192
+ with st.spinner("Processing... ⏳"):
193
+ outputs = model.generate(
194
+ input_ids=inputs["input_ids"],
195
+ pixel_values=inputs["pixel_values"],
196
+ max_new_tokens=1024,
197
+ num_beams=3,
198
+ output_scores=True, # Make sure we get the scores/logits
199
+ return_dict_in_generate=True # Ensures you get both sequences and scores in the output
200
+ )
201
+
202
+
203
+ # Ensure transition_scores is properly extracted
204
+ transition_scores = model.compute_transition_scores(
205
+ outputs.sequences, outputs.scores, outputs.beam_indices, normalize_logits=False
206
+ )
207
+
208
+ # Get the generated token IDs (ignoring the input tokens part)
209
+ generated_ids = outputs.sequences
210
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
211
+
212
+ # Get input length
213
+ input_length = inputs.input_ids.shape[1]
214
+ generated_tokens = outputs.sequences
215
+
216
+ # Calculate output length (number of generated tokens)
217
+ output_length = np.sum(transition_scores.cpu().numpy() < 0, axis=1)
218
+
219
+ # Get length penalty
220
+ length_penalty = model.generation_config.length_penalty
221
+
222
+ # Calculate total score for the generated sentence
223
+ reconstructed_scores = transition_scores.cpu().sum(axis=1) / (output_length**length_penalty)
224
+
225
+ # Convert log-probability to probability (0-1 range)
226
+ probabilities = np.exp(reconstructed_scores.cpu().numpy())
227
+
228
+ # Streamlit UI to display the result
229
+ st.markdown(f"**🎯 Probability of the Results:** <span style='color:#28a745; font-size:24px; font-weight:bold;'>{probabilities[0] * 100:.2f}%</span>", unsafe_allow_html=True)
230
+
231
+
232
+ predictions = processor.post_process_generation(generated_text, task="<CAPTION_TO_PHRASE_GROUNDING>", image_size=np_image.shape[:2])
233
+
234
+ detection = sv.Detections.from_lmm(sv.LMM.FLORENCE_2, predictions, resolution_wh=np_image.shape[:2])
235
+
236
+ # Annotate the image with bounding boxes and labels
237
+ bounding_box_annotator = sv.BoundingBoxAnnotator(color_lookup=sv.ColorLookup.INDEX)
238
+ label_annotator = sv.LabelAnnotator(color_lookup=sv.ColorLookup.INDEX)
239
+ image_with_predictions = bounding_box_annotator.annotate(np_image.copy(), detection)
240
+ image_with_predictions = label_annotator.annotate(image_with_predictions, detection)
241
+ annotated_image = Image.fromarray(image_with_predictions.astype(np.uint8))
242
+
243
+ # Display the original and result images side by side
244
+ col1, col2 = st.columns([1, 1])
245
+
246
+ with col1:
247
+ st.image(image, caption=f"Original Image: {selected_example}", width=400)
248
+
249
+ with col2:
250
+ st.image(annotated_image, caption="Inference Results 🖼️", width=400)
251
+
252
+ # Display the generated text
253
+ st.write("**Generated Text:**", generated_text)
254
+
255
+ # Upload Image section
256
+ st.subheader("📤 Upload Your Own Image")
257
+
258
+ col1, col2 = st.columns([1, 1])
259
+ with col1:
260
+ dataset_choice = st.selectbox("Select Dataset 📚", options=list(dataset_options.keys()))
261
+ disease_options = list(dataset_options[dataset_choice].keys())
262
+ with col2:
263
+ disease_choice = st.selectbox("Select Disease 🦠", options=disease_options)
264
+
265
+ uploaded_file = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])
266
+
267
+
268
+ col1, col2 = st.columns([1, 2])
269
+
270
+ with col1:
271
+ # Handle file upload
272
+ if uploaded_file:
273
+ image = Image.open(uploaded_file).convert("RGB")
274
+ image = apply_transform(image) # Ensure the uploaded image is transformed correctly
275
+ st.image(image, caption="Uploaded Image", width=400)
276
+
277
+ # Let user select dataset and disease dynamically
278
+ disease_choice = disease_choice if disease_choice else example_diseases[0]
279
+
280
+ # Get Definition Priority: Dataset -> User Input
281
+ definition = vindr_definitions.get(disease_choice, padchest_definitions.get(disease_choice, ""))
282
+ if not definition:
283
+ definition = st.text_input("Enter Definition Manually 📝", value="")
284
+
285
+ with col2:
286
+ # Instructions and warnings
287
+ st.subheader("⚙️ Instructions to Get Started:")
288
+ st.write("""
289
+ - **Run Inference**: Click the "Run Inference on Example" button to process the image and display the results.
290
+ - **Choose an Example**: 🌄 Select an example image from the dataset to view its associated diseases.
291
+ - **Upload Your Own Image**: 📤 Upload an image of your choice to analyze it for diseases.
292
+ - **Select Dataset**: 📚 Choose between available datasets (Vindr or PadChest) for disease information.
293
+ - **Select Disease**: 🦠 Pick the disease to be analyzed from the list of diseases in the selected dataset.
294
+ """)
295
+
296
+ st.subheader("⚠️ Warning:")
297
+ st.write("""
298
+ - **🚫 Please avoid uploading non-frontal chest X-ray images.** Our model has been specifically trained on **frontal chest X-ray images** only.
299
+ - This demo is intended for **🔬 research purposes only** and should **❌ not be used for medical diagnoses**.
300
+ - The model’s responses may contain **<span style='color:#dc3545; font-weight:bold;'>🤖 hallucinations or incorrect information</span>**.
301
+ - Always consult a **<span style='color:#dc3545; font-weight:bold;'>👨‍⚕️ medical professional</span>** for accurate diagnosis and advice.
302
+ """, unsafe_allow_html=True)
303
+
304
+ # Run inference after upload
305
+ if st.button("Run Inference 🏃‍♂️"):
306
+ if image is None:
307
+ st.error("❌ Please upload an image or select an example.")
308
+ else:
309
+ det_obj = f"{disease_choice} means {definition}."
310
+ st.write(f"**Definition:** {definition}")
311
+
312
+ # Construct Prompt with Disease Definition
313
+ prompt = f"Locate the phrases in the caption: {det_obj}."
314
+ prompt = f"<CAPTION_TO_PHRASE_GROUNDING>{prompt}"
315
+
316
+ np_image = np.array(image)
317
+ inputs = processor(text=[prompt], images=[np_image], return_tensors="pt", padding=True).to(DEVICE)
318
+
319
+ with st.spinner("Processing... ⏳"):
320
+ # generated_ids = model.generate(input_ids=inputs["input_ids"], pixel_values=inputs["pixel_values"], max_new_tokens=1024, num_beams=3)
321
+ # generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
322
+
323
+ outputs = model.generate(
324
+ input_ids=inputs["input_ids"],
325
+ pixel_values=inputs["pixel_values"],
326
+ max_new_tokens=1024,
327
+ num_beams=3,
328
+ output_scores=True, # Make sure we get the scores/logits
329
+ return_dict_in_generate=True # Ensures you get both sequences and scores in the output
330
+ )
331
+
332
+ transition_scores = model.compute_transition_scores(
333
+ outputs.sequences, outputs.scores, outputs.beam_indices, normalize_logits=False
334
+ )
335
+
336
+ # Get the generated token IDs (ignoring the input tokens part)
337
+ generated_ids = outputs.sequences
338
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
339
+
340
+ # Get input length
341
+ input_length = inputs.input_ids.shape[1]
342
+
343
+ # Extract generated tokens (ignoring the input tokens)
344
+ # generated_tokens = outputs.sequences[:, input_length:]
345
+ generated_tokens = outputs.sequences
346
+
347
+ # Calculate output length (number of generated tokens)
348
+ output_length = np.sum(transition_scores.cpu().numpy() < 0, axis=1)
349
+
350
+ # Get length penalty
351
+ length_penalty = model.generation_config.length_penalty
352
+
353
+ # Calculate total score for the generated sentence
354
+ reconstructed_scores = transition_scores.cpu().sum(axis=1) / (output_length**length_penalty)
355
+
356
+ # Convert log-probability to probability (0-1 range)
357
+ probabilities = np.exp(reconstructed_scores.cpu().numpy())
358
+
359
+ # Streamlit UI to display the result
360
+
361
+ # st.write(f"**Probability of the Results (0-1):** {probabilities[0]:.4f}")
362
+ st.markdown(f"**🎯 Probability of the Results:** <span style='color:green; font-size:24px; font-weight:bold;'>{probabilities[0] * 100:.2f}%</span>", unsafe_allow_html=True)
363
+
364
+
365
+
366
+ predictions = processor.post_process_generation(generated_text, task="<CAPTION_TO_PHRASE_GROUNDING>", image_size=np_image.shape[:2])
367
+
368
+ detection = sv.Detections.from_lmm(sv.LMM.FLORENCE_2, predictions, resolution_wh=np_image.shape[:2])
369
+
370
+ bounding_box_annotator = sv.BoundingBoxAnnotator(color_lookup=sv.ColorLookup.INDEX)
371
+ label_annotator = sv.LabelAnnotator(color_lookup=sv.ColorLookup.INDEX)
372
+ image_with_predictions = bounding_box_annotator.annotate(np_image.copy(), detection)
373
+ image_with_predictions = label_annotator.annotate(image_with_predictions, detection)
374
+ annotated_image = Image.fromarray(image_with_predictions.astype(np.uint8))
375
+
376
+ # Create two columns to display the original and the results side by side
377
+ col1, col2 = st.columns([1, 1])
378
+
379
+ # Left column for original image
380
+ with col1:
381
+ st.image(image, caption="Uploaded Image", width=400)
382
+
383
+ # Right column for result image
384
+ with col2:
385
+ st.image(annotated_image, caption="Inference Results 🖼️", width=400)
386
+
387
+ # Display the generated text
388
+ st.write("**Generated Text:**", generated_text)
389
+
390
+
391
+
configs/experiment.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Experiment 1 Configuration
2
+
3
+ model:
4
+ model_type: "microsoft/Florence-2-base-ft"
5
+ lora_config: "configs/lora_config.yaml"
6
+ init_checkpoint: "checkpoints/mimic_model_init.pt"
7
+ processor:
8
+ image_size: 512
9
+ crop_size: 512
10
+ peft:
11
+ use_peft: False
12
+ lora_checkpoint: None
13
+ finetune: true # true
14
+
15
+ trainer:
16
+ checkpoint_dir: "../outputs"
17
+ project_name: "Knowledge-AG" # change to your own wandb project name
18
+ entity_name: "compai" # change to your own wandb entity name
19
+ max_epochs: 50
20
+ train_batch_size: 16
21
+ valid_batch_size: 16
22
+ num_workers: 28
23
+ log_every_n_steps: 100
24
+ gpu: 0
25
+ ddp: true
26
+ optimizer: "adamw"
27
+ learning_rate: 3e-6 #5e-6
28
+ weight_decay: 0.01
29
+
30
+ dataset:
31
+ vindr:
32
+ img_root: "/vol/ciamspace/datasets/X-ray/vindr-cxr/processed/images_512/"
33
+ annotation_csv: "/u/home/lj0/Code/AG-KD-miccai25/annotations/vindr_dataset.csv"
34
+ data_pct: 1.0
35
+
36
+
configs/padchest_definition.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pleural thickening: "Increased thickness of the pleura seen as a dense layer around the lung."
2
+ atelectasis: "Collapsed lung tissue causing darkened or shrunken areas in the lung."
3
+ pleural effusion: "Excess fluid in the pleural space appearing as a shadow around the lungs."
4
+ cardiomegaly: "Enlargement of the heart seen when the heart appears larger than normal."
5
+ aortic elongation: "Lengthened and tortuous aorta, visible as an elongated curving structure."
6
+ vertebral degenerative changes: "Irregular vertebral margins with bony sclerosis and osteophytes."
7
+ aortic atheromatosis: "Calcified deposits in the aortic wall appearing as bright, irregular opacities."
8
+ nodule: "A growth or lump in the lung which may appear as a well-defined or irregular shape."
9
+ alveolar pattern: "Cloud-like, patchy opacities representing fluid or cellular accumulation in alveoli."
10
+ hiatal hernia: "A soft-tissue mass or air-fluid level above the diaphragm, near the midline."
11
+ scoliosis: "Sideways curvature of the spine causing misalignment of vertebral bodies."
12
+ hemidiaphragm elevation: "One side of the diaphragm appearing higher than the other, with convex shape."
13
+ hyperinflated lung: "Abnormally increased lung volume with expanded air spaces."
14
+ interstitial pattern: "Fine reticular or nodular opacities spread across the lung, indicating interstitial involvement."
15
+ fracture: "A break in the bone appearing as a radiolucent line or displacement."
16
+ vascular hilar enlargement: "Increased prominence of the pulmonary vessels near the lung hila."
17
+ nsg tube: "A thin radiopaque tube extending from the nasal cavity into the stomach."
18
+ endotracheal tube: "A thin or opaque line in the middle of the trachea. "
19
+ hypoexpansion: "Reduced lung inflation with increased density and narrow intercostal spaces."
20
+ central venous catheter: "A visible line inside large vein."
21
+ electrical device: "A dense, well-defined metallic opacity, typically a pacemaker or defibrillator."
22
+ bronchiectasis: "Dilated bronchi with thick walls, appearing as tubular or cystic opacities."
23
+ goiter: "A soft tissue mass in the anterior neck, sometimes displacing the trachea."
24
+ other entities: "An unusual mass or area in the lung with irregular borders or density."
configs/vindr_definition.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ lung opacity: "An area of increased density in the lung fields typically appearing as a white or grayish patch."
2
+ infiltration: "Accumulation of substances or cells in the lung tissue visible as increased density or nodules."
3
+ consolidation: "Lung tissue filled with fluid or cells causing dense solid areas on imaging."
4
+ nodule or mass: "A growth or lump in the lung which may appear as a well-defined or irregular shape."
5
+ pleural thickening: "Increased thickness of the pleura seen as a dense layer around the lung."
6
+ aortic enlargement: "Widening of the aorta visible as an enlarged artery on imaging."
7
+ pulmonary fibrosis: "Scarring of the lung tissue creating a dense fibrous appearance."
8
+ ild: "Scarring or inflammation of the lung’s interstitial tissue creating a reticular or nodular pattern."
9
+ cardiomegaly: "Enlargement of the heart seen when the heart appears larger than normal."
10
+ other lesion: "An unusual mass or area in the lung with irregular borders or density."
11
+ pleural effusion: "Excess fluid in the pleural space appearing as a shadow around the lungs."
12
+ calcification: "Calcium deposits in lung tissue visible as bright white spots."
13
+ enlarged pa: "Widening of the pulmonary artery seen as an enlarged artery in the chest."
14
+ lung cavity: "Air-filled spaces within the lung often surrounded by dense tissue."
15
+ atelectasis: "Collapsed lung tissue causing darkened or shrunken areas in the lung."
16
+ mediastinal shift: "Displacement of central chest structures like the heart to one side."
17
+ lung cyst: "Fluid-filled spaces in the lung often round with thin walls."
18
+ pneumothorax: "Air trapped in the pleural space creating a gap or absence of lung tissue."
19
+ emphysema: "Enlarged air spaces in the lungs appearing over-expanded or damaged."
20
+ clavicle fracture: "A break in the collarbone seen as a gap or irregularity in the bone."
21
+ rib fracture: "A break in one or more ribs appearing as a visible crack or displacement."
22
+ edema: "Fluid accumulation in the lungs creating a hazy or clouded area."
examples/26746130963764173994750391023442607773-2_mukhp1.png ADDED

Git LFS Details

  • SHA256: 22685c58a95cdc659f9c02def6fbf7b29553daa00754678848dcb260b3518a6c
  • Pointer size: 131 Bytes
  • Size of remote file: 288 kB
examples/f1eb2216d773ced6330b1f31e18f04f8.png ADDED

Git LFS Details

  • SHA256: a561d1b918ba3e21f8a22cb1305f8b7b75c3bd4974dc2e30ce2e949e3605b054
  • Pointer size: 131 Bytes
  • Size of remote file: 247 kB
examples/fb4dfacc089f4b5550f03f52e706b6f2.png ADDED

Git LFS Details

  • SHA256: 2cfd21a08dc8ee97fcd71aaa5239da8e474dc289d39698600c78a56ab6b1a6b7
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
examples/prompt.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ ./examples/26746130963764173994750391023442607773-2_mukhp1.png:
2
+ - electrical device
3
+
4
+ ./examples/f1eb2216d773ced6330b1f31e18f04f8.png:
5
+ - pulmonary fibrosis
6
+
7
+ ./examples/fb4dfacc089f4b5550f03f52e706b6f2.png:
8
+ - cardiomegaly
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ torch
3
+ transformers
4
+ pillow
5
+ numpy
6
+ supervision
7
+ albumentations
8
+ opencv-python
9
+ pyyaml
10
+ einops
11
+ timm