CoolFace
Apppublic

Jian-An/cxr2ct

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
plot.py416 linesDownload Raw Back to layout
1import plotly.graph_objs as go2from dash import html, dcc3import dash_bootstrap_components as dbc4 5original_2d = dcc.Graph(6    id = "original_2d",7    figure = go.Figure(8        layout = go.Layout(9            plot_bgcolor = "black",10            paper_bgcolor = "black",11            xaxis = dict(showgrid = False, zeroline = False, visible = False),12            yaxis = dict(showgrid = False, zeroline = False, visible = False)13        )14    )15)16 17trachea_2d_graph = dbc.Row(18    children = [19        html.H3(20            "Trachea",21            style = {22                "textAlign": "center"23            }24        ), 25        dcc.Graph(26            id = "trachea_2d",27            figure = go.Figure(28                layout = go.Layout(29                    plot_bgcolor = "black", 30                    paper_bgcolor = "black",31                    xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸32                    yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸33                )34            ),35            style = {36                "width": "100%"37            }38        ),39    ]40)41lung_2d_graph = dbc.Row(42    children = [43        html.H3(44            "Lung",45            style = {46                "textAlign": "center"47            }48        ), 49        dcc.Graph(50            id = "lung_2d",51            figure = go.Figure(52                layout = go.Layout(53                    plot_bgcolor = "black", 54                    paper_bgcolor = "black",55                    xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸56                    yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸57                )58            ),59            style = {60                "width": "100%"61            }62        ),63    ]64)65heart_2d_graph = dbc.Row(66    children = [67        html.H3(68            "Heart",69            style = {70                "textAlign": "center"71            }72        ), 73        dcc.Graph(74            id = "heart_2d",75            figure = go.Figure(76                layout = go.Layout(77                    plot_bgcolor = "black", 78                    paper_bgcolor = "black",79                    xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸80                    yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸81                )82            ),83            style = {84                "width": "100%"85            }86        ),87    ]88)89aorta_2d_graph = dbc.Row(90    children = [91        html.H3(92            "Aorta",93            style = {94                "textAlign": "center"95            }96        ), 97        dcc.Graph(98            id = "aorta_2d",99            figure = go.Figure(100                layout = go.Layout(101                    plot_bgcolor = "black", 102                    paper_bgcolor = "black",103                    xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸104                    yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸105                )106            ),107            style = {108                "width": "100%"109            }110        ),111    ]112)113bone_2d_graph = dbc.Row(114    children = [115        html.H3(116            "Bone",117            style = {118                "textAlign": "center"119            }120        ), 121        dcc.Graph(122            id = "bone_2d",123            figure = go.Figure(124                layout = go.Layout(125                    plot_bgcolor = "black", 126                    paper_bgcolor = "black",127                    xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸128                    yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸129                )130            ),131            style = {132                "width": "100%"133            }134        )135    ]136)137 138original_segmentation_2d = dbc.Row(139    children = [140        dbc.Col(trachea_2d_graph),141        dbc.Col(lung_2d_graph),142        dbc.Col(heart_2d_graph),143        dbc.Col(aorta_2d_graph),144        dbc.Col(bone_2d_graph)145    ]146)147 148plot_3d_using_2d = dbc.Row(149    children = [150        dbc.Col(151            children = dcc.Graph(152                id = "up_down_slice_2d_graph",153                figure = go.Figure(154                    layout = go.Layout(155                        plot_bgcolor = "black", 156                        paper_bgcolor = "black",157                        xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸158                        yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸159                    )160                ), 161                style = {162                    "width": "99%"163                }164            )165        ),166        dbc.Col(167            children = dcc.Graph(168                id = "left_right_slice_2d_graph",169                figure = go.Figure(170                    layout = go.Layout(171                        plot_bgcolor = "black", 172                        paper_bgcolor = "black",173                        xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸174                        yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸175                    )176                ), 177                style = {178                    "width": "99%"179                }180            )181        ),182        dbc.Col(183            children = dcc.Graph(184                id = "front_back_slice_2d_graph",185                figure = go.Figure(186                    layout = go.Layout(187                        plot_bgcolor = "black", 188                        paper_bgcolor = "black",189                        xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸190                        yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸191                    )192                ), 193                style = {194                    "width": "99%"195                }196            )197        )198    ]199)200 201plot_3d_using_3d = dbc.Row(202    children = [203        dbc.Col(204            children = [205                dbc.Row(206                    children = html.Label(207                        children = "左右切面",208                        style = {209                            "textAlign": "center"210                        }211                    )212                ),213                dbc.Row(214                    children = dcc.Graph(215                        id = "up_down_slice_3d_graph",216                        figure = go.Figure(217                            layout = go.Layout(218                                plot_bgcolor = "black", 219                                paper_bgcolor = "black",220                                xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸221                                yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸222                            )223                        ), 224                        style = {225                            "width": "99%"226                        }227                    )228                )229            ]230        ),231        dbc.Col(232            children = [233                dbc.Row(234                    children = html.Label(235                        children = "前後切面",236                        style = {237                            "textAlign": "center"238                        }239                    )240                ),241                dbc.Row(242                    children = dcc.Graph(243                        id = "left_right_slice_3d_graph",244                        figure = go.Figure(245                            layout = go.Layout(246                                plot_bgcolor = "black", 247                                paper_bgcolor = "black",248                                xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸249                                yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸250                            )251                        ), 252                        style = {253                            "width": "99%"254                        }255                    )256                )257            ]258        ),259        dbc.Col(260            children = [261                dbc.Row(262                    children = html.Label(263                        children = "上下切面",264                        style = {265                            "textAlign": "center"266                        }267                    )268                ),269                dbc.Row(270                    children = dcc.Graph(271                        id = "front_back_slice_3d_graph",272                        figure = go.Figure(273                            layout = go.Layout(274                                plot_bgcolor = "black", 275                                paper_bgcolor = "black",276                                xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸277                                yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸278                            )279                        ), 280                        style = {281                            "width": "99%"282                        }283                    )284                )285            ]286        )287    ]288)289 290plot_segmentation_3d = dbc.Row(291    children = [292        dbc.Col(293            children = [294                dbc.Row(295                    children = html.Label(296                        children = "左右切面",297                        style = {298                            "textAlign": "center"299                        }300                    )301                ),302                dbc.Row(303                    children = dcc.Graph(304                        id = "up_down_slice_segmentation",305                        figure = go.Figure(306                            layout = go.Layout(307                                plot_bgcolor = "black",308                                paper_bgcolor = "black",309                                xaxis = dict(310                                    showgrid = False,311                                    zeroline = False,312                                    visible = False313                                ),314                                yaxis = dict(315                                    showgrid = False,316                                    zeroline = False,317                                    visible = False318                                )319                            )320                        ),321                        style = {322                            "width": "95%"323                        }324                    )325                )326            ]327        ),328        dbc.Col(329            children = [330                dbc.Row(331                    children = html.Label(332                        children = "前後切面",333                        style = {334                            "textAlign": "center"335                        }336                    )337                ),338                dbc.Row(339                    children = dcc.Graph(340                        id = "left_right_slice_segmentation",341                        figure = go.Figure(342                            layout = go.Layout(343                                plot_bgcolor = "black", 344                                paper_bgcolor = "black",345                                xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸346                                yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸347                            )348                        ), 349                        style = {350                            "width": "95%"351                        }352                    )353                )354            ]355        ),356        dbc.Col(357            children = [358                dbc.Row(359                    children = html.Label(360                        children = "上下切面",361                        style = {362                            "textAlign": "center"363                        }364                    )365                ),366                dbc.Row(367                    children = dcc.Graph(368                        id = "front_end_slice_segmentation",369                        figure = go.Figure(370                            layout = go.Layout(371                                plot_bgcolor = "black", 372                                paper_bgcolor = "black",373                                xaxis=dict(showgrid=False, zeroline=False, visible=False),  # 隱藏 X 軸374                                yaxis=dict(showgrid=False, zeroline=False, visible=False)   # 隱藏 Y 軸375                            )376                        ), 377                        style = {378                            "width": "95%"379                        }380                    )381                )382            ]383        )384    ]385)386 387plot_layout = html.Div(388    children = [389        html.H1(390            children = "原始 X-Ray",391            style = {392                "textAlign": "center"393            }394        ), 395        original_2d,396        html.Hr(), 397        html.H1(398            children = "五大器官 X-Ray",399            style = {400                "textAlign": "center"401            }402        ), 403        original_segmentation_2d, 404        html.Hr(), 405        html.H1(406            children = "2D → 3D",407            style = {408                "textAlign": "center"409            }410        ), 411        plot_3d_using_2d,412        plot_3d_using_3d,413        html.Hr(), 414        plot_segmentation_3d415    ]416)