Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
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
|
| 195 |
-
#
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
results = []
|
| 200 |
-
print(f"Processing {len(files_to_process)} files
|
| 201 |
|
| 202 |
-
|
| 203 |
-
|
| 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:
|