James Kelly
cloned most of ctmatch into this spaces repo... it will have to handle the data too, we'll see. using ctmatch requirements.txt
8155451
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) |