Spaces:
Paused
Paused
File size: 8,183 Bytes
69777eb 4d8b8e1 297a56e 4d8b8e1 297a56e 4d8b8e1 297a56e 8c61e72 f21b583 e7d4b75 8c61e72 f09f258 8c61e72 f09f258 4d8b8e1 cdc8845 f4742fd cdc8845 b447f49 978439f 0eb3f60 b447f49 cdc8845 2ebdd7c ea656ff f21b583 4f5f929 044421b cdc8845 5e62602 f9e727e d4408a4 cdc8845 b447f49 3ae8ff3 cdc8845 b447f49 cdc8845 69d9579 978439f f7afd73 b447f49 c7a05ab 978439f cdc8845 b447f49 2ebdd7c f4742fd 2ebdd7c cdc8845 2ebdd7c cdc8845 f4742fd cdc8845 d4408a4 2ebdd7c cdc8845 f15cc8e cdc8845 044421b 2ebdd7c 9ce2e26 f4742fd 2ebdd7c cdc8845 2ebdd7c cdc8845 d68c359 cdc8845 64ba046 bdd2412 cdc8845 594ac32 |
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
from datasets import load_dataset
#LOINC
datasetLOINC = load_dataset("awacke1/LOINC-CodeSet-Value-Description.csv")
#SNOMED:
datasetSNOMED = load_dataset("awacke1/SNOMED-CT-Code-Value-Semantic-Set.csv")
#eCQM:
dataseteCQM = load_dataset("awacke1/eCQM-Code-Value-Semantic-Set.csv")
print(datasetLOINC)
print(datasetSNOMED)
print(dataseteCQM)
# play with some dataset tools before the show:
#print(start_with_ar["Description"])
#---
#Main Stage - Begin!
#---
import os
import json
import numpy as np
import gradio as gr
CHOICES = ["SNOMED", "LOINC", "CQM"]
JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu": 0.55,"batters":{"batter":[{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1003", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }]},"topping":[{ "id": "5001", "type": "None" },{ "id": "5002", "type": "Glazed" },{ "id": "5005", "type": "Sugar" },{ "id": "5007", "type": "Powdered Sugar" },{ "id": "5006", "type": "Chocolate with Sprinkles" },{ "id": "5003", "type": "Chocolate" },{ "id": "5004", "type": "Maple" }]}]}}"""
#def lowercase_title(example):
# return {"Description": example[title].lower()}
# demonstrate map function of dataset
#JSONOBJ_MAP=datasetLOINC.map(lowercase_title)
#JSONOBJ_MAP=datasetLOINC.filter(lambda example: example["Description"].startswith("Mental health"))
#def fn( text1, text2, num, slider1, slider2, single_checkbox, checkboxes, radio, dropdown, im1, im2, im3, im4,
# video, audio1, audio2, file, df1, df2,):
def fn( text1, text2, single_checkbox, checkboxes, radio, im4, file, df1, df2,):
searchTerm = text1
searchTermSentence = text2
#my_dataset_dictionary['train'][0]
start_with_searchTermLOINC = datasetLOINC.filter(lambda example: example["Description"].startswith('Allergy')) #Allergy
start_with_searchTermSNOMED = datasetSNOMED.filter(lambda example: example["Description"].startswith('Hospital')) #Hospital
start_with_searchTermCQM = dataseteCQM.filter(lambda example: example["Description"].startswith('Telephone')) #Telephone
try:
top1matchLOINC = json.loads(start_with_searchTermLOINC['train'][0])
top1matchSNOMED = json.loads(start_with_searchTermSNOMED['train'][0])
top1matchCQM = json.loads(start_with_searchTermCQM['train'][0])
catch:
print(start_with_searchTermLOINC)
print(start_with_searchTermSNOMED )
print(start_with_searchTermCQM )
return (
#(text1 if single_checkbox else text2) + ", selected:" + ", ".join(checkboxes), # Text
#(start_with_searchTermLOINC if single_checkbox else start_with_searchTermSNOMED) + ", selected:" + ", ".join(checkboxes), # Text
# {"positive": num / (num + slider1 + slider2),"negative": slider1 / (num + slider1 + slider2),"neutral": slider2 / (num + slider1 + slider2),}, # Label
# (audio1[0], np.flipud(audio1[1])) if audio1 is not None else os.path.join(os.path.dirname(__file__), "files/cantina.wav"), # Audio
# np.flipud(im1) if im1 is not None else os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"), # Image
# video if video is not None else os.path.join(os.path.dirname(__file__), "files/world.mp4"), # Video
[
#(searchTerm, start_with_searchTermLOINC[0]),
#(searchTerm, start_with_searchTermSNOMED[0] ),
#(searchTerm, start_with_searchTermCQM[0] ),
(searchTerm, "vrb"),
(start_with_searchTermLOINC['train'][0], "nn"),
(searchTermSentence, "vrb"),
(start_with_searchTermSNOMED['train'][0], "nn"),
("The", "art"),
("quick brown", "adj"),
("fox", "nn"),
("jumped", "vrb"),
("testing testing testing", None),
("over", "prp"),
("the", "art"),
("testing", None),
("lazy", "adj"),
("dogs", "nn"),
(".", "punc"),
] + [(f"test {x}", f"test {x}") for x in range(10)], # HighlightedText
[
#(start_with_searchTermLOINC[0], 0.8 ),
#(start_with_searchTermSNOMED[0], 0.8 ),
#(start_with_searchTermCQM[0], 0.8 ),
("The testing testing testing", None),
("over", 0.6),
("the", 0.2),
("testing", None),
("lazy", -0.1),
("dogs", 0.4),
(".", 0),
] + [(f"test", x / 10) for x in range(-10, 10)], # HighlightedText
#json.loads(JSONOBJ), # JSON
#json.loads(JSONOBJ_MAP), # JSONOBJ_MAP
json.loads(top1matchLOINC),
"<button style='background-color: red'>Click Me: " + radio + "</button>", # HTML
os.path.join(os.path.dirname(__file__), "files/titanic.csv"),
df1, # Dataframe
np.random.randint(0, 10, (4, 4)), # Dataframe
df2, # Timeseries
)
demo = gr.Interface(
fn,
inputs=[
gr.Textbox(value="Allergy", label="Textbox"),
gr.Textbox(lines=3, value="Bathing", placeholder="Type here..", label="Textbox 2"),
#gr.Number(label="Number", value=42),
#gr.Slider(10, 20, value=15, label="Slider: 10 - 20"),
#gr.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
gr.Checkbox(label="Check for NER Match on Submit"),
gr.CheckboxGroup(label="Clinical Terminology to Check", choices=CHOICES, value=CHOICES[0:2]),
gr.Radio(label="Preferred Terminology Output", choices=CHOICES, value=CHOICES[2]),
#gr.Dropdown(label="Dropdown", choices=CHOICES),
#gr.Image(label="Image"),
#gr.Image(label="Image w/ Cropper", tool="select"),
#gr.Image(label="Sketchpad", source="canvas"),
gr.Image(label="Webcam", source="webcam"),
#gr.Video(label="Video"),
#gr.Audio(label="Audio"),
#gr.Audio(label="Microphone", source="microphone"),
gr.File(label="File"),
gr.Dataframe(label="Filters", headers=["Name", "Age", "Gender"]),
gr.Timeseries(x="time", y=["price", "value"], colors=["pink", "purple"]),
],
outputs=[
gr.Textbox(label="Textbox"),
#gr.Label(label="Label"),
#gr.Audio(label="Audio"),
#gr.Image(label="Image"),
#gr.Video(label="Video"),
gr.HighlightedText(label="HighlightedText", color_map={"punc": "pink", "test 0": "blue"}),
gr.HighlightedText(label="HighlightedText", show_legend=True),
gr.JSON(label="JSON"),
gr.HTML(label="HTML"),
gr.File(label="File"),
gr.Dataframe(label="Dataframe"),
gr.Dataframe(label="Numpy"),
gr.Timeseries(x="time", y=["price", "value"], label="Timeseries"),
],
examples=[
[
"Allergy",
"Admission",
#10,
#12,
#4,
True,
["SNOMED", "LOINC", "CQM"],
"SNOMED",
#"bar",
#os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"),
#os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"),
#os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"),
os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"),
#os.path.join(os.path.dirname(__file__), "files/world.mp4"),
#os.path.join(os.path.dirname(__file__), "files/cantina.wav"),
#os.path.join(os.path.dirname(__file__), "files/cantina.wav"),
os.path.join(os.path.dirname(__file__), "files/titanic.csv"),
[[1, 2, 3], [3, 4, 5]],
os.path.join(os.path.dirname(__file__), "files/time.csv"),
]
]
* 3,
theme="default",
title="⚗️🧠🔬🧬 Clinical Terminology Auto Mapper AI 👩⚕️🩺⚕️🙋",
cache_examples=False,
description="Clinical Terminology Auto Mapper AI",
article="Learn more at [Yggdrasil](https://github.com/AaronCWacker/Yggdrasil)",
# live=True,
)
if __name__ == "__main__":
demo.launch() |