FrancescoLR commited on
Commit
4d847b9
·
1 Parent(s): c1f2c57

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -32,8 +32,7 @@ def run_nnunet_predict(nifti_file):
32
 
33
  # Save the uploaded file to the input directory
34
  input_path = os.path.join(INPUT_DIR, "image.nii.gz")
35
- with open(input_path, "wb") as f:
36
- f.write(nifti_file.file.read()) # Use .file to access the underlying file object
37
 
38
  # Set environment variables for nnUNet
39
  os.environ["nnUNet_raw"] = DATASET_DIR
@@ -57,6 +56,7 @@ def run_nnunet_predict(nifti_file):
57
  except subprocess.CalledProcessError as e:
58
  return f"Error: {e}"
59
 
 
60
  # Gradio Interface
61
  interface = gr.Interface(
62
  fn=run_nnunet_predict,
@@ -71,4 +71,4 @@ download_model()
71
 
72
  # Launch the app
73
  if __name__ == "__main__":
74
- interface.launch()
 
32
 
33
  # Save the uploaded file to the input directory
34
  input_path = os.path.join(INPUT_DIR, "image.nii.gz")
35
+ os.rename(nifti_file.name, input_path) # Move the uploaded file to the expected input location
 
36
 
37
  # Set environment variables for nnUNet
38
  os.environ["nnUNet_raw"] = DATASET_DIR
 
56
  except subprocess.CalledProcessError as e:
57
  return f"Error: {e}"
58
 
59
+
60
  # Gradio Interface
61
  interface = gr.Interface(
62
  fn=run_nnunet_predict,
 
71
 
72
  # Launch the app
73
  if __name__ == "__main__":
74
+ interface.launch(share=True)