Spaces:
Runtime error
Runtime error
Commit
·
49f1dbf
1
Parent(s):
5217b68
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,35 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
-
from transformers import
|
4 |
-
from transformers import SummarizationPipeline
|
5 |
-
|
6 |
-
#summarizer = SummarizationPipeline(model="hamzamalik11/Biobart_radiology_summarization", task="summarization", tokenizer="hamzamalik11/Biobart_radiology_summarization")
|
7 |
-
|
8 |
-
pipeline = pipeline(task="summarization", model="hamzamalik11/Biobart_radiology_summarization")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
"heart mediastinal contours normal left sided subclavian line position tip distal svc lungs remain clear active disease effusions",
|
17 |
-
'''heart size normal mediastinal hilar contours remain stable small right pneumothorax remains unchanged surgical lung staples overlying
|
18 |
-
left upper lobe seen linear pattern consistent prior upper lobe resection soft tissue osseous structures appear unremarkable nasogastric
|
19 |
-
endotracheal tubes remain satisfactory position atelectatic changes right lower lung field remain unchanged prior study''',
|
20 |
-
]
|
21 |
-
|
22 |
-
radiology_demo = gr.Interface(fn=greet, inputs="text", outputs="text",
|
23 |
-
examples=findings_examples,
|
24 |
-
description=""" -------------RADIOLOGY REPORT SUMMARIZATION----------------
|
25 |
-
ENTER YOUR FINDINGS IN RADIOLOGY REPORT SECTION & MODEL WILL PROVIDE YOU IMPRESSIONS AS AN OUTPUT""",
|
26 |
-
|
27 |
-
)
|
28 |
|
29 |
-
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if __name__ == "__main__":
|
32 |
-
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
model_checkpoint = "hamzamalik11/Biobart_radiology_summarization"
|
5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
7 |
|
8 |
+
from transformers import SummarizationPipeline
|
9 |
+
summarizer = SummarizationPipeline(model=model, tokenizer=tokenizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
import gradio as gr
|
12 |
|
13 |
+
examples = [ "heart mediastinal contours normal left sided subclavian line position tip distal svc lungs remain clear active disease effusions",
|
14 |
+
"prevoid bladder volume cc postvoid bladder volume cc bladder grossly normal appearance"
|
15 |
+
]
|
16 |
+
|
17 |
+
description = """
|
18 |
+
THIS MODEL SUMMARIZE FINDINGS OF RADIOLOGY REPORTS INTO IMPRESSIONS
|
19 |
+
<b>Enter a findings of radiology report to see the generated impression!</b>
|
20 |
+
"""
|
21 |
+
|
22 |
+
def summarize(radiology_report):
|
23 |
+
summary = summarizer(radiology_report)[0]['summary_text']
|
24 |
+
return summary
|
25 |
+
|
26 |
+
iface = gr.Interface(fn=summarize,
|
27 |
+
inputs=gr.inputs.Textbox(lines=5, label="Radiology Report"),
|
28 |
+
outputs=gr.outputs.Textbox(label="Summary"),
|
29 |
+
examples=examples,
|
30 |
+
title="Radiology Report Summarization",
|
31 |
+
description=description,
|
32 |
+
theme="huggingface")
|
33 |
+
|
34 |
if __name__ == "__main__":
|
35 |
+
iface.launch(share=False)
|