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
Beispiel #2
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')
Beispiel #3
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')
Beispiel #4
0
# -*- coding:utf-8 -*-

from ais_sdk.gettoken import get_token
from ais_sdk.utils import decode_to_wave_file
from ais_sdk.tts import tts
import json

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

    token = get_token(user_name, password, account_name)

    # call interface use the default config
    result = tts(token, '语音合成为你的业务增加交互的能力.')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result']['data'],
                        'data/tts_use_default_config.wav')

    # call interface use the specific config
    result = tts(token, '这里是语音合成的测试。', 'xiaoyu', '0', '16k')
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result']['data'],
                        'data/tts_use_specific_config.wav')
# -*- 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')
# -*- 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.moderation_distortion_correct import moderation_distortion_correct
import json

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 correction is true means do not correction
    result = moderation_distortion_correct(token, "", demo_data_url, True)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result']['data'],
                        'data/modeation_distortion-correct.png')
    print result

    # call interface use the file
    result = moderation_distortion_correct(
        token, encode_to_base64('data/modeation_distortion.jpg'), '', True)
    print result
# -*- 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
import json

if __name__ == '__main__':
    #
    # access image dark enhance 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 = 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-token.bmp')
Beispiel #8
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_dark_enhance import image_dark_enhance
import json

if __name__ == '__main__':
    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_dark_enhance(
        token, encode_to_base64('data/dark-enhance-demo-1.bmp'), '0.95')
    print(result)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/dark_enhance_first.bmp')
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/moderation-distortion-aksk-1.png')
    else:
        print(result)

    # call interface use the file
    result = distortion_correct_aksk(
        app_key, app_secret,
        encode_to_base64('data/moderation-distortion.jpg'), '', True)
    result_obj = json.loads(result)
    if result_obj['result']['data'] != '':
        decode_to_wave_file(result_obj['result']['data'],
                            'data/moderation-distortion-aksk-2.png')
    else:
        print(result)
Beispiel #10
0
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.myhwclouds.com/tagging-normal.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-correct_first.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-correct_second.png')
    print result

    #
    # access moderation distortion correct.post data by ak,sk
    app_key = "*************"
    app_secret = "************"
Beispiel #11
0
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-1.png'),
                         '1.5')
    print(result)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/defog-demo_first.png')

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

    # call interface use base64 file
    result = image_defog_aksk(app_key, app_secret,
                              encode_to_base64('data/defog-demo-1.png'), '1.5')
    print(result)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'], 'data/defog-demo_second.png')
Beispiel #12
0
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

    token = get_token(user_name, password, account_name)

    # call interface use base64 file
    result = super_resolution(
        token, encode_to_base64('data/super-resolution-demo-1.png'), 3)
    print(result)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'],
                        'data/super-resolution-demo-first.png')

    #
    # access image super resolution enhance,post data by sk,sk
    #
    app_key = "*************"
    app_secret = "************"

    # call interface use base64 file
    result = super_resolution_aksk(
        app_key, app_secret,
        encode_to_base64('data/super-resolution-demo-1.png'), 3)
    print(result)
    result_obj = json.loads(result)
    decode_to_wave_file(result_obj['result'],
                        'data/super-resolution-demo-second.png')