Sultannn commited on
Commit
5613916
1 Parent(s): ddcbd21

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -0
app.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import numpy as np
3
+ from keras_cv_attention_models.yolox import * # import all yolox model
4
+ from keras_cv_attention_models.coco import data
5
+ import matplotlib.pyplot as plt
6
+ import gradio as gr
7
+
8
+ # semua yolox model
9
+ choices = ["YOLOXNano", "YOLOXTiny", "YOLOXS", "YOLOXM", "YOLOXL", "YOLOXX"]
10
+
11
+ def main(input_img, models):
12
+
13
+ #
14
+ fig, ax = plt.subplots() # pakai ini,jika tidak akan muncul error
15
+
16
+ # YOLOXNano models
17
+ if models == "YOLOXNano":
18
+ model = YOLOXNano(pretrained="coco")
19
+
20
+ # YOLOXTiny models
21
+ elif models == "YOLOXTiny":
22
+ model = YOLOXTiny(pretrained="coco")
23
+
24
+ # YOLOXS models
25
+ elif models == "YOLOXS":
26
+ model = YOLOXS(pretrained="coco")
27
+
28
+ # YOLOXM models
29
+ elif models == "YOLOXM":
30
+ model = YOLOXM(pretrained="coco")
31
+
32
+ # YOLOXL models
33
+ elif models == "YOLOXL":
34
+ model = YOLOXL(pretrained="coco")
35
+
36
+ # YOLOXX models
37
+ elif models == "YOLOXX":
38
+ model = YOLOXX(pretrained="coco")
39
+
40
+ # pass
41
+ else:
42
+ pass
43
+
44
+ # image pre processing yolox
45
+ preds = model(model.preprocess_input(input_img))
46
+ bboxs, lables, confidences = model.decode_predictions(preds)[0]
47
+ data.show_image_with_bboxes(input_img, bboxs, lables, confidences, num_classes=100,label_font_size=17, ax=ax)
48
+
49
+ return fig
50
+
51
+ # define params
52
+
53
+ input = [gr.inputs.Image(shape=(512, 512),label = "Input Image"),
54
+ gr.inputs.Dropdown(choices= choices, type="value", default='YOLOXS', label="Model")]
55
+
56
+ output = gr.outputs.Image(type="plot", label="Output Image")
57
+
58
+ title = "YOLOX Demo(FT)"
59
+
60
+ example = [[" "]]
61
+
62
+ description = "Demo for YOLOX(Object Detection). Models are YOLOXNano - YOLOXX"
63
+
64
+ article = "<p style='text-align: center'>Untuk penjelasan lihat di <a href='https://github.com/sultanbst123/Text_summarization-id2id' target='_blank'><u>repo ku </u>😁</a></p>"
65
+
66
+ # deploy
67
+ iface = gr.Interface(main,
68
+ inputs = input,
69
+ outputs = output,
70
+ title = title,
71
+ article = article,
72
+ description = description,
73
+ theme = "dark")
74
+
75
+ iface.launch(debug = True)