# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import print_topk if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("shufflenetv2", num_threads=4, use_gpu=True) cls_scores = net(m) print_topk(cls_scores, 3)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('mobilenetv3_ssdlite', num_threads=4, use_gpu=use_gpu) objects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects(m, net.class_names, objects, 0.6)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("mobilenet_yolov2", num_threads=4, use_gpu=True) objects = net(m) draw_detection_objects(m, net.class_names, objects)
import time import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model( "nanodet", target_size=320, prob_threshold=0.4, nms_threshold=0.5, num_threads=4, use_gpu=True, ) objects = net(m) draw_detection_objects(m, net.class_names, objects)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_pose use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('simplepose', num_threads=4, use_gpu=use_gpu) keypoints = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_pose(m, keypoints)
color_index += 1 cv2.imshow("image", image) cv2.waitKey(0) if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model( "yolact", target_size=550, confidence_threshold=0.05, nms_threshold=0.5, keep_top_k=200, num_threads=4, use_gpu=True, ) boxes, masks, classes, scores = net(m) draw_result(m, net.class_names, boxes, masks, classes, scores)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import print_topk if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("squeezenet", num_threads=4, use_gpu=True) cls_scores = net(m) print_topk(cls_scores, 5)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('rfcn', num_threads=4, use_gpu=use_gpu) objects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects(m, net.class_names, objects)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import print_topk use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('shufflenetv2', num_threads=4, use_gpu=use_gpu) cls_scores = net(m) if use_gpu: ncnn.destroy_gpu_instance() print_topk(cls_scores, 3)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import print_topk use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('squeezenet', num_threads=4, use_gpu=use_gpu) cls_scores = net(m) if use_gpu: ncnn.destroy_gpu_instance() print_topk(cls_scores, 5)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_pose if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("simplepose", num_threads=4, use_gpu=True) keypoints = net(m) draw_pose(m, keypoints)
img_index1 += 3 img_index2 += 1 image[i] = ptr1.reshape(image[i].shape) cv2.imshow("image", image) cv2.waitKey(0) if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n"%(sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n"%(imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('peleenet_ssd', num_threads=4, use_gpu=use_gpu) objects, seg_out = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects_seg(m, net.class_names, objects, seg_out)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n"%(sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n"%(imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('faster_rcnn', num_threads=4, use_gpu=use_gpu) objects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects(m, net.class_names, objects)
ptr1[img_index1] = b / 2 + ptr1[img_index1] / 2 ptr1[img_index1 + 1] = g / 2 + ptr1[img_index1 + 1] / 2 ptr1[img_index1 + 2] = r / 2 + ptr1[img_index1 + 2] / 2 img_index1 += 3 img_index2 += 1 image[i] = ptr1.reshape(image[i].shape) cv2.imshow("image", image) cv2.waitKey(0) if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("peleenet_ssd", num_threads=4, use_gpu=True) objects, seg_out = net(m) draw_detection_objects_seg(m, net.class_names, objects, seg_out)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('mobilenet_yolov2', num_threads=4, use_gpu=use_gpu) objects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects(m, net.class_names, objects)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("rfcn", num_threads=4, use_gpu=True) objects = net(m) draw_detection_objects(m, net.class_names, objects)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("mobilenetv2_ssdlite", num_threads=4, use_gpu=True) objects = net(m) draw_detection_objects(m, net.class_names, objects)
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_faceobjects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model("retinaface", num_threads=4, use_gpu=True) faceobjects = net(m) draw_faceobjects(m, faceobjects)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('mobilenet_ssd', num_threads=4, use_gpu=use_gpu) objects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_detection_objects(m, net.class_names, objects)
import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_faceobjects use_gpu = False if ncnn.build_with_gpu(): use_gpu = True if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) if use_gpu: ncnn.create_gpu_instance() net = get_model('retinaface', num_threads=4, use_gpu=use_gpu) faceobjects = net(m) if use_gpu: ncnn.destroy_gpu_instance() draw_faceobjects(m, faceobjects)
import sys import cv2 import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [v4l input device or image]\n" % (sys.argv[0])) sys.exit(0) devicepath = sys.argv[1] net = get_model("yolov4_tiny", num_threads=4, use_gpu=True) # net = get_model("yolov4", num_threads=4, use_gpu=True) if devicepath.find("/dev/video") == -1: m = cv2.imread(devicepath) if m is None: print("cv2.imread %s failed\n" % (devicepath)) sys.exit(0) objects = net(m) draw_detection_objects(m, net.class_names, objects) else: cap = cv2.VideoCapture(devicepath) if cap.isOpened() == False:
import time import numpy as np import ncnn from ncnn.model_zoo import get_model from ncnn.utils import draw_detection_objects if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: %s [imagepath]\n" % (sys.argv[0])) sys.exit(0) imagepath = sys.argv[1] m = cv2.imread(imagepath) if m is None: print("cv2.imread %s failed\n" % (imagepath)) sys.exit(0) net = get_model( "yolov5s", target_size=640, prob_threshold=0.25, nms_threshold=0.45, num_threads=4, use_gpu=True, ) objects = net(m) draw_detection_objects(m, net.class_names, objects)