srijaydeshpande commited on
Commit
904e33b
·
1 Parent(s): 9974dfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -14,18 +14,18 @@ subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)
14
 
15
  from llama_cpp import Llama
16
 
17
- # hf_hub_download(
18
- # repo_id="QuantFactory/Meta-Llama-3-8B-Instruct-GGUF",
19
- # filename="Meta-Llama-3-8B-Instruct.Q8_0.gguf",
20
- # local_dir = "./models"
21
- # )
22
-
23
  hf_hub_download(
24
- repo_id="bartowski/Llama-3-8B-Instruct-Gradient-1048k-GGUF",
25
- filename="Llama-3-8B-Instruct-Gradient-1048k-Q8_0.gguf",
26
  local_dir = "./models"
27
  )
28
 
 
 
 
 
 
 
29
  def process_document(pdf_path, page_ids=None):
30
  extracted_pages = extract_pages(pdf_path, page_numbers=page_ids)
31
 
@@ -122,20 +122,20 @@ def deidentify_doc(pdftext, prompt, maxtokens, temperature, top_probability):
122
  def pdf_to_text(files, prompt, maxtokens=2048, temperature=0, top_probability=0.95):
123
  files=[files]#remove later
124
  for file in files:
125
- file_name = os.path.basename(file)
126
- file_name_splt = file_name.split('.')
127
- print('File name is ', file_name)
128
- if (len(file_name_splt) > 1 and file_name_splt[1] == 'pdf'):
129
- page2content = process_document(file, page_ids=[0])
130
- pdftext = page2content[1]
131
- # pdftext = file # remove later
132
- if (pdftext): #shift this if block to right later
133
- anonymized_text = deidentify_doc(pdftext, prompt, maxtokens, temperature, top_probability)
134
  return anonymized_text
135
 
136
 
137
  # model_id = "Meta-Llama-3-8B-Instruct.Q8_0.gguf"
138
- model_id = "models/Llama-3-8B-Instruct-Gradient-1048k-Q8_0.gguf"
139
  model = Llama(model_path=model_id, n_ctx=2048, n_threads=8, n_gpu_layers=-1, n_batch=128)
140
 
141
  css = ".gradio-container {background: 'logo.png'}"
@@ -148,7 +148,7 @@ output_text = gr.Textbox()
148
  output_path_component = gr.File(label="Select Output Path")
149
  iface = gr.Interface(
150
  fn=pdf_to_text,
151
- inputs=['file', 'textbox'],
152
  # inputs=["textbox", input_folder_text, "textbox", max_tokens, temp_slider, prob_slider],
153
  outputs=output_text,
154
  title='COBIx Endoscopy Report De-Identification',
 
14
 
15
  from llama_cpp import Llama
16
 
 
 
 
 
 
 
17
  hf_hub_download(
18
+ repo_id="QuantFactory/Meta-Llama-3-8B-Instruct-GGUF",
19
+ filename="Meta-Llama-3-8B-Instruct.Q8_0.gguf",
20
  local_dir = "./models"
21
  )
22
 
23
+ # hf_hub_download(
24
+ # repo_id="bartowski/Llama-3-8B-Instruct-Gradient-1048k-GGUF",
25
+ # filename="Llama-3-8B-Instruct-Gradient-1048k-Q8_0.gguf",
26
+ # local_dir = "./models"
27
+ # )
28
+
29
  def process_document(pdf_path, page_ids=None):
30
  extracted_pages = extract_pages(pdf_path, page_numbers=page_ids)
31
 
 
122
  def pdf_to_text(files, prompt, maxtokens=2048, temperature=0, top_probability=0.95):
123
  files=[files]#remove later
124
  for file in files:
125
+ # file_name = os.path.basename(file)
126
+ # file_name_splt = file_name.split('.')
127
+ # print('File name is ', file_name)
128
+ # if (len(file_name_splt) > 1 and file_name_splt[1] == 'pdf'):
129
+ # page2content = process_document(file, page_ids=[0])
130
+ # pdftext = page2content[1]
131
+ pdftext = file # remove later
132
+ if (pdftext): #shift this if block to right later
133
+ anonymized_text = deidentify_doc(pdftext, prompt, maxtokens, temperature, top_probability)
134
  return anonymized_text
135
 
136
 
137
  # model_id = "Meta-Llama-3-8B-Instruct.Q8_0.gguf"
138
+ model_id = "models/Meta-Llama-3-8B-Instruct.Q8_0.gguf"
139
  model = Llama(model_path=model_id, n_ctx=2048, n_threads=8, n_gpu_layers=-1, n_batch=128)
140
 
141
  css = ".gradio-container {background: 'logo.png'}"
 
148
  output_path_component = gr.File(label="Select Output Path")
149
  iface = gr.Interface(
150
  fn=pdf_to_text,
151
+ inputs=['textbox', 'textbox'],
152
  # inputs=["textbox", input_folder_text, "textbox", max_tokens, temp_slider, prob_slider],
153
  outputs=output_text,
154
  title='COBIx Endoscopy Report De-Identification',