haritsahm commited on
Commit ·
4adfcec
1
Parent(s): 4191136
code cleanup
Browse files37 unmodified lines3839404141424344454546474849495051515253535455565657585960606162632 unmodified lines6667686969707172737374757637 unmodified linesdef query_image(img): data = {"image": img} batch = preprocess(data)
network.eval() with torch.no_grad(): pred = inference(batch['image'].unsqueeze(dim=0), network)
batch["pred"] = pred for k,v in batch["pred"].items(): batch["pred"][k] = v.squeeze(dim=0)
batch = postprocess(batch)
result = visualize_instance_seg_mask(batch["type_map"].squeeze())
# Combine image result = batch["image"].permute(1, 2, 0).cpu().numpy() * 0.5 + result * 0.5
# Solve rotating problem result = np.fliplr(result) result = np.rot90(result, k=1)
return result
# load Markdown file2 unmodified lines
demo = gr.Interface( query_image, inputs=[gr.Image(type="filepath")], inputs=[gr.Image(type="filepath")], outputs="image", title="Medical Image Classification with MONAI - Pathology Nuclei Segmentation Classification", description = markdown_content, examples=example_files examples=example_files,)
demo.queue(concurrency_count=20).launch()app.py+9-9