Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
from pathlib import Path
|
5 |
-
|
6 |
from main import load_and_preprocess_image, genomic_plip_predictions, classify_tiles
|
7 |
|
8 |
def run_load_and_preprocess_image(image_path, clip_processor_path):
|
@@ -17,20 +16,18 @@ def run_classify_tiles(pred_data, model_path):
|
|
17 |
output = classify_tiles(pred_data, model_path)
|
18 |
return output
|
19 |
|
20 |
-
|
21 |
example_files = list(Path("sample_tiles").glob("*.jpeg"))
|
22 |
|
23 |
with gr.Blocks() as demo:
|
24 |
gr.Markdown("## Cancer Risk Prediction from Tissue Slide")
|
25 |
|
26 |
image_file = gr.Image(type="filepath", label="Upload Image File")
|
27 |
-
|
28 |
clip_processor_path = gr.Textbox(label="CLIP Processor Path", value="./genomic_plip_model")
|
29 |
genomic_plip_model_path = gr.Textbox(label="Genomic PLIP Model Path", value="./genomic_plip_model")
|
30 |
classifier_model_path = gr.Textbox(label="Classifier Model Path", value="./models/classifier.pth")
|
31 |
|
32 |
-
image_tensor_output = gr.
|
33 |
-
pred_data_output = gr.
|
34 |
result_output = gr.Textbox(label="Result")
|
35 |
|
36 |
preprocess_button = gr.Button("Preprocess Image")
|
@@ -54,7 +51,6 @@ with gr.Blocks() as demo:
|
|
54 |
predict_button.click(update_status, inputs=[predict_status, pred_data_output], outputs=predict_status)
|
55 |
classify_button.click(update_status, inputs=[classify_status, result_output], outputs=classify_status)
|
56 |
|
57 |
-
|
58 |
gr.Markdown("## Example Images")
|
59 |
gr.Examples(example_files, inputs=image_file)
|
60 |
|
|
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
from pathlib import Path
|
|
|
5 |
from main import load_and_preprocess_image, genomic_plip_predictions, classify_tiles
|
6 |
|
7 |
def run_load_and_preprocess_image(image_path, clip_processor_path):
|
|
|
16 |
output = classify_tiles(pred_data, model_path)
|
17 |
return output
|
18 |
|
|
|
19 |
example_files = list(Path("sample_tiles").glob("*.jpeg"))
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
gr.Markdown("## Cancer Risk Prediction from Tissue Slide")
|
23 |
|
24 |
image_file = gr.Image(type="filepath", label="Upload Image File")
|
|
|
25 |
clip_processor_path = gr.Textbox(label="CLIP Processor Path", value="./genomic_plip_model")
|
26 |
genomic_plip_model_path = gr.Textbox(label="Genomic PLIP Model Path", value="./genomic_plip_model")
|
27 |
classifier_model_path = gr.Textbox(label="Classifier Model Path", value="./models/classifier.pth")
|
28 |
|
29 |
+
image_tensor_output = gr.State()
|
30 |
+
pred_data_output = gr.State()
|
31 |
result_output = gr.Textbox(label="Result")
|
32 |
|
33 |
preprocess_button = gr.Button("Preprocess Image")
|
|
|
51 |
predict_button.click(update_status, inputs=[predict_status, pred_data_output], outputs=predict_status)
|
52 |
classify_button.click(update_status, inputs=[classify_status, result_output], outputs=classify_status)
|
53 |
|
|
|
54 |
gr.Markdown("## Example Images")
|
55 |
gr.Examples(example_files, inputs=image_file)
|
56 |
|