Spaces:
Sleeping
Sleeping
VishalD1234
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -11,52 +11,52 @@ 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 |
|
14 |
-
def get_step_info(
|
15 |
"""Returns detailed information about a manufacturing step."""
|
16 |
step_details = {
|
17 |
-
|
18 |
"Name": "Bead Insertion",
|
19 |
"Standard Time": "4 seconds",
|
20 |
"Analysis": "Observe the bead placement process. If the insertion exceeds 4 seconds, identify potential issues such as missing beads, technician errors, or machinery malfunction."
|
21 |
},
|
22 |
-
|
23 |
"Name": "Inner Liner Apply",
|
24 |
"Standard Time": "4 seconds",
|
25 |
"Analysis": "Check for manual intervention during the inner layer application. If adjustment is required, it may indicate improper alignment or issues with the layer material."
|
26 |
},
|
27 |
-
|
28 |
"Name": "Ply1 Apply",
|
29 |
"Standard Time": "4 seconds",
|
30 |
"Analysis": "Determine if the technician is manually adjusting the first ply. Manual intervention might suggest improper ply placement or machine misalignment."
|
31 |
},
|
32 |
-
|
33 |
"Name": "Bead Set",
|
34 |
"Standard Time": "8 seconds",
|
35 |
"Analysis": "Observe the bead setting process. Delays may result from bead misalignment, machine pauses, or lack of technician involvement."
|
36 |
},
|
37 |
-
|
38 |
"Name": "Turnup",
|
39 |
"Standard Time": "4 seconds",
|
40 |
"Analysis": "Examine the turnup step for any technician involvement or pauses in machine operation. Reasons for delays might include material misalignment or equipment issues."
|
41 |
},
|
42 |
-
|
43 |
"Name": "Sidewall Apply",
|
44 |
"Standard Time": "14 seconds",
|
45 |
"Analysis": "If a technician is repairing the sidewall, this may indicate material damage or improper initial application. Look for signs of excessive manual handling."
|
46 |
},
|
47 |
-
|
48 |
"Name": "Sidewall Stitching",
|
49 |
"Standard Time": "5 seconds",
|
50 |
"Analysis": "Observe the stitching process. Delays could occur due to machine speed inconsistencies or technician intervention for correction."
|
51 |
},
|
52 |
-
|
53 |
"Name": "Carcass Unload",
|
54 |
"Standard Time": "7 seconds",
|
55 |
"Analysis": "Ensure a technician is present for the carcass unload. If absent, note their return time and identify potential reasons for their absence."
|
56 |
}
|
57 |
}
|
58 |
|
59 |
-
return step_details.get(
|
60 |
|
61 |
|
62 |
def load_video(video_data, strategy='chat'):
|
@@ -140,11 +140,11 @@ def predict(prompt, video_data, temperature, model, tokenizer):
|
|
140 |
|
141 |
return response
|
142 |
|
143 |
-
def get_analysis_prompt(
|
144 |
"""Constructs the prompt for analyzing delay reasons based on the selected step."""
|
145 |
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.
|
146 |
Task Context:
|
147 |
-
You are analyzing video footage from Step {
|
148 |
Required Analysis:
|
149 |
Carefully observe the video for visual cues indicating production interruption.
|
150 |
If no person is visible in any of the frames, the reason probably might be due to his absence.
|
@@ -160,7 +160,7 @@ Important: Base your analysis solely on visual evidence from the video. Focus on
|
|
160 |
|
161 |
model, tokenizer = load_model()
|
162 |
|
163 |
-
def inference(video,
|
164 |
"""Analyzes video to predict possible issues based on the manufacturing step."""
|
165 |
try:
|
166 |
if not video:
|
@@ -197,8 +197,8 @@ def create_interface():
|
|
197 |
|
198 |
gr.Examples(
|
199 |
examples=[
|
200 |
-
["7838_step2_2_eval.mp4",
|
201 |
-
["7838_step6_2_eval.mp4",
|
202 |
],
|
203 |
inputs=[video, step_number],
|
204 |
cache_examples=False
|
@@ -214,4 +214,4 @@ def create_interface():
|
|
214 |
|
215 |
if __name__ == "__main__":
|
216 |
demo = create_interface()
|
217 |
-
demo.queue().launch(share=True)
|
|
|
11 |
TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
|
12 |
|
13 |
|
14 |
+
def get_step_info(step_number):
|
15 |
"""Returns detailed information about a manufacturing step."""
|
16 |
step_details = {
|
17 |
+
1: {
|
18 |
"Name": "Bead Insertion",
|
19 |
"Standard Time": "4 seconds",
|
20 |
"Analysis": "Observe the bead placement process. If the insertion exceeds 4 seconds, identify potential issues such as missing beads, technician errors, or machinery malfunction."
|
21 |
},
|
22 |
+
2: {
|
23 |
"Name": "Inner Liner Apply",
|
24 |
"Standard Time": "4 seconds",
|
25 |
"Analysis": "Check for manual intervention during the inner layer application. If adjustment is required, it may indicate improper alignment or issues with the layer material."
|
26 |
},
|
27 |
+
3: {
|
28 |
"Name": "Ply1 Apply",
|
29 |
"Standard Time": "4 seconds",
|
30 |
"Analysis": "Determine if the technician is manually adjusting the first ply. Manual intervention might suggest improper ply placement or machine misalignment."
|
31 |
},
|
32 |
+
4: {
|
33 |
"Name": "Bead Set",
|
34 |
"Standard Time": "8 seconds",
|
35 |
"Analysis": "Observe the bead setting process. Delays may result from bead misalignment, machine pauses, or lack of technician involvement."
|
36 |
},
|
37 |
+
5: {
|
38 |
"Name": "Turnup",
|
39 |
"Standard Time": "4 seconds",
|
40 |
"Analysis": "Examine the turnup step for any technician involvement or pauses in machine operation. Reasons for delays might include material misalignment or equipment issues."
|
41 |
},
|
42 |
+
6: {
|
43 |
"Name": "Sidewall Apply",
|
44 |
"Standard Time": "14 seconds",
|
45 |
"Analysis": "If a technician is repairing the sidewall, this may indicate material damage or improper initial application. Look for signs of excessive manual handling."
|
46 |
},
|
47 |
+
7: {
|
48 |
"Name": "Sidewall Stitching",
|
49 |
"Standard Time": "5 seconds",
|
50 |
"Analysis": "Observe the stitching process. Delays could occur due to machine speed inconsistencies or technician intervention for correction."
|
51 |
},
|
52 |
+
8: {
|
53 |
"Name": "Carcass Unload",
|
54 |
"Standard Time": "7 seconds",
|
55 |
"Analysis": "Ensure a technician is present for the carcass unload. If absent, note their return time and identify potential reasons for their absence."
|
56 |
}
|
57 |
}
|
58 |
|
59 |
+
return step_details.get(step_number, {"Error": "Invalid step number. Please provide a valid step number."})
|
60 |
|
61 |
|
62 |
def load_video(video_data, strategy='chat'):
|
|
|
140 |
|
141 |
return response
|
142 |
|
143 |
+
def get_analysis_prompt(step_number):
|
144 |
"""Constructs the prompt for analyzing delay reasons based on the selected step."""
|
145 |
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.
|
146 |
Task Context:
|
147 |
+
You are analyzing video footage from Step {step_number} of a tire manufacturing process where a delay has been detected.
|
148 |
Required Analysis:
|
149 |
Carefully observe the video for visual cues indicating production interruption.
|
150 |
If no person is visible in any of the frames, the reason probably might be due to his absence.
|
|
|
160 |
|
161 |
model, tokenizer = load_model()
|
162 |
|
163 |
+
def inference(video, step_number):
|
164 |
"""Analyzes video to predict possible issues based on the manufacturing step."""
|
165 |
try:
|
166 |
if not video:
|
|
|
197 |
|
198 |
gr.Examples(
|
199 |
examples=[
|
200 |
+
["7838_step2_2_eval.mp4", 2],
|
201 |
+
["7838_step6_2_eval.mp4", 6]
|
202 |
],
|
203 |
inputs=[video, step_number],
|
204 |
cache_examples=False
|
|
|
214 |
|
215 |
if __name__ == "__main__":
|
216 |
demo = create_interface()
|
217 |
+
demo.queue().launch(share=True)
|