Souha commited on
Commit
9bbd70c
β€’
1 Parent(s): 071ef02
Files changed (2) hide show
  1. app.py +59 -0
  2. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from keras_cv_attention_models.yolox import * # import all yolox model
3
+ from keras_cv_attention_models.coco import data
4
+ import matplotlib.pyplot as plt
5
+ import gradio as gr
6
+
7
+
8
+ choices = ["YOLOXNano", "YOLOXS"]
9
+
10
+ def main(input_img, models):
11
+
12
+ #
13
+ fig, ax = plt.subplots()
14
+
15
+ # YOLOXNano models
16
+ if models == "YOLOXNano":
17
+ model = YOLOXNano(pretrained="coco")
18
+
19
+ # YOLOXS models
20
+ elif models == "YOLOXS":
21
+ model = YOLOXS(pretrained="coco")
22
+
23
+ # pass
24
+ else:
25
+ pass
26
+
27
+ # image pre processing yolox
28
+ preds = model(model.preprocess_input(input_img))
29
+ bboxs, lables, confidences = model.decode_predictions(preds)[0]
30
+ data.show_image_with_bboxes(input_img, bboxs, lables, confidences, num_classes=100,label_font_size=17, ax=ax)
31
+
32
+ return fig
33
+
34
+ # define params
35
+
36
+ input = [gr.inputs.Image(shape=(2000, 1500),label = "Input Image"),
37
+ gr.inputs.Dropdown(choices= choices, type="value", default='YOLOXS', label="Model")]
38
+
39
+ output = gr.outputs.Image(type="plot", label="Output Image")
40
+
41
+ title = "Demo"
42
+
43
+ example = [["image1.jpeg ","YOLOXNano"],["image2.jpeg","YOLOXS"]]
44
+
45
+ description = "Demo for YOLOX(Object Detection). Models are YOLOXNano - YOLOXX"
46
+
47
+ article = "<a href='https://github.com/Megvii-BaseDetection/YOLOX' target='_blank'><u>YOLOX </u></a>is an anchor-free version of YOLO, with a simpler design but better performance!<br><br><p style='text-align: center'>Untuk penjelasan lihat di <a href='https://github.com/sultanbst123/YOLOX-Demo' target='_blank'><u>repo ku </u>😁</a></p>"
48
+
49
+ # deploy
50
+ iface = gr.Interface(main,
51
+ inputs = input,
52
+ outputs = output,
53
+ title = title,
54
+ article = article,
55
+ description = description,
56
+ examples = example,
57
+ theme = "dark")
58
+
59
+ iface.launch(debug = True)
requirements.txt ADDED
File without changes