VishalD1234 commited on
Commit
43eb4dd
·
verified ·
1 Parent(s): a702daa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -14
app.py CHANGED
@@ -160,15 +160,23 @@ def predict(prompt, video_data, temperature, model, tokenizer):
160
  def get_analysis_prompt(step_number, possible_reasons):
161
  """Constructs the prompt for analyzing delay reasons based on the selected step."""
162
  return f"""You are an AI expert system specialized in analyzing manufacturing processes and identifying production delays in tire manufacturing. Your role is to accurately classify delay reasons based on visual evidence from production line footage.
163
- Task Context:
164
- You are analyzing video footage from Step {step_number} of a tire manufacturing process where a delay has been detected. Your task is to determine the most likely cause of the delay from the following possible reasons:
165
- {', '.join(possible_reasons)}
166
- Required Analysis:
167
- - Carefully observe the video for visual cues indicating production interruption.
168
- - If no person is visible in any of the frames, the reason probably might be due to their absence.
169
- - If a person is visible in the video and is observed touching and modifying the layers of the tire, it means there is an issue with the tire being patched, hence they are repairing it.
170
- Compare observed evidence against each possible delay reason.
171
- """
 
 
 
 
 
 
 
 
172
 
173
  def inference(video, step_number, observed_time, issues=""):
174
  """Analyzes video and additional step data for delay analysis."""
@@ -187,11 +195,11 @@ def inference(video, step_number, observed_time, issues=""):
187
  return f"An error occurred during analysis: {str(e)}"
188
 
189
  def create_interface():
190
- """Creates the Gradio interface for the Manufacturing Delay Analysis System."""
191
  with gr.Blocks() as demo:
192
  gr.Markdown("""
193
  # Manufacturing Delay Analysis System
194
- Upload a video of the manufacturing step, input observed time, and note specific issues.
195
  The system will analyze the video and determine the most likely cause of delay.
196
  """)
197
 
@@ -202,16 +210,30 @@ def create_interface():
202
  choices=list(DELAY_REASONS.keys()),
203
  label="Manufacturing Step"
204
  )
205
- observed_time = gr.Number(label="Observed Time (seconds)")
206
- issues = gr.Textbox(label="Specific Issues (optional)")
207
  analyze_btn = gr.Button("Analyze Delay", variant="primary")
208
 
209
  with gr.Column():
210
  output = gr.Textbox(label="Analysis Result", lines=10)
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  analyze_btn.click(
213
  fn=inference,
214
- inputs=[video, step_number, observed_time, issues],
215
  outputs=[output]
216
  )
217
 
 
160
  def get_analysis_prompt(step_number, possible_reasons):
161
  """Constructs the prompt for analyzing delay reasons based on the selected step."""
162
  return f"""You are an AI expert system specialized in analyzing manufacturing processes and identifying production delays in tire manufacturing. Your role is to accurately classify delay reasons based on visual evidence from production line footage.
163
+ Task Context:
164
+ You are analyzing video footage from Step {step_number} of a tire manufacturing process where a delay has been detected. Your task is to determine the most likely cause of the delay from the following possible reasons:
165
+ {', '.join(possible_reasons)}
166
+ Required Analysis:
167
+ Carefully observe the video for visual cues indicating production interruption.
168
+ If no person is visible in any of the frames, the reason probably might be due to his absence.
169
+ If a person is visible in the video and is observed touching and modifying the layers of the tire, it means there is a issue with tyre being patched hence he is repairing it.
170
+ Compare observed evidence against each possible delay reason.
171
+ Select the most likely reason based on visual evidence.
172
+ Please provide your analysis in the following format:
173
+ 1. Selected Reason: [State the most likely reason from the given options]
174
+ 2. Visual Evidence: [Describe specific visual cues that support your selection]
175
+ 3. Reasoning: [Explain why this reason best matches the observed evidence]
176
+ 4. Alternative Analysis: [Brief explanation of why other possible reasons are less likely]
177
+ Important: Base your analysis solely on visual evidence from the video. Focus on concrete, observable details rather than assumptions. Clearly state if no person or specific activity is observed."""
178
+
179
+ model, tokenizer = load_model()
180
 
181
  def inference(video, step_number, observed_time, issues=""):
182
  """Analyzes video and additional step data for delay analysis."""
 
195
  return f"An error occurred during analysis: {str(e)}"
196
 
197
  def create_interface():
198
+ """Creates the Gradio interface for the Manufacturing Delay Analysis System with examples."""
199
  with gr.Blocks() as demo:
200
  gr.Markdown("""
201
  # Manufacturing Delay Analysis System
202
+ Upload a video of the manufacturing step and select the step number.
203
  The system will analyze the video and determine the most likely cause of delay.
204
  """)
205
 
 
210
  choices=list(DELAY_REASONS.keys()),
211
  label="Manufacturing Step"
212
  )
 
 
213
  analyze_btn = gr.Button("Analyze Delay", variant="primary")
214
 
215
  with gr.Column():
216
  output = gr.Textbox(label="Analysis Result", lines=10)
217
 
218
+ # Add examples
219
+ examples = [
220
+ ["7838_step2_2_eval.mp4", "Step 2"],
221
+ ["7838_step6_2_eval.mp4", "Step 6"],
222
+ ["7838_step8_1_eval.mp4", "Step 8"],
223
+ ["7993_step6_3_eval.mp4", "Step 6"],
224
+ ["7993_step8_3_eval.mp4", "Step 8"]
225
+
226
+ ]
227
+
228
+ gr.Examples(
229
+ examples=examples,
230
+ inputs=[video, step_number],
231
+ cache_examples=False
232
+ )
233
+
234
  analyze_btn.click(
235
  fn=inference,
236
+ inputs=[video, step_number],
237
  outputs=[output]
238
  )
239