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


Python exifutil.open_oriented_im函数代码示例

本文整理汇总了Python中exifutil.open_oriented_im函数的典型用法代码示例。如果您正苦于以下问题:Python open_oriented_im函数的具体用法?Python open_oriented_im怎么用?Python open_oriented_im使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: image_search_upload

def image_search_upload():
    try:
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files['imagefile']
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
            werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        #image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'index_object_searching.html', has_result=True,
            result=[-1, 'Cannot open uploaded image.']
        )
    try:
        starttime = time.time()        
        image = exifutil.open_oriented_im(filename)        
        tmp_list = [filename]
        target_feature = image_feature_extract(tmp_list,1,1)
        
        
        L2_distance_feature = []
        res_images = []
        if app.is_gallery_feature_extract == True:
            logging.info('Begin to caculate L2_distance and sort.')
            for i in range(app.gallery_image_num):
                #caculate the L2 distance for f8 feature 
                tmp_distance = Euclidean_distance(app.gallery_features[i],target_feature[0])
                L2_distance_feature.append(tmp_distance)
            print "L2_distance_feature:",L2_distance_feature
            index = np.argsort(np.array(L2_distance_feature))                               
            for i in index:
                if L2_distance_feature[i] < app.threshold:
                    print 'Prepare output image, index: %d, distance:%d, name : %s \n'%(i,L2_distance_feature[i],app.gallery_image_name[i])
                    tmp_image = exifutil.open_oriented_im(app.gallery_image_name[i])
                    
                    res_images.append(embed_image_html(tmp_image))
                else:
                    break
            endtime = time.time()
            logging.info('Finish searching, output %d similar images.',len(res_images)) 
            return flask.render_template(
        'index_object_searching.html', has_result=True, result=[len(res_images),'%.3f' % (endtime - starttime)],result_images=res_images,imagesrc=embed_image_html(image) )

        else:
            endtime = time.time()
            return flask.render_template(
        'index_object_searching.html', has_result=True, result=[0,'%.3f' % (endtime - starttime)],result_images=res_images,imagesrc=embed_image_html(image) )
        
    except Exception as err:
            logging.info('Image searching error: %s', err)
            return flask.render_template(
            'index_object_searching.html', has_result=True,
            result=[-1, 'Something went wrong when searching image. '] )
开发者ID:bowang9,项目名称:project,代码行数:57,代码来源:app.py

示例2: classify_upload_json

def classify_upload_json():
    try:
        # We will save the file to disk for possible data collection.
        logging.info('In classify upload...')
        imagefile = flask.request.files['imagefile']
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
            werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'index.html', has_result=True,
            result=(False, 'Cannot open uploaded image.')
        )

    result = app.clf.classify_image(image)
    
    #done with image file; no need to keep it around

    #os.remove(os.path.join(UPLOAD_FOLDER, filename))
    #logging.info('Deleted file with name, %s', (os.path.join(UPLOAD_FOLDER, filename)))

    return jsonify(result=result)
开发者ID:aurotripathy,项目名称:Caffe-ReST-APIs,代码行数:27,代码来源:rest-server.py

示例3: classify_upload

def classify_upload():
    try:
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files['imagefile']
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
            werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'index.html', has_result=True,
            result=(False, 'Cannot open uploaded image.')
        )

    result = app.clf.classify_image(image)
    #print '----                         ..'
    #print result
    return flask.render_template(
        'index.html', has_result=True, result=result,
        imagesrc=embed_image_html(image)
    )
开发者ID:zdx3578,项目名称:caffe,代码行数:25,代码来源:app.py

示例4: enroll_upload

def enroll_upload():
  try:
    # We will save the file to disk for possible data collection.
    imagefile = flask.request.files['imagefile_enroll']
    filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
      werkzeug.secure_filename(imagefile.filename)
    filename = os.path.join(ENROLL_FOLDER, filename_)
    imagefile.save(filename)
    image = exifutil.open_oriented_im(filename)
    im = PIL.Image.fromarray(np.asarray(image * 255.).astype(np.uint8))
    im = im.resize( (384, 384), PIL.Image.ANTIALIAS )
    thumb_filename = filename #+ '_thumb.jpg'
    im.save(thumb_filename)
    #scp_command = 'scp %s [email protected]:%s' % (thumb_filename, ENROLL_FOLDER)
    #os.system(scp_command)
    logging.info('Saving to %s. done', thumb_filename)
    logging.info('%s done', scp_command)

  except Exception as err:
    logging.info('Uploaded image open error: %s', err)
    return flask.render_template(
      'index.html', has_result=True,
      result=(False, 'Cannot open uploaded image.')
    )

  result = app.clf.enroll_image(image, filename_)
  return flask.render_template('index.html', \
    has_result=True, result=result, imagesrc=embed_image_html(image))
开发者ID:taey16,项目名称:demon_11st,代码行数:28,代码来源:app.py

示例5: classify_upload

def classify_upload():
    try:
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files['imagefile']
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
            werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        path, extension = os.path.splitext(filename)
        if extension == '.png':
            im = Image.open(filename)
            filename = "%s.jpg" % path
            im.save(filename)

        logging.info('Saving to %s.', filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'index.html', has_result=True,
            result=(False, 'Cannot open uploaded image.')
        )

    names, probs, time_cost, accuracy = app.clf.classify_image(
        open(os.path.join(filename), "rb").read())
    return flask.render_template(
        'index.html', has_result=True, result=[True, zip(names, probs), '%.3f' % time_cost],
        imagesrc=embed_image_html(image)
    )
开发者ID:hetaoaoao,项目名称:tensorflow_web_deploy,代码行数:30,代码来源:PyClassification.py

示例6: classify_upload

def classify_upload():
    try:
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files['imagefile']
        # filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
        #     werkzeug.secure_filename(imagefile.filename)
        filename_ = str(uuid.uuid1()) + "_" + str(datetime.datetime.now()).replace(' ', '_') + "." + imagefile.filename.rsplit('.', 1)[1]
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        filenameMd5 = md5(filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'index.html', has_result=True, has_images=False,
            result=(False, 'Cannot open uploaded image.')
        )

    result = app.clf.classify_image(image)

    try:
        dyCom = reClassify.DynamoCommunicator()
        s3 = reClassify.S3Wrapper()
        classes = []
        for item in result[2]:
            classes.append(item[0])

        if (not dyCom.isStored(filenameMd5)):

            s3.transfer.upload_file(filename, s3.BUCKET_NAME, s3.IMAGES_FOLDER + filename_, extra_args={'ACL': 'public-read'})
            dyCom.add_md5_and_image(filenameMd5,filename_)
            dyCom.add_image_to_classes(filename_, classes)
            dyCom.add_image_and_classes(filename_,classes, filenameMd5)


        images = dyCom.get_images(classes)

        imgIDs = []
        s3URL = "https://s3.amazonaws.com"
        s3URL = os.path.join(s3URL, s3.BUCKET_NAME, s3.IMAGES_FOLDER)

        for item in images:
	    samp = min(5,len(images[item]))
            for it in random.sample(images[item],samp):
                imgIDs.append(os.path.join(s3URL, str(it)))

    except Exception as err:
        # For any exception we encounter in reading the image, we will just
        # not continue.
        logging.info('AWS Error: %s', err)
        return flask.render_template(
            'index.html', has_result=True, has_images=False,
            result=(False, "AWS Error" + err.message)
        )
    return flask.render_template(
        'index.html', has_result=True, result=result,
        imagesrc=embed_image_html(image), has_images=True, images=imgIDs
    )
开发者ID:cioionut,项目名称:imgSearchEngine,代码行数:60,代码来源:app.py

示例7: classify

def classify(net,labels,imagesFname):
    images = []
    for i in range(len(imagesFname)):
        images.append(exifutil.open_oriented_im(str(i)+'.jpg'))
    scores = net.predict(images, oversample=False)
    scoresLabels = [ labels[(-x).argsort()[:1][0] ] for x in scores ]
    output = zip( imagesFname, scoresLabels )
    return output
开发者ID:karthiknrao,项目名称:videocontext,代码行数:8,代码来源:loadclf.py

示例8: save_image

def save_image(imagefile):
    filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
        werkzeug.secure_filename(imagefile.filename)
    filename = os.path.join(UPLOAD_FOLDER, filename_)
    imagefile.save(filename)
    logging.info('Saving to %s.', filename)
    image = exifutil.open_oriented_im(filename)
    return (filename, image)
开发者ID:gyurisc,项目名称:DigitsRest,代码行数:8,代码来源:app.py

示例9: show_team

def show_team():
    photos = []
    
    filename1 = './templates/team-members-photo/wangbo.jpg'
    image1 = exifutil.open_oriented_im(filename1)
    member1=embed_image_html(image1)
    photos.append(member1)
        
    filename2 = './templates/team-members-photo/zdh.jpg'
    image2 = exifutil.open_oriented_im(filename2)
    member2=embed_image_html(image2)
    photos.append(member2)    
    
    filename3 = './templates/team-members-photo/zhuhao.jpg'
    image3 = exifutil.open_oriented_im(filename3)
    member3=embed_image_html(image3)
    photos.append(member3)
    
    return flask.render_template('index_team.html', has_result=False,imagesrc=photos)
开发者ID:bowang9,项目名称:project,代码行数:19,代码来源:app.py

示例10: classify_upload

def classify_upload():
    imagefile = request.files['imagefile']
    filename_ = werkzeug.secure_filename(imagefile.filename)
    filename = os.path.join(UPLOADS_FOLDER,filename_)
    imagefile.save(filename)
    image = exifutil.open_oriented_im(filename)
    result = classify_image(filename)
    print result
    imagesrc=embed_image_html(image)
    return render_template('index.html', has_result=True, result=result, imagesrc=imagesrc)
开发者ID:fromgop,项目名称:test,代码行数:10,代码来源:caffeDemo.py

示例11: classify_upload

def classify_upload():
    try:
        # We will save the file to disk for possible data collection.
        filename = flask.request.args["image"]
        logging.info("Saving to %s.", filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info("Uploaded image open error: %s", err)
        return flask.render_template("index.html", has_result=True, result=(False, "Cannot open uploaded image."))

    result = app.clf.classify_image(image)
    return flask.jsonify(result[2])
开发者ID:wangtt03,项目名称:vophoto_processor,代码行数:13,代码来源:app.py

示例12: myclassify_dog_upload

def myclassify_dog_upload():
    try:
        logging.info('in classify_upload')
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files['imagefile']
        logging.info('in classify_upload 1')
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + \
            werkzeug.secure_filename(imagefile.filename)
        logging.info('in classify_upload 2')
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        logging.info('in classify_upload 3')
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return flask.render_template(
            'responseDogs.html', has_result=True,
            result=(False, 'Cannot open uploaded image.')
        )

    result = app.clf.classify_image(image)
    i = 0
    while i < len(result[1]):
         single_pred = result[1][i]
         if not(p.match(single_pred[0])):
           logging.info(single_pred[0] + " i=" + str(i))
           del result[1][i]
         else:
           #image support
           searchre = re.compile('.*'+single_pred[0].lower()+'.*',re.IGNORECASE)
           defkey = "borzoi"
           for key in dogs:
             if searchre.match(key):
               defkey = key
               break
           result[1][i] = [ single_pred[0], single_pred[1], dogs[defkey][2]]
           '''
           if single_pred[0].lower() in dogs:
             result[1][i] = [ single_pred[0], single_pred[1], dogs[single_pred[0].lower()][2]]
           else: 
             result[1][i] = [ single_pred[0], single_pred[1], dogs["borzoi"][2]]
           '''
           i = i + 1
 
    return flask.render_template(
        'responseDogs.html', has_result=True, result=result,
        imagesrc=embed_image_html(image)
    )
开发者ID:lrosenba1,项目名称:WhatsMyMutt,代码行数:50,代码来源:app.py

示例13: classify_dir

def classify_dir(imagedir,test):
  global f
  if test=='test':
    f=open('/opt/data/1000caffefileout-test.txt','a')
    for root, directories, filenames in os.walk(imagedir):
      for filename in filenames:
        if 'test' in root:
          if filename not in 'Thumbs.db':
            lfname =os.path.join(root,filename)
            catlog=root.split('/')[-3]
            cimage = exifutil.open_oriented_im(lfname)
            app.clf.classify_image(cimage,catlog,lfname)
    f.close()
  else:
    f=open('/opt/data/1000caffefileout.txt','a')
    for root, directories, filenames in os.walk(imagedir):
      for filename in filenames:
        if 'test' not in root:
          if filename not in 'Thumbs.db':
            lfname =os.path.join(root,filename)
            catlog=root.split('/')[-2]
            cimage = exifutil.open_oriented_im(lfname)
            app.clf.classify_image(cimage,catlog,lfname)
    f.close()
开发者ID:zdx3578,项目名称:caffe,代码行数:24,代码来源:app.py

示例14: classify_upload

def classify_upload():
    try:
        # We will save the file to disk for possible data collection.
        imagefile = flask.request.files["imagefile"]
        filename_ = str(datetime.datetime.now()).replace(" ", "_") + werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOAD_FOLDER, filename_)
        imagefile.save(filename)
        logging.info("Saving to %s.", filename)
        image = exifutil.open_oriented_im(filename)

    except Exception as err:
        logging.info("Uploaded image open error: %s", err)
        return flask.render_template("index.html", has_result=True, result=(False, "Cannot open uploaded image."))

    result = app.clf.classify_image(image)
    return flask.render_template("classify.html", has_result=True, result=result, imagesrc=embed_image_html(image))
开发者ID:NichCritic,项目名称:AI-proj,代码行数:16,代码来源:app.py

示例15: classifyy_upload

def classifyy_upload():
    try:
        imagefile = request.files['imagefile']
        filename_ = str(datetime.datetime.now()).replace(' ', '_') + werkzeug.secure_filename(imagefile.filename)
        filename = os.path.join(UPLOADS_FOLDER, filename_)
        imagefile.save(filename)
        logging.info('Saving to %s.', filename)
        image = exifutil.open_oriented_im(filename)
        
    except Exception as err:
        logging.info('Uploaded image open error: %s', err)
        return render_template('index.html', has_result=True,result=(False, 'Cannot open uploaded image.'))
    
    logging.info('Image: %s', image_url)
    result = app.clf.classify_image(image)
    
    
开发者ID:fromgop,项目名称:test,代码行数:15,代码来源:app.py


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