VishalD1234 commited on
Commit
d20dd63
·
verified ·
1 Parent(s): c0b4a24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -39
app.py CHANGED
@@ -10,8 +10,6 @@ MODEL_PATH = "THUDM/cogvlm2-video-llama3-chat"
10
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
11
  TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
12
 
13
- # Delay Reasons for Each Manufacturing Step
14
-
15
  def get_step_info(step_number):
16
  """Returns detailed information about a manufacturing step."""
17
  step_details = {
@@ -81,18 +79,12 @@ def get_step_info(step_number):
81
  "Standard Time": "7 seconds",
82
  "Video_substeps_expected": {
83
  "0-3 seconds": "Technician unloads(removes) carcass(tire) from the machine."
84
- },
85
- "Potential_Delay_reasons": [
86
- "Person not available in time(in 3 sec) to remove carcass.",
87
- "Person is doing bead(ring) insertion before carcass unload causing unload to be delayed by more than 3 sec"
88
- ]
89
  }
90
  }
91
 
92
  return step_details.get(step_number, {"Error": "Invalid step number. Please provide a valid step number."})
93
 
94
-
95
-
96
  def load_video(video_data, strategy='chat'):
97
  """Loads and processes video data into a format suitable for model input."""
98
  bridge.set_bridge('torch')
@@ -183,37 +175,13 @@ def get_analysis_prompt(step_number):
183
 
184
  step_name = step_info["Name"]
185
  standard_time = step_info["Standard Time"]
186
- analysis = step_info["Analysis"]
187
 
188
  return f"""
189
- 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.
190
- Task Context:
191
- You are analyzing video footage from Step {step_number} of a tire manufacturing process where a delay has been detected. The step is called {step_name}, and its standard time is {standard_time}.
192
- Required Analysis:
193
- Carefully observe the video for visual cues indicating production interruption.
194
- - If no person is visible in any of the frames, the reason probably might be due to their absence.
195
- - If a person is visible in the video and is observed touching and modifying the layers of the tire, it indicates an issue with tire patching, and the person might be repairing it.
196
- - Compare observed evidence against the following possible delay reasons:
197
- - {analysis}
198
- Following are the subactivities needs to happen in this step.
199
-
200
- {get_step_info(step_number)}
201
-
202
- Important:Please provide your output in the following format.
203
- Output_Examples = {
204
- ["Delay in Bead Insertion", "Lack of raw material"],
205
- ["Inner Liner Adjustment by Technician", "Person rebuilding defective Tire Sections"],
206
- ["Manual Adjustment in Ply1 Apply", "Technician repairing defective Tire Sections"],
207
- ["Delay in Bead Set", "Lack of raw material"],
208
- ["Delay in Turnup", "Lack of raw material"],
209
- ["Person Repairing Sidewall", "Person rebuilding defective Tire Sections"],
210
- ["Delay in Sidewall Stitching", "Lack of raw material"],
211
- ["No person available to load Carcass", "No person available to collect tire"]
212
- }
213
- 1. **Selected Reason:** [State the most likely reason from the given options]
214
- 2. **Visual Evidence:** [Describe specific visual cues that support your selection]
215
- 3. **Reasoning:** [Explain why this reason best matches the observed evidence]
216
- 4. **Alternative Analysis:** [Brief explanation of why other possible reasons are less likely]
217
  """
218
 
219
  model, tokenizer = load_model()
@@ -275,4 +243,4 @@ def create_interface():
275
 
276
  if __name__ == "__main__":
277
  demo = create_interface()
278
- demo.queue().launch(share=True)
 
10
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
11
  TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
12
 
 
 
13
  def get_step_info(step_number):
14
  """Returns detailed information about a manufacturing step."""
15
  step_details = {
 
79
  "Standard Time": "7 seconds",
80
  "Video_substeps_expected": {
81
  "0-3 seconds": "Technician unloads(removes) carcass(tire) from the machine."
82
+ }
 
 
 
 
83
  }
84
  }
85
 
86
  return step_details.get(step_number, {"Error": "Invalid step number. Please provide a valid step number."})
87
 
 
 
88
  def load_video(video_data, strategy='chat'):
89
  """Loads and processes video data into a format suitable for model input."""
90
  bridge.set_bridge('torch')
 
175
 
176
  step_name = step_info["Name"]
177
  standard_time = step_info["Standard Time"]
178
+ video_substeps = step_info["Video_substeps_expected"]
179
 
180
  return f"""
181
+ You are an AI expert system specializing in manufacturing process analysis.
182
+ Analyze the video for Step {step_number}: {step_name}, with a standard time of {standard_time}.
183
+ Observe for deviations in the expected substeps: {video_substeps}.
184
+ Provide delay analysis based on visual evidence, such as worker actions, material handling, or equipment delays.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  """
186
 
187
  model, tokenizer = load_model()
 
243
 
244
  if __name__ == "__main__":
245
  demo = create_interface()
246
+ demo.queue().launch(share=True)