VatsalPatel18
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
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):
|
8 |
image_tensor = load_and_preprocess_image(image_path, clip_processor_path)
|
9 |
return image_tensor
|
10 |
|
|
|
11 |
def run_genomic_plip_predictions(image_tensor, model_path):
|
12 |
pred_data = genomic_plip_predictions(image_tensor, model_path)
|
13 |
return pred_data
|
14 |
|
|
|
15 |
def run_classify_tiles(pred_data, model_path):
|
16 |
output = classify_tiles(pred_data, model_path)
|
17 |
return output
|
@@ -54,4 +58,4 @@ with gr.Blocks() as demo:
|
|
54 |
gr.Markdown("## Example Images")
|
55 |
gr.Examples(example_files, inputs=image_file)
|
56 |
|
57 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import spaces
|
3 |
import torch
|
4 |
from PIL import Image
|
5 |
from pathlib import Path
|
6 |
from main import load_and_preprocess_image, genomic_plip_predictions, classify_tiles
|
7 |
|
8 |
+
@spaces.GPU
|
9 |
def run_load_and_preprocess_image(image_path, clip_processor_path):
|
10 |
image_tensor = load_and_preprocess_image(image_path, clip_processor_path)
|
11 |
return image_tensor
|
12 |
|
13 |
+
@spaces.GPU
|
14 |
def run_genomic_plip_predictions(image_tensor, model_path):
|
15 |
pred_data = genomic_plip_predictions(image_tensor, model_path)
|
16 |
return pred_data
|
17 |
|
18 |
+
@spaces.GPU
|
19 |
def run_classify_tiles(pred_data, model_path):
|
20 |
output = classify_tiles(pred_data, model_path)
|
21 |
return output
|
|
|
58 |
gr.Markdown("## Example Images")
|
59 |
gr.Examples(example_files, inputs=image_file)
|
60 |
|
61 |
+
demo.launch()
|