Spaces:
Runtime error
Runtime error
application file and requirements
Browse files- app.py +74 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
article = '''<img src="https://corporateweb-v3-corporatewebv3damstrawebassetbuck-1lruglqypgb84.s3-ap-southeast-2.amazonaws.com/public/cta-2.jpg"/> '''
|
6 |
+
|
7 |
+
examples = [
|
8 |
+
['''
|
9 |
+
A large screen was being lifted into the plant when the crane operator observed someone walk directly under the load. \
|
10 |
+
The drop zone underneath the load had not been adequately barricaded
|
11 |
+
'''
|
12 |
+
],
|
13 |
+
['''
|
14 |
+
While building scaffold to access a pipe for repairs a worker was observed not wearing fall protection while the scaffold \
|
15 |
+
was still being constructed. There was a potential for him to fall over 5 metres from the side of the plant
|
16 |
+
'''
|
17 |
+
],
|
18 |
+
['''
|
19 |
+
A worker was using a grinder in a confined space when he became dizzy from the fumes in the area and had to be helped out. \
|
20 |
+
The gas monitor he was using was found to be faulty and when the area was assessed with another monitor there was an \
|
21 |
+
unacceptably high level of CO2 in the area
|
22 |
+
'''
|
23 |
+
],
|
24 |
+
[
|
25 |
+
'''
|
26 |
+
Henry Winkler tripped over some rocks that had overflowed from the discharge chute of screen 1011. He had been walking past the screen \
|
27 |
+
on the way to the control room. He suffered a bruised hip and broken wrist and had to be transported to Mackay Base Hospital \
|
28 |
+
for treatment.
|
29 |
+
'''
|
30 |
+
],
|
31 |
+
[
|
32 |
+
'''
|
33 |
+
Susan Lauper experienced a mild electrical shock while operating an arc welder in the plant today. It was discovered that the earth \
|
34 |
+
was not effectively grounded due to corrosion and buildup in the work area. She was treated according to site procedures and was \
|
35 |
+
given a medical clearance to return to work by her GP later that day.
|
36 |
+
'''
|
37 |
+
],
|
38 |
+
[
|
39 |
+
'''
|
40 |
+
While conducting regular inspections of the ground floor, guarding was noticed to be missing on the main drive of pump 1330. \
|
41 |
+
This pump had been serviced during the previous maintenance day and it appears that the guard was not replaced prior to startup \
|
42 |
+
and was found nearby. This is a potential breach of isolation procedure and requires further investigation.
|
43 |
+
'''
|
44 |
+
]
|
45 |
+
]
|
46 |
+
|
47 |
+
|
48 |
+
title = "Safety Hazard Classifier"
|
49 |
+
description = "Using zero shot classification to determine which critical hazard an incident belongs to"
|
50 |
+
|
51 |
+
classifier = pipeline("zero-shot-classification", model="Narsil/deberta-large-mnli-zero-cls")
|
52 |
+
|
53 |
+
def predict(text):
|
54 |
+
preds = classifier(text, candidate_labels=["electrical", "confined space", "unguarded machinery", \
|
55 |
+
"spills and tripping hazards", "working from heights", "suspended loads", "machinery related"])
|
56 |
+
return dict(zip(preds['labels'], preds['scores']))
|
57 |
+
|
58 |
+
gradio_ui = gr.Interface(
|
59 |
+
fn=predict,
|
60 |
+
title=title,
|
61 |
+
description=description,
|
62 |
+
inputs=[
|
63 |
+
gr.inputs.Textbox(lines=5, label="Paste some text here"),
|
64 |
+
],
|
65 |
+
outputs=[
|
66 |
+
gr.outputs.Label(num_top_classes=3)
|
67 |
+
],
|
68 |
+
examples=examples,
|
69 |
+
article=article
|
70 |
+
|
71 |
+
)
|
72 |
+
|
73 |
+
gradio_ui.launch(debug=True)
|
74 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
sentencepiece
|
3 |
+
gradio
|
4 |
+
torch
|