Spaces:
Build error
Build error
File size: 1,476 Bytes
52dce0a 915d664 52dce0a 83fe5b0 52dce0a 55a5bfa 52dce0a 55a5bfa 1d5816e e643fff 52dce0a 55a5bfa 9d3accc f03708e 1d5816e 89ea98f 1d5816e 915d664 1d5816e 52dce0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
from pathlib import Path
from typing import List, Dict, Tuple
import matplotlib.colors as mpl_colors
import pandas as pd
import seaborn as sns
import shinyswatch
import run
from shiny import App, Inputs, Outputs, Session, reactive, render, req, ui
from transformers import SamModel, SamConfig, SamProcessor
import torch
sns.set_theme()
www_dir = Path(__file__).parent.resolve() / "www"
app_ui = ui.page_fillable(
shinyswatch.theme.minty(),
ui.layout_sidebar(
ui.sidebar(
ui.input_file("image_input", "Upload image: ", multiple=True),
),
ui.output_image("image"),
ui.output_image("image_output"),
ui.output_image("single_patch_prediction"),
ui.output_image("single_patch_prob")
),
)
def server(input: Inputs, output: Outputs, session: Session):
@output
@render.image
def image():
here = Path(__file__).parent
if input.image_input():
src = input.image_input()[0]['datapath']
img = {"src": src, "width": "500px"}
return img
return None
@output
@render.image
def image_output():
here = Path(__file__).parent
if input.image_input():
src = input.image_input()[0]['datapath']
img = {"src": src, "width": "500px"}
x = run.pred(src)
print(x)
return img
return None
app = App(
app_ui,
server,
static_assets=str(www_dir),
)
|