-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
48 lines (38 loc) · 1.52 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
from AsyncKandinsky import FusionBrainApi, ApiApi, ApiWeb
model = FusionBrainApi(ApiApi("Сюда свой api_key", "Сюда свой secret_key"))
# Любой способ на выбор
model = FusionBrainApi(ApiWeb("Ваша почта", "Ваш пароль"))
async def generate():
try:
result = await model.text2image("котик", style="ANIME", art_gpt=True)
except ValueError as e:
print(f"Error:\t{e}")
else:
with open("cat_anime_img.png", "wb") as f:
f.write(result.getvalue())
print("Done!")
# _______________________________________________________________________________________
try:
result = await model.text2video("котик бежит по полю")
except ValueError as e:
print(f"Error:\t{e}")
else:
with open("cat_anime_video.mp4", "wb") as f:
f.write(result.getvalue())
print("Done!")
# _______________________________________________________________________________________
try:
result = await model.text2animation(["котик бежит по полю", "котик пьёт воду из речки"])
except ValueError as e:
print(f"Error:\t{e}")
else:
with open("cat_anime_animation.mp4", "wb") as f:
f.write(result.getvalue())
print("Done!")
async def read_styles():
for style in await model.get_styles():
print(style)
if __name__ == '__main__':
asyncio.run(read_styles())
asyncio.run(generate())