Roboflow OpenAI Decisions Switch 助力工作流图像智能分支决策

An intelligent routing tool in workflow systems can direct each image to the appropriate processing branch. This tool, called a decision switch, sends a multiple-choice question about an image to a large language model, then executes the branch whose answer meets a set probability threshold. Two practical applications of this technology are sorting items on a recycling conveyor belt and dispatching road maintenance teams based on real-time air temperature.
How the Decision Switch Operates
The model offers answer options that include predefined cases plus a built-in "none of these" option, and the system returns a probability score for each choice. The decision switch only activates a specific branch if the top-scoring case meets or exceeds a user-defined confidence threshold. If no case reaches this threshold, the workflow follows default next steps, or stops entirely if no default steps are set.
Example 1: Recycling Line Sorting
An instance segmentation model identifies and tracks every item moving along the conveyor belt. The decision switch receives a cropped view of each item, marked with a magenta outline to avoid confusion from overlapping objects, then selects one of six material categories: PET, HDPE, film, multilayer plastic, paper, or aluminum. For each item, the system queries the decision API three times as the item moves, averages the results, and uses gray tags to mark items whose top-scoring category remains below a 0.5 confidence level.
Example 2: Integrating Non-Image Context Data
Road maintenance crews use hot asphalt for pothole repair only when temperatures are 10 degrees Celsius or above, otherwise they use cold patch material. Since a photo cannot display the current temperature, the workflow pulls real-time air temperature data from a weather feed and includes it as context alongside the image. Each predefined case refers to this context value by name: for instance, the cold patch case specifies that the road has potholes or damaged surfaces, but the temperature is too low for hot asphalt, so cold patch is the appropriate repair method.
At a 0.8 confidence threshold, test results show clear patterns: a rural road pothole photo with 20°C temperature triggers hot asphalt repair with 99% probability, leading to a paving crew dispatch. The same photo with 4°C temperature selects cold patch with 95% probability, assigning a pothole patrol team. A photo of dry, intact asphalt at 20°C results in the "none of these" case with 65% probability, so no action is taken. A close-up of snow with tire tracks at -3°C scores 65% for salt spreading, which is below the threshold, so no action runs.
Key Settings for the Decision Block
To set up the decision switch, users define four core components: a question to guide the model's choice, cases corresponding to each processing branch (each linked to the first step of the branch), a one-sentence description for each case to clarify when it applies, and optional context data for non-image facts. A case activates only if it is the top answer and meets the minimum confidence level (default 0.9). If no case meets the threshold, the workflow uses default next steps. For simpler decisions, a model cascade may be more cost-effective than this decision switch.
Choosing the Right Confidence Threshold
Adjusting the minimum confidence threshold balances the number of incorrect routes and items needing manual review. Testing on 100 public garbage classification photos (with six material categories as cases) shows: at a 0.5 threshold, 80 decisions are correct, 16 are wrong, and 4 items need manual review; at 0.9 threshold, 72 are correct, 3 wrong, and 25 need review. The threshold should be set based on the cost of errors: for recycling sorting, where uncertain items go to manual sorters, a 0.5 threshold works. For road dispatch, where wrong calls waste crew time, a 0.8 threshold is better. To check probabilities during setup, run the decision block in question mode, which outputs each option's probability score.
Implementation Steps
To use this decision switch in a workflow: 1. Add the decision switch block and connect the image input. 2. Write the guiding question, add one case per action, and describe each case in a single sentence. 3. Set the default next steps and minimum confidence threshold. 4. Test with real photos, disabling output sinks to avoid actual actions. If good photos end up needing manual review, refine the case descriptions before lowering the threshold.
The block uses standard industry credits by default, or users can use their own API keys. Each image processing request uses a few hundred to a few thousand input tokens.

