Ejemplo n.º 1
0
        print('enter by number')
        get_num = input('>> ')
    return int(get_num)


def enter_command():
    command = input('>> ')
    while True:
        if command in ['0', '1', '2']:
            return int(command)
        else:
            print('輪郭描画:0 顔のみ切り出し:1 編集なし:2')
            command = input('>> ')


if __name__ == '__main__':

    fetcher = Fetcher(MY_UA)
    facer = Facer()

    print('欲しい画像のキーワードを入力してください')
    keyword = input('>> ')
    print('枚数を入力してください')
    get_num = enter_number()
    # get_num = int(input('>> '))
    print('顔の編集モードを指定してください 輪郭描画:0 顔のみ切り出し:1 編集なし:2')
    command = enter_command()
    image_urls = url_search(keyword, get_num)
    print(str(len(image_urls)) + '枚の画像URLの取得に成功しました')
    download_count = image_collector_in_url(image_urls, keyword, command)
    print(str(download_count) + '件の画像の収集に成功しました')
Ejemplo n.º 2
0
            #顔編集実行
            if command in command_dict.keys():
                encode = np.asarray(bytearray(img), dtype=np.uint8)
                img = command_dict[command](encode)
                facer.save_img(img, file)
                print('ダウンロード成功 URL:' + str(url))
                scount += 1
            else:
                with open(file, mode='wb') as f:
                    f.write(img)
                print('ダウンロード成功 URL:' + str(url))
                scount += 1

        return scount


if __name__ == '__main__':

    fetcher = Fetcher(MY_UA)
    facer = Facer('haarcascade_frontalface_alt.xml')

    print('欲しい画像のキーワードを入力してください')
    keyword = input('>> ')
    print('枚数を入力してください')
    get_num = int(input('>> '))
    print('顔の編集モードを指定してください 輪郭描画:0 顔のみ切り出し:1 編集なし:2')
    command = int(input('>> '))
    image_urls = url_search(keyword, get_num)
    print(str(len(image_urls)) + '枚の画像URLの取得に成功しました')
    download_count = image_collector_in_url(image_urls, keyword, command)
    print(str(download_count) + '件の画像の収集に成功しました')