Update Chest_Xray_Report_Generator-V2.py
Browse files
Chest_Xray_Report_Generator-V2.py
CHANGED
|
@@ -7,6 +7,8 @@ import numpy as np
|
|
| 7 |
import pydicom
|
| 8 |
import time
|
| 9 |
|
|
|
|
|
|
|
| 10 |
##### Libraries For Grad-Cam-View
|
| 11 |
import os
|
| 12 |
import cv2
|
|
@@ -19,6 +21,7 @@ from pytorch_grad_cam.utils.image import show_cam_on_image, preprocess_image
|
|
| 19 |
from pytorch_grad_cam.ablation_layer import AblationLayerVit
|
| 20 |
from transformers import VisionEncoderDecoderModel
|
| 21 |
|
|
|
|
| 22 |
def generate_gradcam(image_path, model_path, output_path, method='gradcam', use_cuda=True, aug_smooth=False, eigen_smooth=False):
|
| 23 |
methods = {
|
| 24 |
"gradcam": GradCAM,
|
|
@@ -126,6 +129,7 @@ Image_Captioner = pipeline("image-to-text", model = "./Mimic_test/")
|
|
| 126 |
|
| 127 |
data_dir = "./CAM-Result"
|
| 128 |
|
|
|
|
| 129 |
def xray_report_generator(Image_file):
|
| 130 |
if Image_file[-4:] =='.dcm':
|
| 131 |
png_file = 'DCM2PNG.png'
|
|
|
|
| 7 |
import pydicom
|
| 8 |
import time
|
| 9 |
|
| 10 |
+
import spaces # Import the spaces module for ZeroGPU
|
| 11 |
+
|
| 12 |
##### Libraries For Grad-Cam-View
|
| 13 |
import os
|
| 14 |
import cv2
|
|
|
|
| 21 |
from pytorch_grad_cam.ablation_layer import AblationLayerVit
|
| 22 |
from transformers import VisionEncoderDecoderModel
|
| 23 |
|
| 24 |
+
@spaces.GPU
|
| 25 |
def generate_gradcam(image_path, model_path, output_path, method='gradcam', use_cuda=True, aug_smooth=False, eigen_smooth=False):
|
| 26 |
methods = {
|
| 27 |
"gradcam": GradCAM,
|
|
|
|
| 129 |
|
| 130 |
data_dir = "./CAM-Result"
|
| 131 |
|
| 132 |
+
@spaces.GPU(duration=300)
|
| 133 |
def xray_report_generator(Image_file):
|
| 134 |
if Image_file[-4:] =='.dcm':
|
| 135 |
png_file = 'DCM2PNG.png'
|