Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def infer_full_vol(tensor, model):
|
|
21 |
output = output[0]
|
22 |
output = torch.sigmoid(output)
|
23 |
output = torch.movedim(output, -3, -1).type(tensor.type())
|
24 |
-
return output.
|
25 |
|
26 |
# Set page configuration
|
27 |
st.set_page_config(
|
@@ -134,12 +134,9 @@ if uploaded_file is not None and process_button:
|
|
134 |
print(error)
|
135 |
output = output > 0.5 # exception only if input image seems to have just one color 1.0.
|
136 |
output = output.astype('uint16')
|
137 |
-
|
138 |
-
# Convert output to NumPy array
|
139 |
-
output_np = output.detach().cpu().numpy()
|
140 |
|
141 |
# Save the output as a NIfTI file
|
142 |
-
output_img = nib.Nifti1Image(
|
143 |
output_path = tempfile.NamedTemporaryFile(suffix='.nii.gz', delete=False).name
|
144 |
nib.save(output_img, output_path)
|
145 |
|
|
|
21 |
output = output[0]
|
22 |
output = torch.sigmoid(output)
|
23 |
output = torch.movedim(output, -3, -1).type(tensor.type())
|
24 |
+
return output.detach().cpu().numpy()
|
25 |
|
26 |
# Set page configuration
|
27 |
st.set_page_config(
|
|
|
134 |
print(error)
|
135 |
output = output > 0.5 # exception only if input image seems to have just one color 1.0.
|
136 |
output = output.astype('uint16')
|
|
|
|
|
|
|
137 |
|
138 |
# Save the output as a NIfTI file
|
139 |
+
output_img = nib.Nifti1Image(output, affine=nifti_img.affine)
|
140 |
output_path = tempfile.NamedTemporaryFile(suffix='.nii.gz', delete=False).name
|
141 |
nib.save(output_img, output_path)
|
142 |
|