← Back to Pull requests

Using ThreadPool to speed up batch pre-processing #476

Merged
lilohuang merged 1 files (11 lines) on Dec 25, 2017 19:10 UTC
View on GitHub
lilohuang lilohuang commented on Dec 17, 2017 15:58 UTC
Author

Tasks in pre-processing stage are thread safe. Using ThreadPool to improve the batch pre-processing performance at least 2x faster with large batch size. (e.g. python flow --imgdir sample_img/ --model cfg/yolo.cfg --load bin/yolo.weights --batch 32)

Note: Please evaluate the performance improvement with large number of images instead of 8 images in sample_img/ by default.

Diff: 11 lines (+3 / -8) across 1 files Reviewer: thtrieu Review duration: 11712m
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.18) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.18 · 11 lines diff across 1 files
0.18
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 3 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.149
Real PR Conversation Timeline
4 items
codecov-io codecov-io commented on Dec 17, 2017 16:03 UTC
Contributor

Codecov Report


Merging #476 into master will decrease coverage by 0.1%.

The diff coverage is 100%.

![Impacted file tree graph](https://codecov.io/gh/thtrieu/darkflow/pull/476?src=pr&el=tree)

@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
- Coverage   67.27%   67.16%   -0.11%     
==========================================
  Files          33       33              
  Lines        2096     2089       -7     
==========================================
- Hits         1410     1403       -7     
  Misses        686      686

| Impacted Files | Coverage Δ | |
|---|---|---|
| darkflow/net/flow.py | 97.64% <100%> (-0.18%) | :arrow_down: |

------

Continue to review full report at Codecov.

Legend - Click here to learn more

Δ = absolute <relative> (impact), ø = not affected, ? = missing data

Powered by Codecov. Last update a539083...5d022ab. Read the comment docs.

thtrieu thtrieu commented on code on Dec 21, 2017 11:34 UTC
Code Review
darkflow/net/flow.py:1
@@ -115,15 +115,10 @@ def predict(self):
         to_idx = min(from_idx + batch, len(all_inps))
 
         # collect images input in the batch
-        inp_feed = list(); new_all = list()
         this_batch = all_inps[from_idx:to_idx]
-        for inp in this_batch:
-            new_all += [inp]
-            this_inp = os.path.join(inp_path, inp)
-            this_inp = self.framework.preprocess(this_inp)
-            expanded = np.expand_dims(this_inp, 0)
-            inp_feed.append(expanded)
-        this_batch = new_all
+        inp_feed = pool.map(lambda inp: (

Where is this package pool comes from? do we have to import it? install?

lilohuang lilohuang commented on code on Dec 21, 2017 13:56 UTC
Code Review
darkflow/net/flow.py:1
@@ -115,15 +115,10 @@ def predict(self):
         to_idx = min(from_idx + batch, len(all_inps))
 
         # collect images input in the batch
-        inp_feed = list(); new_all = list()
         this_batch = all_inps[from_idx:to_idx]
-        for inp in this_batch:
-            new_all += [inp]
-            this_inp = os.path.join(inp_path, inp)
-            this_inp = self.framework.preprocess(this_inp)
-            expanded = np.expand_dims(this_inp, 0)
-            inp_feed.append(expanded)
-        this_batch = new_all
+        inp_feed = pool.map(lambda inp: (

"pool" variable is initialized as a Python built-in ThreadPool instance at flow.py#L15 which has been used few months in ThreadPool batch post-processing for prediction. 😎

Reviewers
Assignees
lilohuang lilohuang
Labels
risk: low confidence: 90.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 17.8% (LOW) · Higher = larger blast radius
17.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.1% · Lower = rushed or shallow review
90.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2% · Safe to merge
2%