Commit 
							
							·
						
						5eec800
	
1
								Parent(s):
							
							b586598
								
fixing dcm2nii and wget etc
Browse files- Dockerfile +7 -10
- app.py +17 -22
- requirements.txt +1 -1
    	
        Dockerfile
    CHANGED
    
    | @@ -1,8 +1,6 @@ | |
| 1 | 
             
            # Use an official Python runtime as a parent image
         | 
| 2 | 
             
            FROM python:3.10.12
         | 
| 3 |  | 
| 4 | 
            -
            # RUN apt-get update && apt-get install -y unzip wget
         | 
| 5 | 
            -
             | 
| 6 | 
             
            # Set up a new user named "user" with user ID 1000
         | 
| 7 | 
             
            RUN useradd -m -u 1000 user
         | 
| 8 |  | 
| @@ -29,17 +27,16 @@ COPY --chown=user . $HOME/app | |
| 29 | 
             
            # RUN wget https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip && \
         | 
| 30 | 
             
            #     unzip dcm2niix_lnx.zip && \
         | 
| 31 | 
             
            #     cp dcm2niix /home/user/.local/bin
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            # RUN dcm2niix -h
         | 
| 34 |  | 
| 35 | 
             
            # Install any needed packages specified in requirements.txt
         | 
| 36 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 37 |  | 
| 38 | 
            -
            #  | 
| 39 | 
            -
            # RUN  | 
| 40 | 
            -
            # RUN  | 
| 41 | 
            -
            # RUN  | 
| 42 | 
            -
            # RUN  | 
| 43 |  | 
| 44 | 
             
            # RUN unzip "metadata_only_model.zip" -d "metadata_only_model/"
         | 
| 45 | 
             
            # RUN unzip "images_only_model.zip" -d "images_only_model/"
         | 
| @@ -58,4 +55,4 @@ maxMessageSize = 2000\n\ | |
| 58 | 
             
            EXPOSE 8501
         | 
| 59 |  | 
| 60 | 
             
            # Run filter_data_app.py when the container launches
         | 
| 61 | 
            -
            CMD streamlit run app.py
         | 
|  | |
| 1 | 
             
            # Use an official Python runtime as a parent image
         | 
| 2 | 
             
            FROM python:3.10.12
         | 
| 3 |  | 
|  | |
|  | |
| 4 | 
             
            # Set up a new user named "user" with user ID 1000
         | 
| 5 | 
             
            RUN useradd -m -u 1000 user
         | 
| 6 |  | 
|  | |
| 27 | 
             
            # RUN wget https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip && \
         | 
| 28 | 
             
            #     unzip dcm2niix_lnx.zip && \
         | 
| 29 | 
             
            #     cp dcm2niix /home/user/.local/bin
         | 
| 30 | 
            +
             | 
|  | |
| 31 |  | 
| 32 | 
             
            # Install any needed packages specified in requirements.txt
         | 
| 33 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 34 |  | 
| 35 | 
            +
            # Download files as the non-root user
         | 
| 36 | 
            +
            # RUN curl https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/scaling_factors.csv
         | 
| 37 | 
            +
            # RUN curl https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/metadata_only_model.zip
         | 
| 38 | 
            +
            # RUN curl https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/images_only_model.zip
         | 
| 39 | 
            +
            # RUN curl https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/images_and_metadata_model.zip
         | 
| 40 |  | 
| 41 | 
             
            # RUN unzip "metadata_only_model.zip" -d "metadata_only_model/"
         | 
| 42 | 
             
            # RUN unzip "images_only_model.zip" -d "images_only_model/"
         | 
|  | |
| 55 | 
             
            EXPOSE 8501
         | 
| 56 |  | 
| 57 | 
             
            # Run filter_data_app.py when the container launches
         | 
| 58 | 
            +
            CMD streamlit run app.py
         | 
    	
        app.py
    CHANGED
    
    | @@ -56,33 +56,30 @@ print('selected_series: ' + str(selected_series)) | |
| 56 | 
             
            if st.button("Run inference"):
         | 
| 57 |  | 
| 58 | 
             
                # Code to run when the button is pressed
         | 
| 59 | 
            -
                st.write("Running inference")
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                if os.path.exists("DICOMScanClassification_user_demo.ipynb"):
         | 
| 62 | 
            -
                    os.remove("DICOMScanClassification_user_demo.ipynb")
         | 
| 63 |  | 
| 64 | 
             
                if not os.path.exists("DICOMScanClassification_user_demo.ipynb"):
         | 
| 65 | 
             
                    subprocess.run(["wget", "https://raw.githubusercontent.com/deepakri201/DICOMScanClassification_pw41/main/DICOMScanClassification_user_demo.ipynb"])
         | 
|  | |
| 66 | 
             
                if not os.path.exists("scaling_factors.csv"):
         | 
| 67 | 
            -
                    subprocess.run(["wget", " | 
|  | |
| 68 | 
             
                if not os.path.exists("metadata_only_model.zip"):
         | 
| 69 | 
            -
                    subprocess.run(["wget", " | 
| 70 | 
            -
                    subprocess.run(["unzip", "metadata_only_model.zip" | 
| 71 | 
            -
             | 
| 72 | 
            -
                    subprocess.run(["wget", "-O", "images_only_model.zip", "https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/images_only_model.zip"])
         | 
| 73 | 
            -
                    subprocess.run(["unzip", "images_only_model.zip", -d, "images_only_model/"])
         | 
| 74 | 
             
                if not os.path.exists("images_and_metadata_model.zip"):
         | 
| 75 | 
            -
                    subprocess.run(["wget", " | 
| 76 | 
            -
                    subprocess.run(["unzip", "images_and_metadata_model.zip" | 
| 77 | 
            -
             | 
| 78 | 
            -
                # pm.execute_notebook(
         | 
| 79 | 
            -
                #         "DICOMScanClassification_user_demo.ipynb",
         | 
| 80 | 
            -
                #         'output.ipynb',
         | 
| 81 | 
            -
                #         parameters = dict(SeriesInstanceUID=selected_series)
         | 
| 82 | 
            -
                # )
         | 
| 83 |  | 
|  | |
|  | |
|  | |
|  | |
| 84 | 
             
                subprocess.run(["papermill", "-p", "SeriesInstanceUID", selected_series,  "DICOMScanClassification_user_demo.ipynb", "output.ipynb"])
         | 
| 85 |  | 
|  | |
|  | |
| 86 | 
             
                with open('output.ipynb', "rb") as f:
         | 
| 87 | 
             
                    st.download_button(
         | 
| 88 | 
             
                        label="Download the output notebook file",
         | 
| @@ -90,9 +87,7 @@ if st.button("Run inference"): | |
| 90 | 
             
                        file_name="output.ipynb",
         | 
| 91 | 
             
                        mime="application/json"
         | 
| 92 | 
             
                    )
         | 
| 93 | 
            -
                
         | 
| 94 | 
            -
                # Show 2D image 
         | 
| 95 |  | 
| 96 | 
            -
                #  | 
| 97 |  | 
| 98 | 
            -
                
         | 
|  | |
| 56 | 
             
            if st.button("Run inference"):
         | 
| 57 |  | 
| 58 | 
             
                # Code to run when the button is pressed
         | 
| 59 | 
            +
                st.write("Button pressed! Running inference")
         | 
|  | |
|  | |
|  | |
| 60 |  | 
| 61 | 
             
                if not os.path.exists("DICOMScanClassification_user_demo.ipynb"):
         | 
| 62 | 
             
                    subprocess.run(["wget", "https://raw.githubusercontent.com/deepakri201/DICOMScanClassification_pw41/main/DICOMScanClassification_user_demo.ipynb"])
         | 
| 63 | 
            +
             | 
| 64 | 
             
                if not os.path.exists("scaling_factors.csv"):
         | 
| 65 | 
            +
                    subprocess.run(["wget", "https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/scaling_factors.csv"])
         | 
| 66 | 
            +
             | 
| 67 | 
             
                if not os.path.exists("metadata_only_model.zip"):
         | 
| 68 | 
            +
                    subprocess.run(["wget", "https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/metadata_only_model.zip"])
         | 
| 69 | 
            +
                    subprocess.run(["unzip", "metadata_only_model.zip"])
         | 
| 70 | 
            +
             | 
|  | |
|  | |
| 71 | 
             
                if not os.path.exists("images_and_metadata_model.zip"):
         | 
| 72 | 
            +
                    subprocess.run(["wget", "https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/images_and_metadata_model.zip"])
         | 
| 73 | 
            +
                    subprocess.run(["unzip", "images_and_metadata_model.zip"])
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 74 |  | 
| 75 | 
            +
                if not os.path.exists("images_only_model.zip"):
         | 
| 76 | 
            +
                    subprocess.run(["wget", "https://github.com/deepakri201/DICOMScanClassification/releases/download/v1.0.0/images_only_model.zip"])
         | 
| 77 | 
            +
                    subprocess.run(["unzip", "images_only_model.zip"])
         | 
| 78 | 
            +
                    
         | 
| 79 | 
             
                subprocess.run(["papermill", "-p", "SeriesInstanceUID", selected_series,  "DICOMScanClassification_user_demo.ipynb", "output.ipynb"])
         | 
| 80 |  | 
| 81 | 
            +
                st.write(subprocess.run(["ls","-R"]))
         | 
| 82 | 
            +
                         
         | 
| 83 | 
             
                with open('output.ipynb', "rb") as f:
         | 
| 84 | 
             
                    st.download_button(
         | 
| 85 | 
             
                        label="Download the output notebook file",
         | 
|  | |
| 87 | 
             
                        file_name="output.ipynb",
         | 
| 88 | 
             
                        mime="application/json"
         | 
| 89 | 
             
                    )
         | 
|  | |
|  | |
| 90 |  | 
| 91 | 
            +
                # show classification results df 
         | 
| 92 |  | 
| 93 | 
            +
                # show image 
         | 
    	
        requirements.txt
    CHANGED
    
    | @@ -14,4 +14,4 @@ matplotlib==3.7.1 | |
| 14 | 
             
            scikit-learn==1.2.2
         | 
| 15 | 
             
            sklearn-pandas
         | 
| 16 | 
             
            numpy==1.25.2
         | 
| 17 | 
            -
            dcm2niix | 
|  | |
| 14 | 
             
            scikit-learn==1.2.2
         | 
| 15 | 
             
            sklearn-pandas
         | 
| 16 | 
             
            numpy==1.25.2
         | 
| 17 | 
            +
            git+https://github.com/rordenlab/dcm2niix.git 
         |