• 大小: 7.67MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-11
  • 语言: 其他
  • 标签: 目标检测  

资源简介

.YOLOV3darknet.-master...YOLOV3,目标检测算法,目前速度比较快的算法

资源截图

代码片段和文件信息

#!python3
“““
Python 3 wrapper for identifying objects in images

Requires DLL compilation

Both the GPU and no-GPU version should be compiled; the no-GPU version should be renamed “yolo_cpp_dll_nogpu.dll“.

On a GPU system you can force CPU evaluation by any of:

- Set global variable DARKNET_FORCE_CPU to True
- Set environment variable CUDA_VISIBLE_DEVICES to -1
- Set environment variable “FORCE_CPU“ to “true“


To use either run performDetect() after import or modify the end of this file.

See the docstring of performDetect() for parameters.

Directly viewing or returning bounding-boxed images requires scikit-image to be installed (‘pip install scikit-image‘)


Original *nix 2.7: https://github.com/pjreddie/darknet/blob/0f110834f4e18b30d5f101bf8f1724c34b7b83db/python/darknet.py
Windows Python 2.7 version: https://github.com/AlexeyAB/darknet/blob/fc496d52bf22a0bb257300d3c79be9cd80e722cb/build/darknet/x64/darknet.py

@author: Philip Kahn
@date: 20180503
“““
#pylint: disable=R W0401 W0614 W0703
from ctypes import *
import math
import random
import os

def sample(probs):
    s = sum(probs)
    probs = [a/s for a in probs]
    r = random.uniform(0 1)
    for i in range(len(probs)):
        r = r - probs[i]
        if r <= 0:
            return i
    return len(probs)-1

def c_array(ctype values):
    arr = (ctype*len(values))()
    arr[:] = values
    return arr

class BOX(Structure):
    _fields_ = [(“x“ c_float)
                (“y“ c_float)
                (“w“ c_float)
                (“h“ c_float)]

class DETECTION(Structure):
    _fields_ = [(“bbox“ BOX)
                (“classes“ c_int)
                (“prob“ POINTER(c_float))
                (“mask“ POINTER(c_float))
                (“objectness“ c_float)
                (“sort_class“ c_int)]


class IMAGE(Structure):
    _fields_ = [(“w“ c_int)
                (“h“ c_int)
                (“c“ c_int)
                (“data“ POINTER(c_float))]

class metaDATA(Structure):
    _fields_ = [(“classes“ c_int)
                (“names“ POINTER(c_char_p))]



#lib = CDLL(“/home/pjreddie/documents/darknet/libdarknet.so“ RTLD_GLOBAL)
#lib = CDLL(“darknet.so“ RTLD_GLOBAL)
hasGPU = True
if os.name == “nt“:
    cwd = os.path.dirname(__file__)
    os.environ[‘PATH‘] = cwd + ‘;‘ + os.environ[‘PATH‘]
    winGPUdll = os.path.join(cwd “yolo_cpp_dll.dll“)
    winNoGPUdll = os.path.join(cwd “yolo_cpp_dll_nogpu.dll“)
    envKeys = list()
    for k v in os.environ.items():
        envKeys.append(k)
    try:
        try:
            tmp = os.environ[“FORCE_CPU“].lower()
            if tmp in [“1“ “true“ “yes“ “on“]:
                raise ValueError(“ForceCPU“)
            else:
                print(“Flag value ‘“+tmp+“‘ not forcing CPU mode“)
        except KeyError:
            # We never set the flag
            if ‘CUDA_VISIBLE_DEVICES‘ in envKeys:
                if int(os.environ[‘CUDA_VISIBLE_DEVICES‘]) < 0:
                    raise ValueError(“ForceCPU“)
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-13 21:20  darknet-master\
     目录           0  2018-10-13 21:20  darknet-master\.circleci\
     文件         500  2018-10-13 21:20  darknet-master\.circleci\config.yml
     文件         271  2018-10-13 21:20  darknet-master\.gitignore
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\dll\
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\dll\x64\
     文件      185976  2018-10-13 21:20  darknet-master\3rdparty\dll\x64\pthreadGC2.dll
     文件       82944  2018-10-13 21:20  darknet-master\3rdparty\dll\x64\pthreadVC2.dll
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\
     文件      119888  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\pthreadGC2.dll
     文件      121953  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\pthreadGCE2.dll
     文件       55808  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\pthreadVC2.dll
     文件       61952  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\pthreadVCE2.dll
     文件       57344  2018-10-13 21:20  darknet-master\3rdparty\dll\x86\pthreadVSE2.dll
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\include\
     文件       42499  2018-10-13 21:20  darknet-master\3rdparty\include\pthread.h
     文件        4995  2018-10-13 21:20  darknet-master\3rdparty\include\sched.h
     文件        4563  2018-10-13 21:20  darknet-master\3rdparty\include\semaphore.h
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\lib\
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\lib\x64\
     文件       93692  2018-10-13 21:20  darknet-master\3rdparty\lib\x64\libpthreadGC2.a
     文件       29738  2018-10-13 21:20  darknet-master\3rdparty\lib\x64\pthreadVC2.lib
     目录           0  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\
     文件       93480  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\libpthreadGC2.a
     文件       93486  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\libpthreadGCE2.a
     文件       30334  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\pthreadVC2.lib
     文件       30460  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\pthreadVCE2.lib
     文件       30460  2018-10-13 21:20  darknet-master\3rdparty\lib\x86\pthreadVSE2.lib
     文件         515  2018-10-13 21:20  darknet-master\LICENSE
     文件        4543  2018-10-13 21:20  darknet-master\Makefile
............此处省略1909个文件信息

评论

共有 条评论