当前位置: 首页>>代码示例>>Python>>正文


Python BlobService.set_blob_metadata方法代码示例

本文整理汇总了Python中azure.storage.BlobService.set_blob_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python BlobService.set_blob_metadata方法的具体用法?Python BlobService.set_blob_metadata怎么用?Python BlobService.set_blob_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure.storage.BlobService的用法示例。


在下文中一共展示了BlobService.set_blob_metadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import set_blob_metadata [as 别名]
def upload():

    file = request.files['fileInput']
    print "File is" + file.filename


    if file:
        data = file.read()


        blob_service = BlobService(account_name='squadshots', account_key='UgxaWKAKv2ZvhHrPt0IHi4EQedPpZw35r+RXkAYB2eICPrG3TjSwk2G8gUzG/PNDDTV+4CVCYWCvZSiad5xMQQ==')
        blob_service.create_container('album')

        blob_service.put_block_blob_from_bytes(
            'album',
            file.filename + "_blob",
            data,
            x_ms_blob_content_type='image/png'
        )

        if 'username' in session:
            un = session['username']
        else:
            print "not in session"

        blob_service.set_blob_metadata(container_name="album",
                                   blob_name=file.filename + "_blob",
                                   x_ms_meta_name_values={'metaun': un})

        blob_service.get_blob_to_path('album',file.filename + "_blob",'static/output.png')
        f = open('input_person.png','w+')
        f.write(data)
        f.close()


        [X,y] = read_images(OUTPUT_DIRECTORY, (256,256))
    # Convert labels to 32bit integers. This is a workaround for 64bit machines,
        y = np.asarray(y, dtype=np.int32)

    # Create the Eigenfaces model.
        model = cv2.createEigenFaceRecognizer()
    # Learn the model. Remember our function returns Python lists,
    # so we use np.asarray to turn them into NumPy lists to make
    # the OpenCV wrapper happy:
        model.train(np.asarray(X), np.asarray(y))

    # Save the model for later use
        model.save("eigenModel.xml")



           # Create an Eign Face recogniser
        t = float(100000)
        model = cv2.createEigenFaceRecognizer(threshold=t)

        # Load the model
        model.load("eigenModel.xml")

       # Read the image we're looking for
        try:
            sampleImage = cv2.imread('static/output.png', cv2.IMREAD_GRAYSCALE)
            if sampleImage != None:
                sampleImage = cv2.resize(sampleImage, (256,256))
            else:
                print "sample image is  null"
        except IOError:
            print "IO error"

      # Look through the model and find the face it matches
        [p_label, p_confidence] = model.predict(sampleImage)

    # Print the confidence levels
        print "Predicted label = %d (confidence=%.2f)" % (p_label, p_confidence)

    # If the model found something, print the file path
        if (p_label > -1):
            count = 0
            for dirname, dirnames, filenames in os.walk(OUTPUT_DIRECTORY):
                for subdirname in dirnames:
                    subject_path = os.path.join(dirname, subdirname)
                    if (count == p_label):
                        for filename in os.listdir(subject_path):
                            print "subject path = " + subject_path

                    count = count+1

    return "uploaded"
开发者ID:engineershreyas,项目名称:SquadShots,代码行数:89,代码来源:app.py


注:本文中的azure.storage.BlobService.set_blob_metadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。