hilmantm commited on
Commit
1629170
·
1 Parent(s): 5b38d2b

feat: implement demo layout

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import torch
3
+ from PIL import Image
4
+ import io
5
+ import gradio as gr
6
+
7
+ accident_detector = pipeline(model="hilmantm/detr-traffic-accident-detection")
8
+
9
+ import gradio as gr
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown(
13
+ """
14
+ # Hello!!!
15
+ Welcome to the live demonstration of our traffic accident detection application! Experience cutting-edge technology designed to enhance road safety and provide real-time accident alerts. Let's explore the capabilities of our innovative solution together.
16
+ """)
17
+
18
+ gr.Markdown("## Detect Accident from Image")
19
+ with gr.Row():
20
+ with gr.Column():
21
+ input_image = gr.Image(label="Input image", type="pil")
22
+ inp = gr.Textbox(label="Image URL", placeholder="You have image from URL? Drop here")
23
+ with gr.Column():
24
+ output_image = gr.Image(label="Output image with predicted accident", type="pil")
25
+
26
+ gr.Button(value="Detect Accident")
27
+
28
+
29
+ gr.Markdown("## Detect Accident from Video")
30
+ with gr.Row():
31
+ with gr.Column():
32
+ inp = gr.Textbox(label="Youtube URL", placeholder="You should upload video to youtube and drop the link here")
33
+ with gr.Column():
34
+ output_image = gr.Image(label="Output image with predicted accident", type="pil")
35
+
36
+ gr.Button(value="Detect Accident")
37
+
38
+
39
+ if __name__ == "__main__":
40
+ demo.launch(debug=True)