File size: 908 Bytes
8155451 |
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 |
from ctmatch.match import CTMatch, PipeConfig
import gradio as gr
pipe_config = PipeConfig(
classifier_model_checkpoint='semaj83/scibert_finetuned_pruned_ctmatch',
ir_setup=True,
filters=["svm", "classifier"],
)
CTM = CTMatch(pipe_config)
def ctmatch_web_api(topic_query: str) -> str:
return '\n\n'.join([f"{nid}: {txt}" for nid, txt in CTM.match_pipeline(topic_query, top_k=5)])
if __name__ == "__main__":
with gr.Blocks(css=".gradio-container {background-color: #00CED1}") as demo:
name = gr.Textbox(lines=5, label="patient description", placeholder="Patient is a 45-year-old man with a history of anaplastic astrocytoma...")
output = gr.Textbox(lines=10, label="matching trials")
greet_btn = gr.Button("match")
greet_btn.click(fn=ctmatch_web_api, inputs=name, outputs=output, api_name="match")
demo.queue().launch(share=True, debug=True) |