예제 #1
0
def classify_with_archive(archive, image_files, use_gpu=True):
    """
    """
    tmpdir = unzip_archive(archive)
    caffemodel = None
    deploy_file = None
    mean_file = None
    labels_file = None
    for filename in os.listdir(tmpdir):
        full_path = os.path.join(tmpdir, filename)
        if filename.endswith('.caffemodel'):
            caffemodel = full_path
        elif filename == 'deploy.prototxt':
            deploy_file = full_path
        elif filename.endswith('.binaryproto'):
            mean_file = full_path
        elif filename == 'labels.txt':
            labels_file = full_path
        else:
            print 'Unknown file:', filename

    assert caffemodel is not None, 'Caffe model file not found'
    assert deploy_file is not None, 'Deploy file not found'

    classify(caffemodel, deploy_file, image_files,
            mean_file=mean_file, labels_file=labels_file, use_gpu=use_gpu)
예제 #2
0
def classify_with_archive(archive, image_files, batch_size=None, use_gpu=True):
    """
    """
    tmpdir = unzip_archive(archive)
    caffemodel = None
    deploy_file = None
    mean_file = None
    labels_file = None
    for filename in os.listdir(tmpdir):
        full_path = os.path.join(tmpdir, filename)
        if filename.endswith('.caffemodel'):
            caffemodel = full_path
        elif filename == 'deploy.prototxt':
            deploy_file = full_path
        elif filename.endswith('.binaryproto'):
            mean_file = full_path
        elif filename == 'labels.txt':
            labels_file = full_path
        else:
            print('Unknown file:', filename)

    assert caffemodel is not None, 'Caffe model file not found'
    assert deploy_file is not None, 'Deploy file not found'

    classify(caffemodel,
             deploy_file,
             image_files,
             mean_file=mean_file,
             labels_file=labels_file,
             batch_size=batch_size,
             use_gpu=use_gpu)
예제 #3
0
def classify_image(image_files, use_gpu=True):
    caffemodel = '../caffe/20151207-223900-80d9_epoch_30.0/snapshot_iter_19140.caffemodel'
    deploy_file = '../caffe/20151207-223900-80d9_epoch_30.0/deploy.prototxt'
    mean_file = '../caffe/20151207-223900-80d9_epoch_30.0/mean.binaryproto'
    labels_file = '../caffe/20151207-223900-80d9_epoch_30.0/labels.txt'

    classify(caffemodel, deploy_file, image_files,
            mean_file=mean_file, labels_file=labels_file, use_gpu=use_gpu)
예제 #4
0
def classify_with_archive(archive, image_files, batch_size=None, use_gpu=True):
    """
    """
    tmpdir = unzip_archive(archive)
    caffemodel = None
    deploy_file = None
    mean_file = None
    labels_file = None
    for filename in os.listdir(tmpdir):
        full_path = os.path.join(tmpdir, filename)
        if filename.endswith('.caffemodel'):
            caffemodel = full_path
        elif filename == 'deploy.prototxt':
            deploy_file = full_path
        elif filename.endswith('.binaryproto'):
            mean_file = full_path
        elif filename == 'labels.txt':
            labels_file = full_path
        else:
            print 'Unknown file:', filename

    assert caffemodel is not None, 'Caffe model file not found'
    assert deploy_file is not None, 'Deploy file not found'

    class_labels = classify(caffemodel,
                            deploy_file,
                            image_files,
                            mean_file=mean_file,
                            labels_file=labels_file,
                            batch_size=batch_size,
                            use_gpu=use_gpu)

    with open('result.csv', 'wb') as myfile:
        wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
        wr.writerow(class_labels)
예제 #5
0
def main():
   drone = ps_drone.Drone()
   drone.reset()
   i=0
   
   


   while (True):
       cap = misc.face()
       
           
       number=validation.classify("test/snapshot_iter_21120.caffemodel", "test/deploy.prototxt", cap, 
        "test/mean.binaryproto", "test/labels.txt")
        
       print number 
            
       time.sleep(0.5)  

       i=i+1
    
       if i>10:
           exit()
예제 #6
0
def classify_archive():
    archive = '/home/user/Desktop/Run_DIGITS_Locally/INSIDEv4.tar.gz'
    image_file = ['/home/user/Desktop/Run_DIGITS_Locally/tst.png']
    batch_size = None
    use_gpu = True
    tmpdir = unzip_archive(archive)

    caffemodel = None
    deploy_file = None
    mean_file = None
    labels_file = None
    for filename in os.listdir(tmpdir):
        full_path = os.path.join(tmpdir, filename)
        if filename.endswith('.caffemodel'):
            caffemodel = full_path
        elif filename == 'deploy.prototxt':
            deploy_file = full_path
        elif filename.endswith('.binaryproto'):
            mean_file = full_path
        elif filename == 'labels.txt':
            labels_file = full_path
        else:
            print 'Unknown file:', filename

    assert caffemodel is not None, 'Caffe model file not found'
    assert deploy_file is not None, 'Deploy file not found'
    #print("NOt working: print Image file before call classify.\n")
    #print(image_file)
    resultLabel = classify(caffemodel,
                           deploy_file,
                           image_file,
                           mean_file=mean_file,
                           labels_file=labels_file,
                           batch_size=batch_size,
                           use_gpu=use_gpu)
    return resultLabel
예제 #7
0
#Starts the Video Stream
#drone.startVideo()
#drone.showVideo()
#time.sleep(5)

Running = True
while Running:
    start = timeit.timeit()

    #Get Pictures to put in the Model
    cap= drone.VideoImage
    print type(cap)
    New=numpy.array(cap)
    cap = cv2.cvtColor(New, cv2.COLOR_BGR2RGB)
    
    number=validation.classify("test/snapshot_iter_21120.caffemodel", "test/deploy.prototxt", cap, 
        "test/mean.binaryproto", "test/labels.txt")

    #cv2.imshow("Frame", cap)
    #cv2.imwrite("frontd.png", cap)

    #Call The Classification Funktion here !
    DirectionClass=number
    
    print number


    #Controll via Classified Data
    #Sleep defines the inertia time
    STime = 0.5
"""
    if DirectionClass == 0: