Spaces:
Sleeping
Sleeping
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() | |