程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Come on, white whoring cartoon avatar! Python calls Baidu AI interface, and one line of code converts 200 pieces for free.

編輯:Python

Hello everyone , This is Wang Feng, a programmer .

Python The official website of automated office has been released :​ ​https://www.python-office.com/​

Last time I shared with you :​ ​ A cartoon Avatar 50 element ?1 That's ok Python Code implementation , Stop paying the IQ tax ​​

0. Problem specification

Everyone loves this feature , This function will be implemented in a short time 200 Trial runs out . If you make the following error report , Explain that there is no problem with your program itself , I just ran out of trials .

Today I will add an advanced version to you , Make sure everyone can use ~

1. install python-office

Easy to install , There is python On the computer of the environment , Just execute the following command line .

If you have used python-office This library , You also need to perform , You can download to the latest version ~

install

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python-office -U

  • 1.

2. Generate animation avatar

Go straight to the code ! Code

# Import this library :python-office, Shorthand for office

import office

office.image.img2Cartoon(path='',client_api=' Yours api key', client_secret=' Yours secret key')

# Parameter description :
# path: Where to store your own live photos + PDF The name of the file , for example :d://image// Programmer Wanfeng .jpg
# client_api: ' Yours api key'
# client_secret: ' Yours secret key'
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

Run the above code directly , You will get a converted cartoon avatar .

The program may need to run 20 About seconds .

3. Open your own cartoon avatar account for free

I believe careful friends have found , The difference between this latest version and the last one is : More `​​clinet_api and client_secret​​` this 2 Parameters .

this 2 The first parameter is Baidu AI Platform , Everyone 200 Free calls .

This is why people reported errors in the previous version : Because I have provided you with my own 200 Trial times , It has been used up .

It's easy to open a free trial , Open the baidu AI platform , find : Portrait animation this function , Then create your own application , Copy from the picture below 2 Just add a message to your own code . If you don't know Baidu AI Links to the platform , You can ask questions in the comment area ( No links in the article , It is easy to fail the audit ).

4. All functions

1 Lines of code implement complex functions , Is it convenient to use ?

The project has been included in 【 Open source in China 】、【Python Official website 】 Such as platform , All functions , Free for everyone to use :​ ​https://github.com/CoderWanFeng/python-office​​


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved