# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.distortion_correct import distortion_correct_aksk
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access moderation distortion correct post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'
    init_global_env(region='cn-north-1')

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/vat-invoice.jpg'

    #call interface use the url correction is true means do not correction
    result = distortion_correct_aksk(app_key, app_secret, "", demo_data_url, True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'], 'data/modeation-distortion-aksk-1.png')
    else:
        print result

    # call interface use the file
    result = distortion_correct_aksk(app_key, app_secret, encode_to_base64('data/modeation-distortion.jpg'), '', True)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'], 'data/modeation-distortion-aksk-2.png')
    else:
        print result
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.recapture_detect import recapture_detect_aksk

if __name__ == '__main__':
    #
    # access image recapture detect ,post data by aksk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.myhuaweicloud.com/recapture-detect.jpg'

    # call interface use the file
    result = recapture_detect_aksk(
        app_key, app_secret,
        encode_to_base64('data/recapture-detect-demo.jpg'), "", 0.75,
        ["recapture"])
    print(result)

    # call interface use the url (token, image, url, threshold=0.95, scene=None)
    result = recapture_detect_aksk(app_key, app_secret, "", demo_data_url,
                                   0.75, ["recapture"])
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.clarity_detect import clarity_detect_aksk

if __name__ == '__main__':
    #
    # access moderation detect,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/vat-invoice.jpg'

    # call interface use the url
    result = clarity_detect_aksk(app_key, app_secret, "", demo_data_url, 0.8)
    print result

    # call interface use the file
    result = clarity_detect_aksk(
        app_key, app_secret,
        encode_to_base64('data/moderation-clarity-detect.jpg'), '', 0.8)
    print result
示例#4
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.super_resolution import super_resolution
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access image super resolution enhance,post data by token
    #
    user_name = '*****'
    password = '******'
    account_name = '*****'  # the same as user_name in commonly use
    init_global_env(region='cn-north-1')

    token = get_token(user_name, password, account_name)

    # call interface use base64 file
    result = super_resolution(
        token, encode_to_base64('data/super-resolution-demo.png'), 3)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'],
                        'data/super-resolution-demo-token.png')
示例#5
0
from ais_sdk.utils import encode_to_base64
from ais_sdk.moderation_image import moderation_image
from ais_sdk.moderation_image import moderation_image_aksk
if __name__ == '__main__':
    #
    # access moderation image,post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/terrorism.jpg'
    token = get_token(user_name, password, account_name)

    # call interface use the local file
    result = moderation_image(token, encode_to_base64('data/moderation-terrorism.jpg'), "", ['politics','terrorism'], "")
    print result

    # call interface use the url (token, image, url, threshold=0.95, scene=None)
    result = moderation_image(token, "", demo_data_url, ['politics','terrorism'], "")
    print result

    #
    # access moderation image,post data by ak,sk
    #
    app_key = "*************"
    app_secret = "************"

    # call interface use the local file
    result = moderation_image_aksk(app_key, app_secret, encode_to_base64('data/moderation-terrorism.jpg'), "", ['politics','terrorism'], "")
    print result
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.celebrity_recognition import celebrity_recognition_aksk
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    #
    # access image tagging , post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'
    init_global_env(region='cn-north-1')

    # The OBS link needs to be consistent with the region, and the OBS resources of different regions are not shared
    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/celebrity-recognition.jpg'

    # call interface use the url
    result = celebrity_recognition_aksk(app_key, app_secret, "", demo_data_url,
                                        0.48)
    print(result)

    # call interface use the file
    result = celebrity_recognition_aksk(
        app_key, app_secret,
        encode_to_base64('data/celebrity-recognition.jpg'), '', 0.48)
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.recapture_detect import recapture_detect_aksk

if __name__ == '__main__':
    #
    # access image recapture detect ,post data by aksk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/recapture-detect.jpg'

    # call interface use the file
    result = recapture_detect_aksk(app_key, app_secret, encode_to_base64('data/recapture-detect-demo.jpg'), "", 0.75, ["recapture"])
    print(result)

    # call interface use the url (token, image, url, threshold=0.95, scene=None)
    result = recapture_detect_aksk(app_key, app_secret, "", demo_data_url, 0.75, ["recapture"])
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.clarity_detect import clarity_detect_aksk

if __name__ == '__main__':
    #
    # access moderation detect,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/vat-invoice.jpg'

    # call interface use the url
    result = clarity_detect_aksk(app_key, app_secret, "", demo_data_url, 0.8)
    print(result)

    # call interface use the file
    result = clarity_detect_aksk(app_key, app_secret, encode_to_base64('data/moderation-clarity-detect.jpg'), '', 0.8)
    print (result)
示例#9
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.moderation_image import moderation_image

if __name__ == '__main__':
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/tagging-normal.jpg'
    token = get_token(user_name, password, account_name)

    # call interface use the local file
    result = moderation_image(token,
                              encode_to_base64('data/moderation-demo-1.jpg'),
                              "", ['politics', 'terrorism'], "")
    print result

    # call interface use the url (token, image, url, threshold=0.95, scene=None)
    result = moderation_image(token, "", demo_data_url,
                              ['politics', 'terrorism'], "")
    print result
示例#10
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.image_defog import image_defog
import json

if __name__ == '__main__':
    #
    # access image defog,post data by token
    #
    user_name = '*****'
    password = '******'
    account_name = '*****'  # the same as user_name in commonly use

    token = get_token(user_name, password, account_name)

    # call interface use base64 file
    result = image_defog(token, encode_to_base64('data/defog-demo.png'), '1.5')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/defog-demo-token.png')


示例#11
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.long_sentence import long_sentence_aksk

if __name__ == '__main__':
    #
    # access asr, long_sentence,post data by token
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.myhuaweicloud.com/lsr-1.mp3'
    # call interface use the file
    result = long_sentence_aksk(app_key, app_secret, '', demo_data_url)
    print result

    # call interface use the file
    result = long_sentence_aksk(app_key, app_secret, encode_to_base64('data/asr-sentence.wav'))
    print result
示例#12
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.moderation_clarity_detect import moderation_clarity_detect

if __name__ == '__main__':
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/tagging-normal.jpg'
    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = moderation_clarity_detect(token, "", demo_data_url, 0.8)
    print result

    # call interface use the file
    result = moderation_clarity_detect(
        token, encode_to_base64('data/image-tagging-demo-1.jpg'), '', 0.8)
    print result
示例#13
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.image_defog import image_defog_aksk
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access image defog,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'
    init_global_env(region='cn-north-1')

    # call interface use base64 file
    result = image_defog_aksk(app_key, app_secret, encode_to_base64('data/defog-demo.png'), '1.5')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/defog-demo-aksk.png')

示例#14
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.asr_sentence import asr_sentence_aksk

if __name__ == '__main__':
    #
    # access asr, asr_sentence,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/asr-sentence.wav'

    # call interface use the url
    result = asr_sentence_aksk(app_key, app_secret, '', demo_data_url, 'wav',
                               '16k')
    print(result)

    # call interface use the file
    result = asr_sentence_aksk(app_key, app_secret,
                               encode_to_base64('data/asr-sentence.wav'), '',
                               'wav', '16k')
    print(result)
示例#15
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.image_defog import image_defog_aksk
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access image defog,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'
    init_global_env(region='cn-north-1')

    # call interface use base64 file
    result = image_defog_aksk(app_key, app_secret,
                              encode_to_base64('data/defog-demo.png'), '1.5')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/defog-demo-aksk.png')
示例#16
0
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/vat-invoice.jpg'
    token = get_token(user_name, password, account_name)

    #call interface use the url correction is true means do not correction
    result = distortion_correct(token, "", demo_data_url, True)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result']['data'],
                        'data/modeation_distortion-token-1.png')
    print(result)

    # call interface use the file
    result = distortion_correct(
        token, encode_to_base64('data/modeation_distortion.jpg'), '', True)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result']['data'],
                        'data/modeation_distortion-token-2.png')
    print(result)

    #
    # access moderation distortion correct.post data by ak,sk
    #
    app_key = "*************"
    app_secret = "************"

    #call interface use the url correction is true means do not correction
    result = distortion_correct_aksk(app_key, app_secret, "", demo_data_url,
                                     True)
    result_obj = json.loads(result)
示例#17
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.long_sentence import long_sentence

if __name__ == '__main__':
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/lsr-1.mp3'
    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = long_sentence(token, '', demo_data_url)
    print result

    # call interface use the file
    result = long_sentence(token, encode_to_base64('data/asr-sentence.wav'))
    print result
示例#18
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.image_tagging import image_tagging

if __name__ == '__main__':
    #
    # access image tagging , post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.myhwclouds.com/tagging-normal.jpg'

    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = image_tagging(token, "", demo_data_url, 'zh', 5, 30)
    print(result)

    # call interface use the file
    result = image_tagging(token,
                           encode_to_base64('data/image-tagging-demo.jpg'), '',
                           'zh', 5, 60)
    print(result)
示例#19
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.dark_enhance import dark_enhance_aksk
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    # Services currently support North China-Beijing 1 (cn-north-1), Asia Pacific-Hong Kong (ap-southeast-1)
    init_global_env('cn-north-1')

    #
    # access image dark enhance by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    # call interface use base64 file
    result = dark_enhance_aksk(app_key, app_secret,
                               encode_to_base64('data/dark-enhance-demo.bmp'),
                               '0.95')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'],
                        'data/dark-enhance-demo-aksk.bmp')
示例#20
0
if __name__ == '__main__':
    # Services currently support North China-Beijing 1 (cn-north-1), Asia Pacific-Hong Kong (ap-southeast-1)
    init_global_env('cn-north-1')

    #
    # access moderation distortion correct post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/vat-invoice.jpg'

    #call interface use the url correction is true means do not correction
    result = distortion_correct_aksk(app_key, app_secret, "", demo_data_url,
                                     True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'],
                            'data/modeation-distortion-aksk-1.png')
    else:
        print(result)

    # call interface use the file
    result = distortion_correct_aksk(
        app_key, app_secret, encode_to_base64('data/modeation-distortion.jpg'),
        '', True)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'],
                            'data/modeation-distortion-aksk-2.png')
    else:
        print(result)
示例#21
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64, download_url_base64
from ais_sdk.image_antiporn import image_antiporn_aksk

if __name__ == '__main__':
    #
    # access moderation, image anti-p**n,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/antiporn.jpg'

    # call interface use the url download
    image_antiporn_aksk(
        app_key, app_secret,
        download_url_base64(
            'http://moderation-demo.ei.huaweicloud.com/theme/images/imagga/image_tagging_04.jpg'
        ))

    # call interface use the url
    image_antiporn_aksk(app_key, app_secret, '', demo_data_url)

    # call interface use the file
    image_antiporn_aksk(app_key, app_secret,
                        encode_to_base64('data/moderation-antiporn.jpg'))
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.celebrity_recognition import celebrity_recognition
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    # Services currently support North China-Beijing 1 (cn-north-1), Asia Pacific-Hong Kong (ap-southeast-1)
    init_global_env('cn-north-1')

    #
    # access image tagging , post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    # The OBS link should match the region, and the OBS resources of different regions are not shared
    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/celebrity-recognition.jpg'
    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = celebrity_recognition(token, "", demo_data_url, 0.48)
    print(result)

    # call interface use the file
    result = celebrity_recognition(token, encode_to_base64('data/celebrity-recognition.jpg'), '', 0.48)
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.image_tagging import image_tagging_aksk

if __name__ == '__main__':
    #
    # access image tagging , post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'

    demo_data_url = 'https://ais-sample-data.obs.myhuaweicloud.com/tagging-normal.jpg'

    # call interface use the url
    result = image_tagging_aksk(app_key, app_secret, "", demo_data_url, 'zh',
                                5, 30)
    print(result)

    # call interface use the file
    result = image_tagging_aksk(
        app_key, app_secret, encode_to_base64('data/image-tagging-demo.jpg'),
        '', 'zh', 5, 60)
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64, download_url_base64
from ais_sdk.image_antiporn import image_antiporn

if __name__ == '__main__':
    #
    # access moderation, image anti-p**n,post data by token
    #
    user_name = '*******'
    password = '******'
    account_name = '*******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/antiporn.jpg'
    token = get_token(user_name, password, account_name)

    # call interface use the url download
    image_antiporn(
        token,
        download_url_base64(
            'http://moderation-demo.ei.huaweicloud.com/theme/images/imagga/image_tagging_04.jpg'
        ))

    # call interface use the url

    image_antiporn(token, '', demo_data_url)

    # call interface use the file
    image_antiporn(token, encode_to_base64('data/moderation-antiporn.jpg'))
示例#25
0
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access moderation distortion correct post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use
    init_global_env(region='cn-north-1')

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/vat-invoice.jpg'
    token = get_token(user_name, password, account_name)

    #call interface use the url correction is true means do not correction
    result = distortion_correct(token, "", demo_data_url, True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] !='':
        decode_to_wave_file(result_obj['result']['data'], 'data/modeation-distortion-token-1.png')
    else:
        print result

    # call interface use the file
    result = distortion_correct(token, encode_to_base64('data/modeation-distortion.jpg'), '', True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'], 'data/modeation-distortion-token-2.png')
    else:
        print result
示例#26
0
# -*- coding:utf-8 -*-
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.dark_enhance import dark_enhance_aksk
import json

if __name__ == '__main__':
    #
    # access image dark enhance by ak,sk
    #
    app_key = '*************'
    app_secret = '************'



    # call interface use base64 file
    result = dark_enhance_aksk(app_key,app_secret, encode_to_base64('data/dark-enhance-demo.bmp'), '0.95')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/dark-enhance-demo-aksk.bmp')
示例#27
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.asr_sentence import asr_sentence
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    # Services currently support North China-Beijing 1 (cn-north-1)
    init_global_env('cn-north-1')

    #
    # access asr, asr_sentence,post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://obs-ch-sdk-sample.obs.cn-north-1.myhwclouds.com/asr-sentence.wav'
    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = asr_sentence(token, '', demo_data_url, 'wav', '16k')
    print(result)

    # call interface use the file
    result = asr_sentence(token, encode_to_base64('data/asr-sentence.wav'), '',
                          'wav', '16k')
    print(result)
示例#28
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.dark_enhance import dark_enhance
from ais_sdk.utils import init_global_env
import json

if __name__ == '__main__':
    #
    # access image dark enhance by token
    #
    user_name = '*****'
    password = '******'
    account_name = '*****'  # the same as user_name in commonly use
    init_global_env(region='cn-north-1')

    token = get_token(user_name, password, account_name)

    # call interface use base64 file
    result = dark_enhance(token, encode_to_base64('data/dark-enhance-demo.bmp'), '0.95')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/dark-enhance-demo-token.bmp')
if __name__ == '__main__':
    #
    # access moderation distortion correct post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhwclouds.com/vat-invoice.jpg'
    token = get_token(user_name, password, account_name)

    #call interface use the url correction is true means do not correction
    result = distortion_correct(token, "", demo_data_url, True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'],
                            'data/modeation-distortion-token-1.png')
    else:
        print result

    # call interface use the file
    result = distortion_correct(
        token, encode_to_base64('data/modeation-distortion.jpg'), '', True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'],
                            'data/modeation-distortion-token-2.png')
    else:
        print result
示例#30
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.image_tagging import image_tagging
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    #
    # access image tagging , post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use
    init_global_env(region='cn-north-1')

    # The OBS link needs to be consistent with the region, and the OBS resources of different regions are not shared
    demo_data_url = 'https://ais-sample-data.obs.myhuaweicloud.com/tagging-normal.jpg'

    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = image_tagging(token, "", demo_data_url, 'zh', 5, 30)
    print(result)

    # call interface use the file
    result = image_tagging(token, encode_to_base64('data/image-tagging-demo.jpg'), '', 'zh', 5, 60)
    print(result)