Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -166,18 +166,15 @@ def read_and_preprocess_dicom(file_path: str):
|
|
| 166 |
pixel_array = ((pixel_array - np.min(pixel_array)) / (np.max(pixel_array) - np.min(pixel_array)) * 255).astype(
|
| 167 |
np.uint8)
|
| 168 |
image_pil = Image.fromarray(pixel_array)
|
|
|
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
-
# PIL images into NumPy arrays
|
| 172 |
-
numpydata = np.asarray(image_pil)
|
| 173 |
-
#convert to cv2 format
|
| 174 |
-
numpydata = numpydata.reshape((numpydata.shape[0], numpydata.shape[1], 3))
|
| 175 |
-
print("In preprocess dicom:", numpydata.shape)
|
| 176 |
#image = np.array(numpydata)[::-1].copy()
|
| 177 |
image = np.array(numpydata)[:,:,::-1].copy()
|
| 178 |
|
| 179 |
# shape
|
| 180 |
-
print("In preprocess dicom-image.
|
| 181 |
|
| 182 |
# Collect metadata in dictionary format and convert to DataFrame
|
| 183 |
metadata_dict = {elem.name: str(elem.value) for elem in dicom_data.iterall() if elem.name != 'Pixel Data'}
|
|
|
|
| 166 |
pixel_array = ((pixel_array - np.min(pixel_array)) / (np.max(pixel_array) - np.min(pixel_array)) * 255).astype(
|
| 167 |
np.uint8)
|
| 168 |
image_pil = Image.fromarray(pixel_array)
|
| 169 |
+
|
| 170 |
+
image = image_pil.convert('RGB')
|
| 171 |
|
| 172 |
+
print("In preprocess dicom:", image.shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
#image = np.array(numpydata)[::-1].copy()
|
| 174 |
image = np.array(numpydata)[:,:,::-1].copy()
|
| 175 |
|
| 176 |
# shape
|
| 177 |
+
print("In preprocess dicom-image.shape2:",image.shape)
|
| 178 |
|
| 179 |
# Collect metadata in dictionary format and convert to DataFrame
|
| 180 |
metadata_dict = {elem.name: str(elem.value) for elem in dicom_data.iterall() if elem.name != 'Pixel Data'}
|