Gabriel commited on
Commit
dcc55fe
1 Parent(s): d7f3fa0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -46,10 +46,17 @@ def download_batch_images(batch_id: str, workers: int = 2, progress=None):
46
 
47
  if progress:
48
  progress(0, desc=f"Starting download for {batch_id}...")
49
-
 
 
 
 
 
 
 
50
  with ThreadPoolExecutor(max_workers=workers) as executor:
51
  for image_id in image_ids:
52
- executor.submit(download_image_by_image_id, image_id)
53
 
54
  # Zip the folder with downloaded images
55
  zip_filename = f"{batch_id}.zip"
@@ -60,9 +67,10 @@ def download_batch_images(batch_id: str, workers: int = 2, progress=None):
60
 
61
  if progress:
62
  progress(1, desc=f"Completed {batch_id}")
63
-
64
  return zip_filename
65
 
 
66
  def gradio_interface(batch_ids_input, progress=gr.Progress()):
67
  batch_ids = [batch_id.strip() for batch_id in batch_ids_input.split("\n") if batch_id.strip()]
68
 
 
46
 
47
  if progress:
48
  progress(0, desc=f"Starting download for {batch_id}...")
49
+
50
+ def track_download(image_id):
51
+ download_image_by_image_id(image_id)
52
+ if progress:
53
+ # Update progress after each image
54
+ current_progress = image_ids.index(image_id) / total_images
55
+ progress(current_progress, desc=f"Downloading {image_id}...")
56
+
57
  with ThreadPoolExecutor(max_workers=workers) as executor:
58
  for image_id in image_ids:
59
+ executor.submit(track_download, image_id)
60
 
61
  # Zip the folder with downloaded images
62
  zip_filename = f"{batch_id}.zip"
 
67
 
68
  if progress:
69
  progress(1, desc=f"Completed {batch_id}")
70
+
71
  return zip_filename
72
 
73
+
74
  def gradio_interface(batch_ids_input, progress=gr.Progress()):
75
  batch_ids = [batch_id.strip() for batch_id in batch_ids_input.split("\n") if batch_id.strip()]
76