Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -171,9 +171,10 @@ def load_model():
|
|
171 |
return model, tokenizer
|
172 |
|
173 |
def predict(prompt, video_data, temperature, model, tokenizer):
|
174 |
-
"""Generates predictions based on the video and textual prompt."""
|
175 |
video = load_video(video_data, strategy='chat')
|
176 |
|
|
|
177 |
inputs = model.build_conversation_input_ids(
|
178 |
tokenizer=tokenizer,
|
179 |
query=prompt,
|
@@ -203,7 +204,10 @@ def predict(prompt, video_data, temperature, model, tokenizer):
|
|
203 |
outputs = outputs[:, inputs['input_ids'].shape[1]:]
|
204 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
205 |
|
206 |
-
return
|
|
|
|
|
|
|
207 |
|
208 |
def get_analysis_prompt(step_number):
|
209 |
"""Constructs the prompt for analyzing delay reasons based on the selected step."""
|
@@ -220,36 +224,19 @@ def get_analysis_prompt(step_number):
|
|
220 |
potential_reasons_text = "\n ".join(potential_delay_reasons)
|
221 |
|
222 |
return f"""
|
223 |
-
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
|
224 |
Task Context:
|
225 |
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}.
|
226 |
Required Analysis:
|
227 |
-
Carefully observe the video for visual cues indicating production interruption.
|
228 |
-
- If no person is visible in any of the frames, the reason probably might be due to their absence.
|
229 |
-
- 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.
|
230 |
-
- Compare observed evidence against the following possible delay reasons:
|
231 |
{potential_reasons_text}
|
232 |
-
|
233 |
-
|
234 |
-
Please provide your output in the following format:
|
235 |
Output:
|
236 |
-
|
237 |
-
|
238 |
-
Delay in Bead Insertion
|
239 |
-
Lack of raw material
|
240 |
-
Inner Liner Adjustment by Technician
|
241 |
-
Person rebuilding defective Tire Sections
|
242 |
-
Manual Adjustment in Ply1 Apply
|
243 |
-
Technician repairing defective Tire Sections
|
244 |
-
Delay in Bead Set
|
245 |
-
Delay in Turnup
|
246 |
-
Person Repairing sidewall
|
247 |
-
Person rebuilding defective Tire Sections
|
248 |
-
Delay in Sidewall Stitching
|
249 |
-
No person available to load Carcass
|
250 |
-
No person available to collect tire
|
251 |
"""
|
252 |
|
|
|
253 |
model, tokenizer = load_model()
|
254 |
|
255 |
def inference(video, step_number):
|
|
|
171 |
return model, tokenizer
|
172 |
|
173 |
def predict(prompt, video_data, temperature, model, tokenizer):
|
174 |
+
"""Generates predictions based on the video and textual prompt, focusing on one delay reason."""
|
175 |
video = load_video(video_data, strategy='chat')
|
176 |
|
177 |
+
# Prepare the inputs for the model
|
178 |
inputs = model.build_conversation_input_ids(
|
179 |
tokenizer=tokenizer,
|
180 |
query=prompt,
|
|
|
204 |
outputs = outputs[:, inputs['input_ids'].shape[1]:]
|
205 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
206 |
|
207 |
+
# Extract the output in the desired format (return just one delay reason)
|
208 |
+
# We can assume the model will return one reason in the format "Output: <delay reason>"
|
209 |
+
return response.strip().split('\n')[-1] # Assuming the reason is on the last line
|
210 |
+
|
211 |
|
212 |
def get_analysis_prompt(step_number):
|
213 |
"""Constructs the prompt for analyzing delay reasons based on the selected step."""
|
|
|
224 |
potential_reasons_text = "\n ".join(potential_delay_reasons)
|
225 |
|
226 |
return f"""
|
227 |
+
You are an AI expert system specialized in analyzing manufacturing processes and identifying production delays in tire manufacturing. Your role is to accurately classify the correct delay reason based on visual evidence from production line footage.
|
228 |
Task Context:
|
229 |
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}.
|
230 |
Required Analysis:
|
231 |
+
Carefully observe the video for visual cues indicating production interruption. The possible delay reasons are:
|
|
|
|
|
|
|
232 |
{potential_reasons_text}
|
233 |
+
Please provide only the most likely delay reason in the following format:
|
234 |
+
|
|
|
235 |
Output:
|
236 |
+
<One specific delay reason>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
"""
|
238 |
|
239 |
+
|
240 |
model, tokenizer = load_model()
|
241 |
|
242 |
def inference(video, step_number):
|