seanpedrickcase commited on
Commit
230fcc3
1 Parent(s): bc4bdbd

Works correctly with images again

Browse files
tools/file_conversion.py CHANGED
@@ -1,5 +1,5 @@
1
  from pdf2image import convert_from_path, pdfinfo_from_path
2
- from tools.helper_functions import get_file_path_end, output_folder
3
  from PIL import Image
4
  import os
5
  from gradio import Progress
@@ -159,6 +159,12 @@ def prepare_image_or_text_pdf(
159
 
160
  print("file_path:", file_path)
161
 
 
 
 
 
 
 
162
  #if file_path:
163
  # file_path_without_ext = get_file_path_end(file_path)
164
  if not file_path:
 
1
  from pdf2image import convert_from_path, pdfinfo_from_path
2
+ from tools.helper_functions import get_file_path_end, output_folder, detect_file_type
3
  from PIL import Image
4
  import os
5
  from gradio import Progress
 
159
 
160
  print("file_path:", file_path)
161
 
162
+ file_extension = os.path.splitext(file_path)[1].lower()
163
+
164
+ # Check if the file is an image type
165
+ if file_extension in ['.jpg', '.jpeg', '.png']:
166
+ in_redact_method = "Image analysis"
167
+
168
  #if file_path:
169
  # file_path_without_ext = get_file_path_end(file_path)
170
  if not file_path:
tools/file_redaction.py CHANGED
@@ -190,7 +190,12 @@ def redact_image_pdf(file_path:str, image_paths:List[str], language:str, chosen_
190
 
191
  image_paths = process_file(file_path)
192
 
193
- images = []
 
 
 
 
 
194
 
195
  #print("Image paths:", image_paths)
196
  number_of_pages = len(image_paths[0])
@@ -216,6 +221,8 @@ def redact_image_pdf(file_path:str, image_paths:List[str], language:str, chosen_
216
 
217
  #for i in progress.tqdm(range(0,number_of_pages), total=number_of_pages, unit="pages", desc="Redacting pages"):
218
 
 
 
219
  for n in range(0, number_of_pages):
220
 
221
  try:
 
190
 
191
  image_paths = process_file(file_path)
192
 
193
+ print("image_paths:", image_paths)
194
+
195
+
196
+ if not isinstance(image_paths, list):
197
+ print("Converting image_paths to list")
198
+ image_paths = [image_paths]
199
 
200
  #print("Image paths:", image_paths)
201
  number_of_pages = len(image_paths[0])
 
221
 
222
  #for i in progress.tqdm(range(0,number_of_pages), total=number_of_pages, unit="pages", desc="Redacting pages"):
223
 
224
+ images = []
225
+
226
  for n in range(0, number_of_pages):
227
 
228
  try: