Amarthya7 commited on
Commit
c9f18eb
·
verified ·
1 Parent(s): 86a74e6

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +73 -0
  2. mediSync.log +80 -0
  3. requirements.txt +11 -0
  4. run.py +71 -0
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ title: Medical Analysis System
2
+ emoji: 🤖
3
+ colorFrom: blue
4
+ colorTo: purple
5
+ sdk: gradio
6
+ sdk_version: 5.20.1
7
+ app_file: app.py
8
+ pinned: false
9
+
10
+ # MediSync: Multi-Modal Medical Analysis System
11
+
12
+ MediSync is an AI-powered healthcare solution that combines X-ray image analysis with patient report text processing to provide comprehensive medical insights.
13
+
14
+ ## Features
15
+
16
+ - **X-ray Image Analysis**: Detects abnormalities in chest X-rays using pre-trained vision models from Hugging Face.
17
+ - **Medical Report Processing**: Extracts key information from patient reports using NLP models.
18
+ - **Multi-modal Integration**: Combines insights from both image and text data for more accurate diagnosis suggestions.
19
+ - **User-friendly Interface**: Simple web interface for uploading images and reports.
20
+
21
+ ## Project Structure
22
+
23
+ ```
24
+ mediSync/
25
+ ├── app.py # Main application with Gradio interface
26
+ ├── models/
27
+ │ ├── image_analyzer.py # X-ray image analysis module
28
+ │ ├── text_analyzer.py # Medical report text analysis module
29
+ │ └── multimodal_fusion.py # Fusion of image and text insights
30
+ ├── utils/
31
+ │ ├── preprocessing.py # Data preprocessing utilities
32
+ │ └── visualization.py # Result visualization utilities
33
+ ├── data/
34
+ │ └── sample/ # Sample data for testing
35
+ └── tests/ # Unit tests
36
+ ```
37
+
38
+ ## Setup Instructions
39
+
40
+ 1. Clone this repository:
41
+ ```bash
42
+ git clone [repository-url]
43
+ cd MediSync
44
+ ```
45
+
46
+ 2. Install dependencies:
47
+ ```bash
48
+ pip install -r requirements.txt
49
+ ```
50
+
51
+ 3. Run the application:
52
+ ```bash
53
+ python app.py
54
+ ```
55
+
56
+ 4. Access the web interface at `http://localhost:7860`
57
+
58
+ ## Models Used
59
+
60
+ - **X-ray Analysis**: facebook/deit-base-patch16-224-medical-cxr
61
+ - **Medical Text Analysis**: medicalai/ClinicalBERT
62
+ - **Additional Support Models**: Medical question answering and entity recognition models
63
+
64
+ ## Use Cases
65
+
66
+ - Preliminary screening of chest X-rays
67
+ - Cross-validation of radiologist reports
68
+ - Educational tool for medical students
69
+ - Research tool for studying correlation between visual findings and written reports
70
+
71
+ ## Note
72
+
73
+ This system is designed as a support tool and should not replace professional medical diagnosis. Always consult with healthcare professionals for medical decisions.
mediSync.log ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2025-03-10 22:44:41,854 - __main__ - INFO - Starting MediSync setup
2
+ 2025-03-10 22:44:41,854 - __main__ - INFO - Checking for sample data
3
+ 2025-03-10 22:44:42,626 - __main__ - INFO - No sample images found. Downloading...
4
+ 2025-03-10 22:44:42,626 - mediSync.utils.download_samples - INFO - Downloading https://prod-images-static.radiopaedia.org/images/53448173/322830a37f0fa0852773ca2db3e8d8_big_gallery.jpeg to D:\Multi Model AI Problem Solving\mediSync\data\sample\normal_chest_xray.jpg
5
+ 2025-03-10 22:44:43,532 - mediSync.utils.download_samples - ERROR - Error downloading https://prod-images-static.radiopaedia.org/images/53448173/322830a37f0fa0852773ca2db3e8d8_big_gallery.jpeg: HTTP Error 404: Not Found
6
+ 2025-03-10 22:44:43,532 - mediSync.utils.download_samples - INFO - Downloading https://prod-images-static.radiopaedia.org/images/52465460/e4d8791bd7502ab72af8d9e5c322db_big_gallery.jpg to D:\Multi Model AI Problem Solving\mediSync\data\sample\pneumonia_xray.jpg
7
+ 2025-03-10 22:44:43,988 - mediSync.utils.download_samples - ERROR - Error downloading https://prod-images-static.radiopaedia.org/images/52465460/e4d8791bd7502ab72af8d9e5c322db_big_gallery.jpg: HTTP Error 404: Not Found
8
+ 2025-03-10 22:44:43,988 - mediSync.utils.download_samples - INFO - Downloading https://prod-images-static.radiopaedia.org/images/556520/cf17c05750adb04b2a6e23afb47c7d_big_gallery.jpg to D:\Multi Model AI Problem Solving\mediSync\data\sample\cardiomegaly_xray.jpg
9
+ 2025-03-10 22:44:44,605 - mediSync.utils.download_samples - ERROR - Error downloading https://prod-images-static.radiopaedia.org/images/556520/cf17c05750adb04b2a6e23afb47c7d_big_gallery.jpg: HTTP Error 404: Not Found
10
+ 2025-03-10 22:44:44,605 - mediSync.utils.download_samples - INFO - Downloading https://prod-images-static.radiopaedia.org/images/19972291/41eed1a2cdad06d26c3f415a6ed65a_big_gallery.jpeg to D:\Multi Model AI Problem Solving\mediSync\data\sample\nodule_xray.jpg
11
+ 2025-03-10 22:44:45,107 - mediSync.utils.download_samples - ERROR - Error downloading https://prod-images-static.radiopaedia.org/images/19972291/41eed1a2cdad06d26c3f415a6ed65a_big_gallery.jpeg: HTTP Error 404: Not Found
12
+ 2025-03-10 22:44:45,107 - mediSync.utils.download_samples - INFO - Downloaded 0 out of 4 images
13
+ 2025-03-10 22:44:45,107 - mediSync.utils.download_samples - INFO - Created sample info file: D:\Multi Model AI Problem Solving\mediSync\data\sample\sample_info.txt
14
+ 2025-03-10 22:44:45,107 - __main__ - INFO - Launching MediSync application
15
+ 2025-03-10 22:44:48,918 - httpx - INFO - HTTP Request: GET https://api.gradio.app/gradio-messaging/en "HTTP/1.1 200 OK"
16
+ 2025-03-10 22:45:02,402 - mediSync.app - INFO - Initializing MediSync application
17
+ 2025-03-10 22:45:03,005 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
18
+ 2025-03-10 22:45:03,294 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
19
+ 2025-03-10 22:45:03,722 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
20
+ 2025-03-10 22:46:47,162 - mediSync.app - INFO - Loading models...
21
+ 2025-03-10 22:46:47,162 - models.multimodal_fusion - INFO - Using device: cpu
22
+ 2025-03-10 22:46:47,178 - models.image_analyzer - INFO - Using device: cpu
23
+ 2025-03-10 22:46:47,391 - models.image_analyzer - ERROR - Failed to load model: facebook/deit-base-patch16-224-medical-cxr is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
24
+ If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`
25
+ 2025-03-10 22:46:47,391 - models.multimodal_fusion - ERROR - Failed to initialize image analyzer: facebook/deit-base-patch16-224-medical-cxr is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
26
+ If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`
27
+ 2025-03-10 22:46:47,391 - models.text_analyzer - INFO - Using device: cpu
28
+ 2025-03-10 22:46:47,490 - models.text_analyzer - ERROR - Failed to load NER model: samrawal/bert-base-uncased_medical-ner is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
29
+ If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`
30
+ 2025-03-10 22:46:58,283 - models.text_analyzer - INFO - Successfully loaded classifier model: medicalai/ClinicalBERT
31
+ 2025-03-10 22:46:58,283 - models.multimodal_fusion - INFO - Successfully initialized text analyzer
32
+ 2025-03-10 22:46:58,283 - mediSync.app - INFO - Models loaded successfully
33
+ 2025-03-10 22:46:58,379 - mediSync.app - INFO - Performing multimodal analysis
34
+ 2025-03-10 22:46:58,379 - models.multimodal_fusion - WARNING - Image analyzer not available
35
+ 2025-03-10 22:46:58,379 - models.text_analyzer - WARNING - NER model not available
36
+ 2025-03-10 22:46:58,379 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
37
+ 2025-03-10 22:47:44,547 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmp19zqepvi\upload.png
38
+ 2025-03-10 22:47:55,128 - mediSync.app - INFO - Analyzing medical report text
39
+ 2025-03-10 22:47:55,128 - models.text_analyzer - WARNING - NER model not available
40
+ 2025-03-10 22:48:20,220 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpowd6qwty\upload.png
41
+ 2025-03-10 22:55:22,019 - mediSync.app - INFO - Performing multimodal analysis
42
+ 2025-03-10 22:55:22,019 - models.multimodal_fusion - WARNING - Image analyzer not available
43
+ 2025-03-10 22:55:22,025 - models.text_analyzer - WARNING - NER model not available
44
+ 2025-03-10 22:55:22,025 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
45
+ 2025-03-10 22:55:35,606 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpipzmsxch\upload.png
46
+ 2025-03-10 22:55:45,116 - mediSync.app - INFO - Analyzing medical report text
47
+ 2025-03-10 22:55:45,116 - models.text_analyzer - WARNING - NER model not available
48
+ 2025-03-10 23:01:32,009 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpo88f1uaw\upload.png
49
+ 2025-03-10 23:05:24,892 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpnckk4w27\upload.png
50
+ 2025-03-10 23:05:45,332 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpxab_m30m\upload.png
51
+ 2025-03-10 23:06:01,387 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpcit78i2e\upload.png
52
+ 2025-03-10 23:06:04,157 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmpivli_abx\upload.png
53
+ 2025-03-10 23:11:47,429 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmp4cpwvo5h\upload.png
54
+ 2025-03-10 23:22:27,118 - mediSync.app - INFO - Performing multimodal analysis
55
+ 2025-03-10 23:22:27,118 - models.multimodal_fusion - WARNING - Image analyzer not available
56
+ 2025-03-10 23:22:27,118 - models.text_analyzer - WARNING - NER model not available
57
+ 2025-03-10 23:22:27,118 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
58
+ 2025-03-10 23:24:22,378 - mediSync.app - INFO - Performing multimodal analysis
59
+ 2025-03-10 23:24:22,378 - models.multimodal_fusion - WARNING - Image analyzer not available
60
+ 2025-03-10 23:24:22,378 - models.text_analyzer - WARNING - NER model not available
61
+ 2025-03-10 23:24:22,378 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
62
+ 2025-03-10 23:24:35,252 - mediSync.app - INFO - Enhancing image: C:\Users\amart\AppData\Local\Temp\tmp947ie5e1\upload.png
63
+ 2025-03-10 23:24:37,554 - mediSync.app - INFO - Performing multimodal analysis
64
+ 2025-03-10 23:24:37,554 - models.multimodal_fusion - WARNING - Image analyzer not available
65
+ 2025-03-10 23:24:37,554 - models.text_analyzer - WARNING - NER model not available
66
+ 2025-03-10 23:24:37,554 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
67
+ 2025-03-10 23:24:58,770 - mediSync.app - INFO - Analyzing medical report text
68
+ 2025-03-10 23:24:58,770 - models.text_analyzer - WARNING - NER model not available
69
+ 2025-03-10 23:25:25,652 - mediSync.app - INFO - Analyzing medical report text
70
+ 2025-03-10 23:25:25,652 - models.text_analyzer - WARNING - NER model not available
71
+ 2025-03-10 23:27:06,100 - mediSync.app - INFO - Performing multimodal analysis
72
+ 2025-03-10 23:27:06,100 - models.multimodal_fusion - WARNING - Image analyzer not available
73
+ 2025-03-10 23:27:06,100 - models.text_analyzer - WARNING - NER model not available
74
+ 2025-03-10 23:27:06,100 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
75
+ 2025-03-10 23:27:46,183 - mediSync.app - INFO - Performing multimodal analysis
76
+ 2025-03-10 23:27:46,183 - models.multimodal_fusion - WARNING - Image analyzer not available
77
+ 2025-03-10 23:27:46,183 - models.text_analyzer - WARNING - NER model not available
78
+ 2025-03-10 23:27:46,183 - models.multimodal_fusion - INFO - Agreement score between modalities: 0.25
79
+ 2025-03-10 23:28:15,394 - mediSync.app - INFO - Analyzing medical report text
80
+ 2025-03-10 23:28:15,394 - models.text_analyzer - WARNING - NER model not available
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch>=2.0.0
2
+ transformers>=4.30.0
3
+ datasets>=2.12.0
4
+ pillow>=9.0.0
5
+ matplotlib>=3.7.0
6
+ pandas>=2.0.0
7
+ numpy>=1.24.0
8
+ scikit-learn>=1.2.0
9
+ gradio>=4.0.0
10
+ huggingface_hub>=0.16.0
11
+ opencv-python>=4.7.0
run.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ MediSync: Multi-Modal Medical Analysis System - Runner Script
3
+ ============================================================
4
+ This script downloads sample data and launches the MediSync application.
5
+ """
6
+
7
+ import logging
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ # Set up logging
12
+ logging.basicConfig(
13
+ level=logging.INFO,
14
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
15
+ handlers=[logging.StreamHandler(), logging.FileHandler("mediSync.log")],
16
+ )
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ def main():
21
+ """
22
+ Main function to set up and run the MediSync application.
23
+ """
24
+ logger.info("Starting MediSync setup")
25
+
26
+ # Add the current directory to Python path
27
+ current_dir = Path(__file__).resolve().parent
28
+ sys.path.append(str(current_dir))
29
+
30
+ # Download sample data if needed
31
+ try:
32
+ logger.info("Checking for sample data")
33
+ from mediSync.utils.download_samples import (
34
+ create_sample_info_file,
35
+ download_sample_images,
36
+ )
37
+
38
+ # Check if sample directory exists and contains images
39
+ sample_dir = current_dir / "mediSync" / "data" / "sample"
40
+ sample_dir.mkdir(parents=True, exist_ok=True)
41
+
42
+ image_files = list(sample_dir.glob("*.jpg")) + list(sample_dir.glob("*.png"))
43
+
44
+ if not image_files:
45
+ logger.info("No sample images found. Downloading...")
46
+ download_sample_images()
47
+ create_sample_info_file()
48
+ else:
49
+ logger.info(f"Found {len(image_files)} existing sample images")
50
+
51
+ except Exception as e:
52
+ logger.error(f"Error setting up sample data: {e}")
53
+ print(f"Warning: Could not set up sample data: {e}")
54
+
55
+ # Launch the application
56
+ try:
57
+ logger.info("Launching MediSync application")
58
+ from mediSync.app import create_interface
59
+
60
+ create_interface()
61
+
62
+ except Exception as e:
63
+ logger.error(f"Error launching application: {e}")
64
+ print(f"Error: Failed to launch MediSync application: {e}")
65
+ return 1
66
+
67
+ return 0
68
+
69
+
70
+ if __name__ == "__main__":
71
+ sys.exit(main())