# How to run a python file on 3D slicer and generate output

**URL:** <https://discourse.slicer.org/t/how-to-run-a-python-file-on-3d-slicer-and-generate-output/24363>\
**Category:** Development\
**Created:** [July 18, 2022, 9:53am UTC](https://discourse.slicer.org/t/how-to-run-a-python-file-on-3d-slicer-and-generate-output/24363 "2022-07-18T09:53:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashuashu](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@ashuashu](https://discourse.slicer.org/u/ashuashu)\
**Post date:** [July 18, 2022, 9:53am UTC](https://discourse.slicer.org/t/how-to-run-a-python-file-on-3d-slicer-and-generate-output/24363/1 "2022-07-18T09:53:56Z")

</div>

Operating system: macOS M1  
Slicer version: 5.0.2  
Expected behavior:  
Actual behavior:

Hello,

I am completely new to the 3D slicer.

I have my deep learning model coded in python and my dataset ready. I want to deploy it in 3D Slicer and generate outputs.

What is the process or commands? Any links to follow the procedure are appreciated.

Thank you.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 18, 2022, 6:31pm UTC](https://discourse.slicer.org/t/how-to-run-a-python-file-on-3d-slicer-and-generate-output/24363/2 "2022-07-18T18:31:24Z")

</div>

You can start by watching this recent webinar and reading up on the topics discussed. You can follow up with specific questions here:

[![](https://img.youtube.com/vi/wtiEe_jiUzg/maxresdefault.jpg "MONAI Label Workshop - Project Week 37") ](https://www.youtube.com/watch?v=wtiEe_jiUzg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 18, 2022, 11:00pm UTC](https://discourse.slicer.org/t/how-to-run-a-python-file-on-3d-slicer-and-generate-output/24363/3 "2022-07-18T23:00:51Z")

</div>

If you don’t use MONAI then you can find a complete example that brings a Pytorch-based model into Slicer:

> <https://github.com/lassoan/SlicerHDBrainExtraction/blob/main/HDBrainExtractionTool/HDBrainExtractionTool.py>

The module installs pytorch, installs the deep learning based segmentation tool, downloads the model, and displays GUI for specifying inputs and outputs for the model.
