Commit ·
f7467af
1
Parent(s): 9327593
Update app.py
Browse files4 unmodified lines56789101112131415161718192021222324252627114 unmodified lines1421431441451461471489 unmodified lines1581591601611621631641651661671681694 unmodified linesimport gradio as grimport osimport accelerateimport spacesimport subprocessfrom huggingface_hub import hf_hub_download, InferenceClientfrom llama_cpp import Llamafrom huggingface_hub import loginlogin(token = os.getenv('HF_TOKEN'))repo_id = "srijaydeshpande/Deid-Fine-Tuned"model_id = "deid_finetuned.Q4_K_M.gguf"hf_hub_download(repo_id="srijaydeshpande/Deid-Fine-Tuned",filename="deid_finetuned.Q4_K_M.gguf",local_dir = "./models")def process_document(pdf_path):extracted_pages = extract_pages(pdf_path)114 unmodified linesreturn response@spaces.GPU(duration=80)def pdf_to_text(files, llm_type, maxtokens=2048, temperature=0, top_probability=0.95):files=[files]for file in files:9 unmodified linesfor page_id in page2content:pdftext = page2content[page_id]original_pdf_text += pdftext + '\n'response_generator = deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability)print('RESPONSE GENERATOR IS ',response_generator)# for chunk in response_generator:# accumulated_text += chunk# yield accumulated_text # Keep updating outputreturn response_generator # + "\n\n"print('Extracted Page Content Is ', original_pdf_text)print('------------------------------------------------------------')# return anonymized_text4 unmodified lines56789101112131415161718192021222324252627114 unmodified lines1421431441451461471489 unmodified lines1581591601611621631641651661671681694 unmodified linesimport gradio as grimport osimport accelerate# import spacesimport subprocess# from huggingface_hub import hf_hub_download, InferenceClient# from llama_cpp import Llama# from huggingface_hub import login# login(token = os.getenv('HF_TOKEN'))# repo_id = "srijaydeshpande/Deid-Fine-Tuned"# model_id = "deid_finetuned.Q4_K_M.gguf"# hf_hub_download(# repo_id="srijaydeshpande/Deid-Fine-Tuned",# filename="deid_finetuned.Q4_K_M.gguf",# local_dir = "./models"# )def process_document(pdf_path):extracted_pages = extract_pages(pdf_path)114 unmodified linesreturn response# @spaces.GPU(duration=80)def pdf_to_text(files, llm_type, maxtokens=2048, temperature=0, top_probability=0.95):files=[files]for file in files:9 unmodified linesfor page_id in page2content:pdftext = page2content[page_id]original_pdf_text += pdftext + '\n'# response_generator = deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability)# print('RESPONSE GENERATOR IS ',response_generator)# for chunk in response_generator:# accumulated_text += chunk# yield accumulated_text # Keep updating output# return response_generator # + "\n\n"print('Extracted Page Content Is ', original_pdf_text)print('------------------------------------------------------------')# return anonymized_text
app.py+16-16