Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -25,33 +25,33 @@ import gradio as gr
|
|
25 |
CHOICES = ["SNOMED", "LOINC", "CQM"]
|
26 |
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" }]}]}}"""
|
27 |
|
28 |
-
def lowercase_title(example):
|
29 |
-
return {"
|
30 |
|
31 |
# demonstrate map function of dataset
|
32 |
#JSONOBJ_MAP=datasetLOINC.map(lowercase_title)
|
33 |
-
JSONOBJ_MAP=datasetLOINC.filter(lambda example: example["Description"].startswith("Mental health"))
|
34 |
|
35 |
#def fn( text1, text2, num, slider1, slider2, single_checkbox, checkboxes, radio, dropdown, im1, im2, im3, im4,
|
36 |
# video, audio1, audio2, file, df1, df2,):
|
37 |
def fn( text1, text2, single_checkbox, checkboxes, radio, im4, file, df1, df2,):
|
38 |
searchTerm = text1
|
39 |
searchTermSentence = text2
|
40 |
-
start_with_searchTermLOINC = datasetLOINC.filter(lambda example: example["Description"].startswith('Allergy')) #Allergy
|
41 |
-
start_with_searchTermSNOMED = datasetSNOMED.filter(lambda example: example["Description"].startswith('Hospital')) #Hospital
|
42 |
-
start_with_searchTermCQM = dataseteCQM.filter(lambda example: example["Description"].startswith('Bathing')) #Bathing
|
43 |
|
44 |
return (
|
45 |
#(text1 if single_checkbox else text2) + ", selected:" + ", ".join(checkboxes), # Text
|
46 |
-
(start_with_searchTermLOINC
|
47 |
# {"positive": num / (num + slider1 + slider2),"negative": slider1 / (num + slider1 + slider2),"neutral": slider2 / (num + slider1 + slider2),}, # Label
|
48 |
# (audio1[0], np.flipud(audio1[1])) if audio1 is not None else os.path.join(os.path.dirname(__file__), "files/cantina.wav"), # Audio
|
49 |
# np.flipud(im1) if im1 is not None else os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"), # Image
|
50 |
# video if video is not None else os.path.join(os.path.dirname(__file__), "files/world.mp4"), # Video
|
51 |
[
|
52 |
-
(searchTerm, start_with_searchTermLOINC[0]),
|
53 |
-
(searchTerm, start_with_searchTermSNOMED[0] ),
|
54 |
-
(searchTerm, start_with_searchTermCQM[0] ),
|
55 |
("The", "art"),
|
56 |
("quick brown", "adj"),
|
57 |
("fox", "nn"),
|
@@ -65,9 +65,9 @@ def fn( text1, text2, single_checkbox, checkboxes, radio, im4,
|
|
65 |
(".", "punc"),
|
66 |
] + [(f"test {x}", f"test {x}") for x in range(10)], # HighlightedText
|
67 |
[
|
68 |
-
(start_with_searchTermLOINC[0], 0.8 ),
|
69 |
-
(start_with_searchTermSNOMED[0], 0.8 ),
|
70 |
-
(start_with_searchTermCQM[0], 0.8 ),
|
71 |
("The testing testing testing", None),
|
72 |
("over", 0.6),
|
73 |
("the", 0.2),
|
@@ -78,8 +78,8 @@ def fn( text1, text2, single_checkbox, checkboxes, radio, im4,
|
|
78 |
] + [(f"test", x / 10) for x in range(-10, 10)], # HighlightedText
|
79 |
|
80 |
|
81 |
-
|
82 |
-
json.loads(JSONOBJ_MAP), # JSONOBJ_MAP
|
83 |
|
84 |
"<button style='background-color: red'>Click Me: " + radio + "</button>", # HTML
|
85 |
os.path.join(os.path.dirname(__file__), "files/titanic.csv"),
|
@@ -92,8 +92,8 @@ def fn( text1, text2, single_checkbox, checkboxes, radio, im4,
|
|
92 |
demo = gr.Interface(
|
93 |
fn,
|
94 |
inputs=[
|
95 |
-
gr.Textbox(value="
|
96 |
-
gr.Textbox(lines=3, placeholder="Type here..", label="Textbox 2"),
|
97 |
#gr.Number(label="Number", value=42),
|
98 |
#gr.Slider(10, 20, value=15, label="Slider: 10 - 20"),
|
99 |
#gr.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
|
|
|
25 |
CHOICES = ["SNOMED", "LOINC", "CQM"]
|
26 |
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" }]}]}}"""
|
27 |
|
28 |
+
#def lowercase_title(example):
|
29 |
+
# return {"Description": example[title].lower()}
|
30 |
|
31 |
# demonstrate map function of dataset
|
32 |
#JSONOBJ_MAP=datasetLOINC.map(lowercase_title)
|
33 |
+
#JSONOBJ_MAP=datasetLOINC.filter(lambda example: example["Description"].startswith("Mental health"))
|
34 |
|
35 |
#def fn( text1, text2, num, slider1, slider2, single_checkbox, checkboxes, radio, dropdown, im1, im2, im3, im4,
|
36 |
# video, audio1, audio2, file, df1, df2,):
|
37 |
def fn( text1, text2, single_checkbox, checkboxes, radio, im4, file, df1, df2,):
|
38 |
searchTerm = text1
|
39 |
searchTermSentence = text2
|
40 |
+
start_with_searchTermLOINC = datasetLOINC.filter(lambda example: example["Description"].startswith('Allergy'))[0] #Allergy
|
41 |
+
start_with_searchTermSNOMED = datasetSNOMED.filter(lambda example: example["Description"].startswith('Hospital'))[0] #Hospital
|
42 |
+
start_with_searchTermCQM = dataseteCQM.filter(lambda example: example["Description"].startswith('Bathing'))[0] #Bathing
|
43 |
|
44 |
return (
|
45 |
#(text1 if single_checkbox else text2) + ", selected:" + ", ".join(checkboxes), # Text
|
46 |
+
(start_with_searchTermLOINC if single_checkbox else start_with_searchTermSNOMED) + ", selected:" + ", ".join(checkboxes), # Text
|
47 |
# {"positive": num / (num + slider1 + slider2),"negative": slider1 / (num + slider1 + slider2),"neutral": slider2 / (num + slider1 + slider2),}, # Label
|
48 |
# (audio1[0], np.flipud(audio1[1])) if audio1 is not None else os.path.join(os.path.dirname(__file__), "files/cantina.wav"), # Audio
|
49 |
# np.flipud(im1) if im1 is not None else os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg"), # Image
|
50 |
# video if video is not None else os.path.join(os.path.dirname(__file__), "files/world.mp4"), # Video
|
51 |
[
|
52 |
+
#(searchTerm, start_with_searchTermLOINC[0]),
|
53 |
+
#(searchTerm, start_with_searchTermSNOMED[0] ),
|
54 |
+
#(searchTerm, start_with_searchTermCQM[0] ),
|
55 |
("The", "art"),
|
56 |
("quick brown", "adj"),
|
57 |
("fox", "nn"),
|
|
|
65 |
(".", "punc"),
|
66 |
] + [(f"test {x}", f"test {x}") for x in range(10)], # HighlightedText
|
67 |
[
|
68 |
+
#(start_with_searchTermLOINC[0], 0.8 ),
|
69 |
+
#(start_with_searchTermSNOMED[0], 0.8 ),
|
70 |
+
#(start_with_searchTermCQM[0], 0.8 ),
|
71 |
("The testing testing testing", None),
|
72 |
("over", 0.6),
|
73 |
("the", 0.2),
|
|
|
78 |
] + [(f"test", x / 10) for x in range(-10, 10)], # HighlightedText
|
79 |
|
80 |
|
81 |
+
json.loads(JSONOBJ), # JSON
|
82 |
+
#json.loads(JSONOBJ_MAP), # JSONOBJ_MAP
|
83 |
|
84 |
"<button style='background-color: red'>Click Me: " + radio + "</button>", # HTML
|
85 |
os.path.join(os.path.dirname(__file__), "files/titanic.csv"),
|
|
|
92 |
demo = gr.Interface(
|
93 |
fn,
|
94 |
inputs=[
|
95 |
+
gr.Textbox(value="Allergy", label="Textbox"),
|
96 |
+
gr.Textbox(lines=3, value="Bathing", placeholder="Type here..", label="Textbox 2"),
|
97 |
#gr.Number(label="Number", value=42),
|
98 |
#gr.Slider(10, 20, value=15, label="Slider: 10 - 20"),
|
99 |
#gr.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
|