Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 7a751b7

Browse files
authored
Merge pull request #15 from Integration-Automation/dev
Add generate image doc
2 parents 456e415 + f02762c commit 7a751b7

File tree

5 files changed

+65
-3
lines changed

5 files changed

+65
-3
lines changed

docs/source/docs/Eng/eng_index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+

docs/source/docs/Zh/zh_index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

test/unit_test/test_generate_image/test_generation_manual.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_generate_image_sync():
3838
# Generate image list async
3939
async 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("Кра́снаяпло́щадь")

0 commit comments

Comments
 (0)