thomasf1 commited on
Commit
dabdc51
·
verified ·
1 Parent(s): dd4cf3b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -191,22 +191,15 @@ def run_batch_conversion(uploaded_files, max_workers):
191
  if not files_to_process:
192
  return "No supported document files found to convert.", gr.update(visible=False), gr.update(visible=False), []
193
 
194
- # Process files in GPU-efficient chunks.
195
- # Grouping files into chunks of 32 enables concurrent processing in VRAM on a single GPU node.
196
- chunk_size = 32
197
- chunks = [files_to_process[i:i + chunk_size] for i in range(0, len(files_to_process), chunk_size)]
198
-
199
  results = []
200
- print(f"Processing {len(files_to_process)} files in {len(chunks)} GPU batches (max concurrent batches={max_workers})...")
201
 
202
- with ThreadPoolExecutor(max_workers=max_workers) as executor:
203
- futures = {
204
- executor.submit(convert_file_batch_on_single_gpu, chunk, output_dir): idx
205
- for idx, chunk in enumerate(chunks)
206
- }
207
- for future in as_completed(futures):
208
- chunk_results = future.result()
209
- results.extend(chunk_results)
210
 
211
  zip_output_path = os.path.join(temp_workspace, "converted_markdown_files.zip")
212
  with zipfile.ZipFile(zip_output_path, 'w', zipfile.ZIP_DEFLATED) as zip_out:
 
191
  if not files_to_process:
192
  return "No supported document files found to convert.", gr.update(visible=False), gr.update(visible=False), []
193
 
194
+ # Process ALL files in a single GPU call.
195
+ # The GPU function uses ThreadPoolExecutor(max_workers=32) internally,
196
+ # so 32 files run concurrently and as each finishes, the next one starts.
197
+ # This maximizes GPU utilization with a single model load.
 
198
  results = []
199
+ print(f"Processing {len(files_to_process)} files on single GPU node (32-way VRAM worker pool)...")
200
 
201
+ batch_results = convert_file_batch_on_single_gpu(files_to_process, output_dir)
202
+ results.extend(batch_results)
 
 
 
 
 
 
203
 
204
  zip_output_path = os.path.join(temp_workspace, "converted_markdown_files.zip")
205
  with zipfile.ZipFile(zip_output_path, 'w', zipfile.ZIP_DEFLATED) as zip_out: