@@ -26,6 +26,7 @@ @interface WelcomeVC ()
2626@property (strong , nonatomic ) IBOutlet UIButton *btnYOLOFastestXL;
2727
2828@property (strong , nonatomic ) IBOutlet UIImageView *btnUseGPU;
29+ @property (assign , nonatomic ) Boolean useGPU;
2930
3031@end
3132
@@ -38,7 +39,32 @@ - (void)viewDidLoad {
3839 self.title = @" TENG" ;
3940}
4041
42+ - (void )changeMode {
43+ self.useGPU = NO ;
44+ self.btnUseGPU .userInteractionEnabled = YES ;
45+ UITapGestureRecognizer *modeTap = [[UITapGestureRecognizer alloc ] initWithTarget: self action: @selector (changeNcnnMode )];
46+ [self .btnUseGPU addGestureRecognizer: modeTap];
47+ }
48+
49+ - (void )changeNcnnMode {
50+ self.useGPU = self.useGPU ? NO : YES ;
51+ NSString *title = @" Warning" ;
52+ NSString *message = @" ohhhhh" ;
53+ if (self.useGPU ) {
54+ title = @" Warning" ;
55+ message = @" If the GPU is too old, it may not work well in GPU mode." ;
56+ } else {
57+ title = @" Warning" ;
58+ message = @" Run on CPU." ;
59+ }
60+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: title message: message preferredStyle: UIAlertControllerStyleAlert];
61+ UIAlertAction *sure = [UIAlertAction actionWithTitle: @" OK" style: UIAlertActionStyleDefault handler: nil ];
62+ [alert addAction: sure];
63+ [self presentViewController: alert animated: YES completion: nil ];
64+ }
65+
4166- (void )initView {
67+ [self changeMode ];
4268 [_btnYolov5s addTarget: self action: @selector (pressYolov5s: ) forControlEvents: UIControlEventTouchUpInside];
4369 [_btnYolov4tiny addTarget: self action: @selector (pressYolov4tiny: ) forControlEvents: UIControlEventTouchUpInside];
4470 [_btnMBV2Yolov3nano addTarget: self action: @selector (pressMBNv2Yolov3Nano: ) forControlEvents: UIControlEventTouchUpInside];
@@ -56,72 +82,84 @@ - (void)initView {
5682- (void )pressYolov5s : (UIButton *)btn {
5783 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
5884 vc.USE_MODEL = W_YOLOV5S;
85+ vc.USE_GPU = self.useGPU ;
5986 [self .navigationController pushViewController: vc animated: NO ];
6087}
6188
6289- (void )pressYolov4tiny : (UIButton *)btn {
6390 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
6491 vc.USE_MODEL = W_YOLOV4TINY;
92+ vc.USE_GPU = self.useGPU ;
6593 [self .navigationController pushViewController: vc animated: NO ];
6694}
6795
6896- (void )pressMBNv2Yolov3Nano : (UIButton *)btn {
6997 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
7098 vc.USE_MODEL = W_MOBILENETV2_YOLOV3_NANO;
99+ vc.USE_GPU = self.useGPU ;
71100 [self .navigationController pushViewController: vc animated: NO ];
72101}
73102
74103- (void )pressSimplePose : (UIButton *)btn {
75104 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
76105 vc.USE_MODEL = W_SIMPLE_POSE;
106+ vc.USE_GPU = self.useGPU ;
77107 [self .navigationController pushViewController: vc animated: NO ];
78108}
79109
80110- (void )pressYolact : (UIButton *)btn {
81111 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
82112 vc.USE_MODEL = W_YOLACT;
113+ vc.USE_GPU = self.useGPU ;
83114 [self .navigationController pushViewController: vc animated: NO ];
84115}
85116
86117- (void )pressFaceLandmark : (UIButton *)btn {
87118 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
88119 vc.USE_MODEL = W_FACE_LANDMARK;
120+ vc.USE_GPU = self.useGPU ;
89121 [self .navigationController pushViewController: vc animated: NO ];
90122}
91123
92124- (void )pressDBFace : (UIButton *)btn {
93125 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
94126 vc.USE_MODEL = W_DBFACE;
127+ vc.USE_GPU = self.useGPU ;
95128 [self .navigationController pushViewController: vc animated: NO ];
96129}
97130
98131- (void )pressMBNv2FCN : (UIButton *)btn {
99132 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
100133 vc.USE_MODEL = W_MOBILENETV2_FCN;
134+ vc.USE_GPU = self.useGPU ;
101135 [self .navigationController pushViewController: vc animated: NO ];
102136}
103137
104138- (void )pressMBNv3SEG : (UIButton *)btn {
105139 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
106140 vc.USE_MODEL = W_MOBILENETV3_SEG;
141+ vc.USE_GPU = self.useGPU ;
107142 [self .navigationController pushViewController: vc animated: NO ];
108143}
109144
110145- (void )pressYOLOv5CustomOP : (UIButton *)btn {
111146 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
112147 vc.USE_MODEL = W_YOLOV5S_CUSTOM_OP;
148+ vc.USE_GPU = self.useGPU ;
113149 [self .navigationController pushViewController: vc animated: NO ];
114150}
115151
116152- (void )pressNanoDet : (UIButton *)btn {
117153 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
118154 vc.USE_MODEL = W_NANODET;
155+ vc.USE_GPU = self.useGPU ;
119156 [self .navigationController pushViewController: vc animated: NO ];
120157}
121158
122159- (void )pressYOLOFastestXL : (UIButton *)btn {
123160 ViewController *vc = [self .storyboard instantiateViewControllerWithIdentifier: @" ViewController" ];
124161 vc.USE_MODEL = W_YOLO_FASTEST_XL;
162+ vc.USE_GPU = self.useGPU ;
125163 [self .navigationController pushViewController: vc animated: NO ];
126164}
127165
0 commit comments