haritsahm commited on
Commit ·
4adfcec
1
Parent(s): 4191136
code cleanup
Browse files37 unmodified lines38394041424344454647484950515253545556575859606162632 unmodified lines666768697071727374757637 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"] = predfor 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 imageresult = batch["image"].permute(1, 2, 0).cpu().numpy() * 0.5 + result * 0.5# Solve rotating problemresult = np.fliplr(result)result = np.rot90(result, k=1)return result# load Markdown file2 unmodified linesdemo = gr.Interface(query_image,inputs=[gr.Image(type="filepath")],outputs="image",title="Medical Image Classification with MONAI - Pathology Nuclei Segmentation Classification",description = markdown_content,examples=example_files)demo.queue(concurrency_count=20).launch()37 unmodified lines38394041424344454647484950515253545556575859606162632 unmodified lines666768697071727374757637 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"] = predfor 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 imageresult = batch["image"].permute(1, 2, 0).cpu().numpy() * 0.5 + result * 0.5# Solve rotating problemresult = np.fliplr(result)result = np.rot90(result, k=1)return result# load Markdown file2 unmodified linesdemo = gr.Interface(query_image,inputs=[gr.Image(type="filepath")],outputs="image",title="Medical Image Classification with MONAI - Pathology Nuclei Segmentation Classification",description = markdown_content,examples=example_files,)demo.queue(concurrency_count=20).launch()
app.py+9-9