{"slug": "injection-molding-defect-detection-for-medical-components", "title": "Injection Molding Defect Detection for Medical Components", "summary": "Roboflow released a tutorial on building an injection molding defect detection system for medical components using its RF-DETR model and Gemini 2.5 Pro. The system automatically detects cracks, breaks, and surface contamination in molded parts, generating bounding boxes and AI-powered inspection notes. The approach aims to reduce the estimated $12 billion in annual waste from injection molding defects.", "body_md": "*Detect injection molding defects automatically by training a Roboflow RF-DETR model on labeled defect images, then deploying it in a Roboflow Workflow that draws bounding boxes around cracks, breaks, and surface contamination. Gemini 2.5 Pro reviews each detection and writes a one-line inspection note, and the same pipeline adapts to medical injection-molded parts such as syringes and IV connectors.*\n\nInjection molding is one of the most widely used [manufacturing](https://roboflow.com/industries/manufacturing?ref=blog.roboflow.com) processes, producing millions of plastic components every day. While the process is highly efficient, [defects](https://roboflow.com/solutions/defect-detection?ref=blog.roboflow.com) can still occur, leading to material waste, increased production costs, and additional quality-control effort.\n\nThe impact is significant. Industry estimates suggest that injection molding defects account for up to $12 billion in annual waste worldwide.\n\nIn this tutorial, we'll build a molding defect detection system using Roboflow. We'll train an [ RF-DETR](https://rfdetr.roboflow.com/latest/?ref=blog.roboflow.com) model, deploy it with a\n\n[, and integrate](https://roboflow.com/workflows/build?ref=blog.roboflow.com)\n\n__Roboflow workflow__[to generate AI-powered inspection observations.](https://playground.roboflow.com/models/google/gemini-2-5-pro?ref=blog.roboflow.com)\n\n__Gemini 2.5 Pro__The final system can:\n\n- Detect defects from images\n- Generate AI-powered inspection observations\n- Produce annotated images with visual detections\n- Demonstrate a workflow that can be adapted for medical manufacturing applications\n\n## Injection Molding Defect Detection for Medical Components\n\n[Here's the workflow we'll build](https://app.roboflow.com/workflows/embed/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3b3JrZmxvd0lkIjoiNUhMSWZ3SFkxZ1ZENG9pRXNCc20iLCJ3b3Jrc3BhY2VJZCI6InJmdnhjT2k5MHJNTXlLSHBvbEM3Q2E5Tk9EMzIiLCJ1c2VySWQiOiJyZnZ4Y09pOTByTU15S0hwb2xDN0NhOU5PRDMyIiwiaWF0IjoxNzgyMzM2NjE5fQ.lxZqKYQfiwQNpCXsJwhaAITYFShH_iNbhvKR_swiWCI?ref=blog.roboflow.com). While the dataset used in this article contains general quality defects on molded components, the same workflow can be applied to medical-specific components and inspection requirements.\n\n### Step 1: Prepare the Dataset\n\nFor this project, we use the Molding Defect Detection [ dataset](https://universe.roboflow.com/molding-2avtd/molding-kabyb?ref=blog.roboflow.com) from\n\n[. The dataset contains annotated defect regions across five classes:](https://universe.roboflow.com/?ref=blog.roboflow.com)\n\n__Roboflow Universe__- MOLDING_BREAK\n- MOLDING_CRACK\n- MOLDING_DEFECT\n- MOLDING_POLLUTION\n- MOLDING_POOR\n\nBefore training, we first remove all images that belong to the null class. Since the goal of this project is to train a model to localize and classify visible quality defects on molded components, we'll use only the images that contain annotations.\n\nHere are a few examples from the dataset:\n\nOnce the dataset has been cleaned, fork it into your Roboflow workspace. Next, navigate to the Train tab and select Custom Training. From the available architectures, choose RF-DETR and set the model size to Small.\n\nBefore starting training, generate a new dataset version and use a 70/15/15 split for training, validation, and testing.\n\nEnable the following preprocessing steps:\n\n- Auto-orientation\n- Resize (512×512)\n\nThese preprocessing steps ensure all images have a consistent orientation and resolution before being used for training.\n\n### Step 2: Train the RF-DETR Model\n\nOnce training begins, RF-DETR learns to identify and localize the annotated defect classes directly from the training images. Unlike a classification model that only predicts whether a defect is present, RF-DETR returns bounding boxes that indicate where defects appear within an image.\n\nThis makes the model particularly useful for inspection workflows. Instead of receiving a simple defect prediction, inspectors can see the exact location of the detected issue and quickly review the affected area.\n\nAfter training completes, the model is ready to be deployed in a Roboflow Workflow. We'll use it as the foundation for our automated inspection pipeline and later integrate Gemini 2.5 Pro to generate inspection observations based on the model's detections.\n\n### Step 3: Build the Roboflow Workflow\n\nAfter training the RF-DETR model, create a Roboflow Workflow that connects defect detection, visualization, Gemini inspection, text formatting, and final image output.\n\nThe workflow contains the following blocks:\n\n**Input:** receives the molded component inspection image.**RF-DETR Object Detection Model:** detects visible defect regions on the molded component.**Bounding Box Visualization:** draws bounding boxes around detected defect regions.**Label Visualization:** adds class labels to the detected regions.**Google Gemini:** inspects the detected regions and generates a short quality-control observation.**Custom Python Block:** formats the Gemini output into a clean inspection summary.**Text Display:** overlays the formatted inspection summary on the annotated image.**Outputs:** returns the final image with bounding boxes, labels, and inspection text.\n\nThis workflow keeps each stage easy to understand. RF-DETR finds the defect regions, the visualization blocks make the detections visible, Gemini describes the detected area, and the formatter prepares the text for display on the final image.\n\nThe completed workflow should resemble the configuration shown below.\n\n### Step 4: Configure the Gemini Inspection Block\n\nThe Gemini block is used after the object detection and visualization blocks. At this stage, the model has already detected the potential defect regions, so Gemini does not need to search for new defects. Its job is to inspect the highlighted areas and generate a short observation.\n\nConnect the Label Visualization image output to the Gemini image input. This gives Gemini the annotated image with the detected regions and labels visible.\n\nUse a prompt like this:\n\n```\nYou are an industrial quality-control inspector.\n\nAn object detection model has already identified defect regions in the image and provided defect class labels.\n\nDo not search for additional defects.\nDo not perform defect detection.\nOnly inspect and describe the defect regions identified by the model.\n\nUsing the provided detections and the image:\n\nExamine the defect region(s) highlighted by the model.\nDescribe what is visually visible inside the detected region.\nMention the detected class label.\nMention the approximate location of the detected region.\nKeep the response to a single concise sentence.\nMaximum 15 words.\nDo not speculate about manufacturing causes.\nDo not explain the inspection process.\n\nExamples:\n\nMOLDING_BREAK detected near the upper edge, showing a visible chipped section; review required.\n\nMOLDING_CRACK detected at the top-right corner, showing a narrow surface crack; review required.\n\nMOLDING_POLLUTION detected in the center region, showing visible surface contamination; review required.\n\nIf no detections are present, return:\n\nNo visible defects detected; inspection passed.\n\nReturn only the inspection summary sentence.\n```\n\nThis keeps Gemini focused on inspection commentary rather than detection. The object detection model decides where the defect is; Gemini simply turns that detection into a readable quality-control observation.\n\n### Step 5: Format the Inspection Output\n\nNext, add a Custom Python Block after Gemini. This block receives the Gemini response and formats it for display on the final annotated image.\n\nUse the Python block to clean the Gemini text and pass back only the inspection summary:\n\n``` python\ndef run(self, gemini_output, predictions):\n    import re\n\n    report = str(gemini_output or \"\").strip()\n    report = re.sub(r\"```.*?```\", \"\", report, flags=re.DOTALL)\n    report = report.replace(\"**\", \"\")\n    report = re.sub(r\"\\s+\", \" \", report)\n\n    return {\"formatted_report\": report}\n```\n\nThen connect the formatter output to the Text Display block.\n\nThe Text Display block overlays the inspection sentence on top of the annotated image. This creates a final output that includes both the visual model detections and the Gemini-generated inspection summary.\n\n### Step 6: Test the Workflow\n\nWith the workflow configured, run inference on several molded component images. Test images with clear defects, smaller defects, and images where the detected region is difficult to inspect.\n\nFor each test image, review:\n\n- The bounding box around the detected defect.\n- The class label applied by the model.\n- The Gemini-generated inspection sentence.\n\nA typical output should show the detected defect region with a label, along with a short inspection sentence placed on the image.\n\n## Applying the Workflow to Medical Component Inspection\n\nWhile this tutorial uses a dataset of visible defects on molded components, the same workflow can be adapted for medical manufacturing by training the model on medical-specific parts and defect categories.\n\nIn a production environment, cameras could be installed at key inspection points to automatically examine components as they move through the manufacturing process. Examples include syringes, IV connectors, diagnostic cartridges, inhaler housings, and other injection-molded [medical devices](https://blog.roboflow.com/medical-device-assembly-verification/).\n\nA typical deployment could involve:\n\n**Image Acquisition**: Industrial cameras capture images of medical components after molding, assembly, or packaging.** Defect Detection**: RF-DETR identifies visible defect regions and classifies them based on the training data.** Inspection Review**: Gemini reviews the detected regions and generates concise inspection observations.** Quality Documentation**: Inspection results are stored for traceability, batch reporting, and audit purposes.** Operator Action**: Components flagged during inspection can be reviewed, reworked, or removed from the production line.\n\nThe overall workflow remains unchanged. RF-DETR continues to detect defect regions, Gemini provides inspection observations, and the final output combines visual detections with human-readable quality information. By replacing the training dataset with medical-specific images, manufacturers can use the same approach to support automated inspection of medical injection-molded components.\n\n## Medical Injection Molding Defect Detection with Roboflow Agent\n\nIf you'd rather not add each block by hand, use [Roboflow Agent](https://app.roboflow.com/solutions/chat/new?ref=blog.roboflow.com). Instead of configuring blocks one at a time, you describe the pipeline you want in plain text and the Agent builds it for you. Here's an example:\n\n## Injection Molding Defect Detection for Medical Components Conclusion\n\nOur final system highlights detected defect regions and generates concise inspection summaries directly on the image. While the dataset used here contains general defects on molded components, the same approach can be applied to medical manufacturing by training on medical-specific parts and defect categories.\n\n**Further reading:**\n\n**Cite this Post**\n\nUse the following entry to cite this post in your research:\n\n[Mostafa Ibrahim](/author/mostafa/). (Jun 29, 2026).\nInjection Molding Defect Detection for Medical Components. Roboflow Blog: https://blog.roboflow.com/injection-molding-defect-detection-for-medical-components/", "url": "https://wpnews.pro/news/injection-molding-defect-detection-for-medical-components", "canonical_source": "https://blog.roboflow.com/injection-molding-defect-detection-for-medical-components/", "published_at": "2026-06-29 17:39:09+00:00", "updated_at": "2026-06-29 17:58:27.897444+00:00", "lang": "en", "topics": ["computer-vision", "ai-tools", "ai-products", "machine-learning", "generative-ai"], "entities": ["Roboflow", "RF-DETR", "Gemini 2.5 Pro", "Roboflow Universe", "Molding Defect Detection dataset"], "alternates": {"html": "https://wpnews.pro/news/injection-molding-defect-detection-for-medical-components", "markdown": "https://wpnews.pro/news/injection-molding-defect-detection-for-medical-components.md", "text": "https://wpnews.pro/news/injection-molding-defect-detection-for-medical-components.txt", "jsonld": "https://wpnews.pro/news/injection-molding-defect-detection-for-medical-components.jsonld"}}