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


Python ClarifaiApi.tag_urls方法代码示例

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


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

示例1: ClarifaiApi

# 需要导入模块: from clarifai.client import ClarifaiApi [as 别名]
# 或者: from clarifai.client.ClarifaiApi import tag_urls [as 别名]
# Clarifai
CLARIFAI_APP_ID = YOUR_CLARIFAI_APP_ID
CLARIFAI_APP_SECRET = YOUR_CLARIFAI_APP_SECRET

clarifai_api = ClarifaiApi(app_id=CLARIFAI_APP_ID, app_secret=CLARIFAI_APP_SECRET)

#results = clarifai_api.tag_image_urls('http://d21vu35cjx7sd4.cloudfront.net/dims3/MMAH/thumbnail/645x380/quality/90/?url=http%3A%2F%2Fs3.amazonaws.com%2Fassets.prod.vetstreet.com%2F3a%2F54%2F5ae8bfcc41b381c27a792e0dd891%2FAP-KWDHXS-645sm8113.jpg')

#results = clarifai_api.tag_urls("http://d21vu35cjx7sd4.cloudfront.net/dims3/MMAH/thumbnail/645x380/quality/90/?url=http%3A%2F%2Fs3.amazonaws.com%2Fassets.prod.vetstreet.com%2F3a%2F54%2F5ae8bfcc41b381c27a792e0dd891%2FAP-KWDHXS-645sm8113.jpg")

#results = clarifai_api.tag_urls("http://www.midtownhotelnyc.com/resourcefiles/homeimages/hilton-garden-inn-new-york-manhattan-midtown-east-home1-top.jpg")

userInput = input('Please enter your image URL: ')

results = clarifai_api.tag_urls(userInput)

for result in results.get('results'):
  tag = result['result']['tag']['classes']
  break
  # debug
  #print(tag)
# debug
#print (tag)

taglist = list()

i = 0
for t in tag:
    if (i==5):
        break
开发者ID:terela,项目名称:tonifai,代码行数:32,代码来源:tonifai.py

示例2: len

# 需要导入模块: from clarifai.client import ClarifaiApi [as 别名]
# 或者: from clarifai.client.ClarifaiApi import tag_urls [as 别名]
    try:
        for gender in df['gender'].unique():
            names = df[df.gender == gender].name.unique().tolist()
            for name in names:
                urls = df[(df.gender == gender) & (df.name == name) & df.clarifai_status.isnull() & (df.image_url.str.contains('.jpg') | df.image_url.str.contains('.jpeg') | df.image_url.str.contains('.png'))][['image_order', 'image_url']].sort_values(['image_order'])['image_url'].tolist()
                count = len(df[(df.gender == gender) & (df.name == name) & (df.clarifai_status == 'OK') & (df.predicted != '-')])
                begin = 0
                print(gender, name, count, len(urls))
                while count < args.count and begin < len(urls):
                    need = args.count - count
                    if args.batch and need > args.batch:
                        need = args.batch
                    sel_urls = urls[begin:begin+need]
                    try:
                        result = clarifai_api.tag_urls(sel_urls)
                        for r in result['results']:
                            url = r['url'].encode('utf-8')
                            status = r['status_code']
                            try:
                                _id = df[(df.gender == gender) & (df.name == name) & (df.image_url == url)].index[0]
                                df.loc[_id, 'clarifai_status'] = status
                                if status == 'OK':
                                    tags = r['result']['tag']['classes']
                                    probs = r['result']['tag']['probs']
                                    msum = 0
                                    fsum = 0
                                    for t in ['man', 'men', 'boy', 'actor']:
                                        try:
                                            idx = tags.index(t)
                                            msum += probs[idx]
开发者ID:soodoku,项目名称:clarifai_gender,代码行数:32,代码来源:clarifai_tag.py


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