Spaces:
Runtime error
Runtime error
update app.py
Browse files
app.py
CHANGED
|
@@ -84,33 +84,13 @@ def load_sample(index):
|
|
| 84 |
for i in range(4):
|
| 85 |
image_filenames.append(f"thumbnails/image{index-1}_{i}.png")
|
| 86 |
|
| 87 |
-
#sample = torch.load(f"samples/val{index-1}.pt")
|
| 88 |
-
#imgs = []
|
| 89 |
-
#for i in range(4):
|
| 90 |
-
# imgs.append(sample["image"][i, :, :, 70])
|
| 91 |
-
|
| 92 |
-
#pil_images = []
|
| 93 |
-
#for i in range(4):
|
| 94 |
-
# pil_images.append(torchvision.transforms.functional.to_pil_image(imgs[i]))
|
| 95 |
-
|
| 96 |
-
#imgs_label = []
|
| 97 |
-
#for i in range(3):
|
| 98 |
-
# imgs_label.append(sample["label"][i, :, :, 70])
|
| 99 |
-
|
| 100 |
label_filenames = []
|
| 101 |
for i in range(3):
|
| 102 |
label_filenames.append(f"thumbnails_label/label{index-1}_{i}.png")
|
| 103 |
|
| 104 |
-
#pil_images_label = []
|
| 105 |
-
#for i in range(3):
|
| 106 |
-
# pil_images_label.append(torchvision.transforms.functional.to_pil_image(imgs_label[i]))
|
| 107 |
-
|
| 108 |
return [index, image_filenames[0], image_filenames[1], image_filenames[2], image_filenames[3],
|
| 109 |
label_filenames[0], label_filenames[1], label_filenames[2]]
|
| 110 |
|
| 111 |
-
#return [index, pil_images[0], pil_images[1], pil_images[2], pil_images[3],
|
| 112 |
-
# pil_images_label[0], pil_images_label[1], pil_images_label[2]]
|
| 113 |
-
|
| 114 |
|
| 115 |
def predict(sample_index):
|
| 116 |
sample = torch.load(f"samples/val{sample_index-1}.pt")
|
|
@@ -147,22 +127,11 @@ with gr.Blocks(title="Brain tumor 3D segmentation with MONAIMNIST - ClassCat",
|
|
| 147 |
input_image1 = gr.Image(label="image channel 1", type="filepath", shape=(240, 240))
|
| 148 |
input_image2 = gr.Image(label="image channel 2", type="filepath", shape=(240, 240))
|
| 149 |
input_image3 = gr.Image(label="image channel 3", type="filepath", shape=(240, 240))
|
| 150 |
-
"""
|
| 151 |
-
input_image0 = gr.Image(label="image channel 0", type="pil", shape=(240, 240))
|
| 152 |
-
input_image1 = gr.Image(label="image channel 1", type="pil", shape=(240, 240))
|
| 153 |
-
input_image2 = gr.Image(label="image channel 2", type="pil", shape=(240, 240))
|
| 154 |
-
input_image3 = gr.Image(label="image channel 3", type="pil", shape=(240, 240))
|
| 155 |
-
"""
|
| 156 |
|
| 157 |
with gr.Row():
|
| 158 |
label_image0 = gr.Image(label="label channel 0", type="filepath", shape=(240, 240))
|
| 159 |
label_image1 = gr.Image(label="label channel 1", type="filepath", shape=(240, 240))
|
| 160 |
label_image2 = gr.Image(label="label channel 2", type="filepath", shape=(240, 240))
|
| 161 |
-
"""
|
| 162 |
-
label_image0 = gr.Image(label="label channel 0", type="pil")
|
| 163 |
-
label_image1 = gr.Image(label="label channel 1", type="pil")
|
| 164 |
-
label_image2 = gr.Image(label="label channel 2", type="pil")
|
| 165 |
-
"""
|
| 166 |
|
| 167 |
with gr.Row():
|
| 168 |
example1_btn = gr.Button("Example 1")
|
|
|
|
| 84 |
for i in range(4):
|
| 85 |
image_filenames.append(f"thumbnails/image{index-1}_{i}.png")
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
label_filenames = []
|
| 88 |
for i in range(3):
|
| 89 |
label_filenames.append(f"thumbnails_label/label{index-1}_{i}.png")
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
return [index, image_filenames[0], image_filenames[1], image_filenames[2], image_filenames[3],
|
| 92 |
label_filenames[0], label_filenames[1], label_filenames[2]]
|
| 93 |
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
def predict(sample_index):
|
| 96 |
sample = torch.load(f"samples/val{sample_index-1}.pt")
|
|
|
|
| 127 |
input_image1 = gr.Image(label="image channel 1", type="filepath", shape=(240, 240))
|
| 128 |
input_image2 = gr.Image(label="image channel 2", type="filepath", shape=(240, 240))
|
| 129 |
input_image3 = gr.Image(label="image channel 3", type="filepath", shape=(240, 240))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
with gr.Row():
|
| 132 |
label_image0 = gr.Image(label="label channel 0", type="filepath", shape=(240, 240))
|
| 133 |
label_image1 = gr.Image(label="label channel 1", type="filepath", shape=(240, 240))
|
| 134 |
label_image2 = gr.Image(label="label channel 2", type="filepath", shape=(240, 240))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
with gr.Row():
|
| 137 |
example1_btn = gr.Button("Example 1")
|