This repository was archived by the owner on Dec 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +65
-3
lines changed
test/unit_test/test_generate_image Expand file tree Collapse file tree 5 files changed +65
-3
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ ReEdgeGPT English Documentation
44.. toctree ::
55 :maxdepth: 4
66
7- chat_example.rst
7+ chat_example.rst
8+ generate_image.rst
Original file line number Diff line number Diff line change 1+ ReEdgeGPT Generate Image
2+ ----
3+
4+ .. code-block :: python
5+
6+ import asyncio
7+ import os
8+ import shutil
9+ from pathlib import Path
10+
11+ from re_edge_gpt import ImageGen, ImageGenAsync
12+
13+ # Read auth_cookie if you don't have this file please read README.md
14+ auth_cooker = open (" bing_cookies.txt" , " r+" ).read()
15+ async_gen = ImageGenAsync(auth_cookie = auth_cooker)
16+
17+ # Generate image list async
18+ async def test_generate_image_async ():
19+ print (" Generate Big Ben image" )
20+ # Get image links
21+ image_list = await async_gen.get_images(" Big Ben" )
22+ # Print image link list
23+ print (image_list)
24+
25+
26+ if __name__ == " __main__" :
27+ # Generate image async
28+ loop = asyncio.get_event_loop()
29+ loop.run_until_complete(test_generate_image_async())
30+
Original file line number Diff line number Diff line change 1+ ReEdgeGPT 生成圖片
2+ ----
3+
4+ .. code-block :: python
5+
6+ import asyncio
7+ import os
8+ import shutil
9+ from pathlib import Path
10+
11+ from re_edge_gpt import ImageGen, ImageGenAsync
12+
13+ # 如果沒有這個檔案請讀 README.md
14+ auth_cooker = open (" bing_cookies.txt" , " r+" ).read()
15+ async_gen = ImageGenAsync(auth_cookie = auth_cooker)
16+
17+ # 非同步產生圖片
18+ async def test_generate_image_async ():
19+ print (" Generate Big Ben image" )
20+ # 取得圖片連結 list
21+ image_list = await async_gen.get_images(" Big Ben" )
22+ # print 圖片連結 list
23+ print (image_list)
24+
25+
26+ if __name__ == " __main__" :
27+ # 產生圖片
28+ loop = asyncio.get_event_loop()
29+ loop.run_until_complete(test_generate_image_async())
30+
Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ ReEdgeGPT 繁體中文 文件
44.. toctree ::
55 :maxdepth: 4
66
7- chat_example.rst
7+ chat_example.rst
8+ generate_image.rst
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def test_generate_image_sync():
3838# Generate image list async
3939async def test_generate_image_async ():
4040 print ("Generate Big Ben image" )
41- image_list = sync_gen .get_images ("Big Ben" )
41+ image_list = await async_gen .get_images ("Big Ben" )
4242 print (image_list )
4343 print ("Generate Кра́снаяпло́щадь image" )
4444 image_list = await async_gen .get_images ("Кра́снаяпло́щадь" )
You can’t perform that action at this time.
0 commit comments