Spaces:
Sleeping
Sleeping
smaller batch
Browse files- tasks/image.py +3 -4
tasks/image.py
CHANGED
|
@@ -248,8 +248,9 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
| 248 |
# Second pass - batch predictions
|
| 249 |
for i, batch_start in enumerate(range(0, n_examples, BATCH_SIZE)):
|
| 250 |
batch_end = min(batch_start + BATCH_SIZE, n_examples)
|
| 251 |
-
|
| 252 |
-
|
|
|
|
| 253 |
# Get batch of images
|
| 254 |
batch_images = [test_dataset[i]['image'] for i in range(batch_start, batch_end)]
|
| 255 |
|
|
@@ -283,12 +284,10 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
| 283 |
# Process predicted boxes
|
| 284 |
try:
|
| 285 |
if len(all_preds[idx]) < 1:
|
| 286 |
-
print("No boxes found")
|
| 287 |
model_preds = [0, 0, 0, 0]
|
| 288 |
else:
|
| 289 |
model_preds = all_preds[idx]
|
| 290 |
except:
|
| 291 |
-
print("No boxes found")
|
| 292 |
model_preds = [0, 0, 0, 0]
|
| 293 |
pred_boxes.append(model_preds)
|
| 294 |
|
|
|
|
| 248 |
# Second pass - batch predictions
|
| 249 |
for i, batch_start in enumerate(range(0, n_examples, BATCH_SIZE)):
|
| 250 |
batch_end = min(batch_start + BATCH_SIZE, n_examples)
|
| 251 |
+
if i % 100 == 0:
|
| 252 |
+
print(f"Processing batch {batch_start//BATCH_SIZE + 1} of {(n_examples + BATCH_SIZE - 1)//BATCH_SIZE}")
|
| 253 |
+
print(f"Batch start: {batch_start}, Batch end: {batch_end}")
|
| 254 |
# Get batch of images
|
| 255 |
batch_images = [test_dataset[i]['image'] for i in range(batch_start, batch_end)]
|
| 256 |
|
|
|
|
| 284 |
# Process predicted boxes
|
| 285 |
try:
|
| 286 |
if len(all_preds[idx]) < 1:
|
|
|
|
| 287 |
model_preds = [0, 0, 0, 0]
|
| 288 |
else:
|
| 289 |
model_preds = all_preds[idx]
|
| 290 |
except:
|
|
|
|
| 291 |
model_preds = [0, 0, 0, 0]
|
| 292 |
pred_boxes.append(model_preds)
|
| 293 |
|