Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -114,36 +114,54 @@ def get_analysis_prompt(step_number, possible_reasons): | |
| 114 | 
             
                    str: A detailed analysis prompt tailored to the given step and reasons.
         | 
| 115 | 
             
                """
         | 
| 116 | 
             
                return f"""
         | 
| 117 | 
            -
                You are  | 
| 118 |  | 
| 119 | 
            -
                Task Context:
         | 
| 120 | 
             
                - Manufacturing Step: {step_number}
         | 
| 121 | 
             
                - Delay Detected: Yes
         | 
| 122 | 
             
                - Possible Reasons for Delay: {', '.join(possible_reasons)}
         | 
| 123 |  | 
| 124 | 
            -
                Required Analysis:
         | 
| 125 | 
            -
                 | 
| 126 | 
            -
                2. Compare the observed evidence with each potential reason for delay, focusing on specific visual indicators:
         | 
| 127 | 
            -
                    - If no technician or worker is visible in the footage, consider the possibility of absence as the delay reason.
         | 
| 128 | 
            -
                    - If a technician is present and actively interacting with materials (e.g., touching or adjusting layers), evaluate whether the interaction indicates an issue requiring manual intervention, such as repatching a misaligned tire layer.
         | 
| 129 | 
            -
                    - Look for machine pauses, material misalignment, missing components, or other visual signals suggesting equipment or procedural issues.
         | 
| 130 |  | 
| 131 | 
            -
                 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 132 | 
             
                Provide your analysis in the following structured format:
         | 
| 133 | 
             
                1. **Selected Reason**: [Clearly state the most likely reason for the delay from the given options.]
         | 
| 134 | 
            -
                2. **Visual Evidence**: [ | 
| 135 | 
            -
                3. **Reasoning**: [Explain  | 
| 136 | 
            -
                4. **Alternative Analysis**: [ | 
| 137 | 
            -
                5. **Recommendations**: [ | 
| 138 | 
            -
             | 
| 139 | 
            -
                Important:
         | 
| 140 | 
            -
                - Base your analysis  | 
| 141 | 
            -
                -  | 
| 142 | 
            -
                -  | 
|  | |
|  | |
| 143 | 
             
                """
         | 
| 144 |  | 
| 145 |  | 
| 146 |  | 
|  | |
| 147 | 
             
            # Load model globally
         | 
| 148 | 
             
            model, tokenizer = load_model()
         | 
| 149 |  | 
|  | |
| 114 | 
             
                    str: A detailed analysis prompt tailored to the given step and reasons.
         | 
| 115 | 
             
                """
         | 
| 116 | 
             
                return f"""
         | 
| 117 | 
            +
                You are a highly advanced AI expert system specialized in analyzing manufacturing processes to diagnose production delays. Your task is to review video footage from Step {step_number} of a tire manufacturing process, where a delay has been identified. Based on visual evidence, your objective is to determine the most accurate reason for the delay from the provided options.
         | 
| 118 |  | 
| 119 | 
            +
                ### Task Context:
         | 
| 120 | 
             
                - Manufacturing Step: {step_number}
         | 
| 121 | 
             
                - Delay Detected: Yes
         | 
| 122 | 
             
                - Possible Reasons for Delay: {', '.join(possible_reasons)}
         | 
| 123 |  | 
| 124 | 
            +
                ### Required Analysis:
         | 
| 125 | 
            +
                Carefully observe the video footage frame by frame, focusing on the following key areas to determine the cause of the delay:
         | 
|  | |
|  | |
|  | |
|  | |
| 126 |  | 
| 127 | 
            +
                1. **Technician Presence and Activity:**
         | 
| 128 | 
            +
                    - Verify whether a technician or worker is visible in the footage.
         | 
| 129 | 
            +
                    - If no technician is observed, the delay may be due to their absence.
         | 
| 130 | 
            +
                    - If a technician is visible, analyze their actions:
         | 
| 131 | 
            +
                        - If they are collecting or loading a carcass, ensure the process is efficient and within standard time limits.
         | 
| 132 | 
            +
                        - If they are observed repairing the inner liner or sidewall, this indicates material or application issues as the cause of the delay.
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                2. **Material or Process Anomalies:**
         | 
| 135 | 
            +
                    - Look for visible defects, such as misaligned layers, improperly applied materials, or damaged components.
         | 
| 136 | 
            +
                    - Check for any signs of manual intervention, such as a technician adjusting or repatching layers.
         | 
| 137 | 
            +
                    - Identify issues with the machine operation, such as pauses, misfeeds, or alignment problems.
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                3. **Equipment Functionality:**
         | 
| 140 | 
            +
                    - Detect if machinery is operating below standard speed, stopping unexpectedly, or failing to perform its task (e.g., applying materials, stitching).
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                4. **Process-Specific Observations:**
         | 
| 143 | 
            +
                    - Determine if the technician is waiting for materials, which may indicate supply chain interruptions.
         | 
| 144 | 
            +
                    - Check for excessive manual handling, which could signal inadequate automation or equipment failure.
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                ### Output Requirements:
         | 
| 147 | 
             
                Provide your analysis in the following structured format:
         | 
| 148 | 
             
                1. **Selected Reason**: [Clearly state the most likely reason for the delay from the given options.]
         | 
| 149 | 
            +
                2. **Visual Evidence**: [Detail specific observations that support your conclusion, such as technician actions, material issues, or machine behavior.]
         | 
| 150 | 
            +
                3. **Reasoning**: [Explain why this reason is most consistent with the evidence. Include links between specific observations and the identified delay reason.]
         | 
| 151 | 
            +
                4. **Alternative Analysis**: [Summarize why other possible reasons are less likely, referencing specific observations or lack of evidence.]
         | 
| 152 | 
            +
                5. **Recommendations**: [Provide actionable suggestions to resolve the delay cause, such as adjustments to machinery, improved training, or material quality checks.]
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                ### Important Considerations:
         | 
| 155 | 
            +
                - Base your analysis strictly on observable evidence from the video.
         | 
| 156 | 
            +
                - Do not make assumptions not supported by visual data.
         | 
| 157 | 
            +
                - If the evidence is inconclusive, state this explicitly and suggest further investigative actions.
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                Note: Pay particular attention to technician interactions with the inner liner repairing, sidewall repairing, and carcass handling, as these are critical indicators of delay causes.
         | 
| 160 | 
             
                """
         | 
| 161 |  | 
| 162 |  | 
| 163 |  | 
| 164 | 
            +
             | 
| 165 | 
             
            # Load model globally
         | 
| 166 | 
             
            model, tokenizer = load_model()
         | 
| 167 |  |