{"record":{"id":"3a904d2df4fa85c4","repo":"tensorflow/models","slug":"predict-requires-at-least-one-image","errorCode":null,"errorMessage":"predict requires at least one image.","messagePattern":"predict requires at least one image\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py","lineNumber":226,"sourceCode":"    \"\"\"Classifies a list of PIL images in a single forward pass.\n\n    Args:\n        pil_images: Sequence of RGB PIL images (length >= 1).\n\n    Returns:\n        One prediction dict per input image, in the same order::\n\n            {\n                \"predicted_class\": str,\n                \"predicted_probability\": float,  # 0-100\n                \"all_probabilities\": dict[str, float],\n            }\n\n    Raises:\n        ValueError: If ``pil_images`` is empty.\n    \"\"\"\n    if not pil_images:\n      raise ValueError(\"predict requires at least one image.\")\n\n    batch = torch.stack([self._eval_transform(img) for img in pil_images]).to(\n        self.device\n    )\n\n    logits = self.model(batch)\n    probabilities = torch_functional.softmax(logits, dim=1).cpu().numpy()\n\n    predictions = []\n    for probability_row in probabilities:\n      predicted_index = int(np.argmax(probability_row))\n      predictions.append({\n          \"predicted_class\": self.class_names[predicted_index],\n          \"predicted_probability\": float(\n              probability_row[predicted_index] * 100.0\n          ),\n          \"all_probabilities\": {\n              name: float(p * 100.0)","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py#L208-L244","documentation":"Error \"predict requires at least one image.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}