File size: 951 Bytes
3b307ab
 
 
2967659
 
6c0f891
2967659
 
 
 
 
 
 
 
 
3b307ab
 
 
 
2967659
 
0f3eab2
 
 
9d0b212
2967659
 
80c4e60
 
3b307ab
 
 
 
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
import gradio as gr
import openslide

from PIL import Image, ImageDraw
from xml.etree import ElementTree as ET
from project_utils.preprocessing import get_mask_from_xml

# output as png or npy 
def process(x, y, annotation_size, annotation):
    image_shrinking_factor = annotation_size / min(x, y)

    # get thumbnail
    image = get_mask_from_xml(annotation, (annotation_size, annotation_size), image_shrinking_factor)
    image.save("mask.png")
    return "mask.png"


demo = gr.Interface(
    fn=process,
    inputs=[
        # gr.File(label="Slide thumbnail", type="file", accept=".png"),
        gr.Number(label="X", value=10_000),
        gr.Number(label="Y", value=10_000),
        gr.Number(label="Thumbnail size", value=500),
        gr.File(label="ASAP Annotation", file_types=[".xml"]),
    ],
    outputs="image",
    title="ASAP annotation to png converter",
    # description="Reverses the text entered by the user",

)

demo.launch()