From 260e6f0333a7ca80563a0cd7d4cf2e2e12560665 Mon Sep 17 00:00:00 2001 From: wwakabobik Date: Sat, 14 Oct 2023 15:41:16 +0200 Subject: [PATCH 1/2] Update README.md and requirements.txt --- README.md | 2 ++ pyproject.toml | 2 +- requirements.txt | 6 +++--- setup.cfg | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3d468a9..53cd9d1 100644 --- a/README.md +++ b/README.md @@ -86,3 +86,5 @@ Which contains details of models like following: Have fun and enjoy! +## Donations +If you like this project, you can support it by donating via [DonationAlerts](https://www.donationalerts.com/r/rocketsciencegeek). diff --git a/pyproject.toml b/pyproject.toml index d76b356..31666fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "leonardo_api" -version = "0.0.5" +version = "0.0.6" authors = [ { name="Iliya Vereshchagin", email="i.vereshchagin@gmail.com" }, ] diff --git a/requirements.txt b/requirements.txt index 1c9e1a2..b651293 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ -aiohttp==3.8.5 +aiohttp==3.8.6 aiofiles==23.2.1 asyncio==3.4.3 requests==2.31.0 -urllib3==2.0.5 +urllib3==2.0.6 async-timeout==4.0.3 certifi==2023.7.22 -charset-normalizer==3.2.0 +charset-normalizer==3.3.0 frozenlist==1.4.0 diff --git a/setup.cfg b/setup.cfg index ac2e689..a5b6666 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = leonardo_api -version = attr: leonardo_api.0.0.5 +version = attr: leonardo_api.0.0.6 author = Iliya Vereshchagin author_email = i.vereshchagin@gmail.com url = https://github.com/wwakabobik/leonardo_api From a11c1f9feaa4d41b4dc1a36dbdb5aea49c27e31e Mon Sep 17 00:00:00 2001 From: wwakabobik Date: Sat, 14 Oct 2023 15:46:19 +0200 Subject: [PATCH 2/2] Update README.md and requirements.txt --- README.md | 31 +++++++++++++++---------------- src/README.md | 36 +++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 53cd9d1..b26bfa3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This package contains Python API for [Leonardo.ai](https://leonardo.ai/) based o To install the package, please use package from [pypi](https://pypi.org/project/leonardo-api/): ```bash - pip install leonardo-api +pip install leonardo-api ``` This Python API provides access to Leonardo API using synchronous methods (based on requests library) as well as asynchronous (aiohttp). You can choose one of them - `Leonardo` or `LeonardoAsync`. @@ -15,44 +15,43 @@ This Python API provides access to Leonardo API using synchronous methods (based To start, you must have paid subscription and create an API access token from you [settings page](https://app.leonardo.ai/settings)->User API. Then, init manager class with using your access_token: ```python - from leonardo_api import Leonardo - - leonardo = Leonardo(auth_token='abcd-1234-5678-90ef-deadbeef00000') +from leonardo_api import Leonardo + +leonardo = Leonardo(auth_token='abcd-1234-5678-90ef-deadbeef00000') ``` Now you can use all API methods, provided by Leonardo.ai API, i.e. starting getting user info and generating your first image: ```python - response = leonardo.get_user_info() # get your user info - response = leonardo.post_generations(prompt="The quick brown fox jumps over the lazy dog", num_images=1, - negative_prompt='schrodinger cat paradox', - model_id='e316348f-7773-490e-adcd-46757c738eb7', width=1024, height=768, - guidance_scale=7) +response = leonardo.get_user_info() # get your user info +response = leonardo.post_generations(prompt="The quick brown fox jumps over the lazy dog", num_images=1, + negative_prompt='schrodinger cat paradox', + model_id='e316348f-7773-490e-adcd-46757c738eb7', width=1024, height=768, + guidance_scale=7) ``` In according to API reference, you will get the json answer with content about pending job like following: ```json - {'sdGenerationJob': {'generationId': '123456-0987-aaaa-bbbb-01010101010'}} +{"sdGenerationJob": {"generationId": "123456-0987-aaaa-bbbb-01010101010"}} ``` To obtain your image you need to use additional method: ```python - - response = leonardo.get_single_generation(generation_id) # get it using response['sdGenerationJob']['generationId'] +response = leonardo.get_single_generation(generation_id) # get it using response['sdGenerationJob']['generationId'] ``` Or, optionally, you may wait for job completion using following method: ```python - response = leonardo.wait_for_image_generation(generation_id=response['sdGenerationJob']['generationId']) +response = leonardo.wait_for_image_generation(generation_id=response['sdGenerationJob']['generationId']) ``` Finally, you'll get your array of images: ```python - [{'url': 'https://cdn.leonardo.ai/users/abcd-1234-5678-90ef-deadbeef00000/generations/123456-0987-aaaa-bbbb-01010101010/Absolute_Reality_v16_The_quick_brown_fox_jumps_0.jpg', 'nsfw': False, 'id': 'aaaaaa-bbbb-cccc-dddd-ffffffffff', 'likeCount': 0, 'generated_image_variation_generics': []}] +[{'url': 'https://cdn.leonardo.ai/users/abcd-1234-5678-90ef-deadbeef00000/generations/123456-0987-aaaa-bbbb-01010101010/Absolute_Reality_v16_The_quick_brown_fox_jumps_0.jpg', 'nsfw': False, 'id': 'aaaaaa-bbbb-cccc-dddd-ffffffffff', 'likeCount': 0, 'generated_image_variation_generics': []}] ``` ![The quick brown fox jumps over the lazy dog](https://raw.githubusercontent.com/wwakabobik/leonardo_api/master/src/assets/fox.jpeg) @@ -61,10 +60,10 @@ You'll find descriptions for rest of the methods in official [API reference](htt --- -As option, you may want to use pre-loaded dicts with models (nsfw/community/platform): +As option, you may want to use preloaded dicts with models (nsfw/community/platform): ```python - from leonardo_api import platform_models, custom_models, nsfw_models +from leonardo_api import platform_models, custom_models, nsfw_models ``` Which contains details of models like following: diff --git a/src/README.md b/src/README.md index 2361026..b26bfa3 100644 --- a/src/README.md +++ b/src/README.md @@ -7,7 +7,7 @@ This package contains Python API for [Leonardo.ai](https://leonardo.ai/) based o To install the package, please use package from [pypi](https://pypi.org/project/leonardo-api/): ```bash - pip install leonardo-api +pip install leonardo-api ``` This Python API provides access to Leonardo API using synchronous methods (based on requests library) as well as asynchronous (aiohttp). You can choose one of them - `Leonardo` or `LeonardoAsync`. @@ -15,44 +15,43 @@ This Python API provides access to Leonardo API using synchronous methods (based To start, you must have paid subscription and create an API access token from you [settings page](https://app.leonardo.ai/settings)->User API. Then, init manager class with using your access_token: ```python - from leonardo_api import Leonardo - - leonardo = Leonardo(auth_token='abcd-1234-5678-90ef-deadbeef00000') +from leonardo_api import Leonardo + +leonardo = Leonardo(auth_token='abcd-1234-5678-90ef-deadbeef00000') ``` Now you can use all API methods, provided by Leonardo.ai API, i.e. starting getting user info and generating your first image: ```python - response = leonardo.get_user_info() # get your user info - response = leonardo.post_generations(prompt="The quick brown fox jumps over the lazy dog", num_images=1, - negative_prompt='schrodinger cat paradox', - model_id='e316348f-7773-490e-adcd-46757c738eb7', width=1024, height=768, - guidance_scale=7) +response = leonardo.get_user_info() # get your user info +response = leonardo.post_generations(prompt="The quick brown fox jumps over the lazy dog", num_images=1, + negative_prompt='schrodinger cat paradox', + model_id='e316348f-7773-490e-adcd-46757c738eb7', width=1024, height=768, + guidance_scale=7) ``` In according to API reference, you will get the json answer with content about pending job like following: ```json - {'sdGenerationJob': {'generationId': '123456-0987-aaaa-bbbb-01010101010'}} +{"sdGenerationJob": {"generationId": "123456-0987-aaaa-bbbb-01010101010"}} ``` To obtain your image you need to use additional method: ```python - - response = leonardo.get_single_generation(generation_id) # get it using response['sdGenerationJob']['generationId'] +response = leonardo.get_single_generation(generation_id) # get it using response['sdGenerationJob']['generationId'] ``` Or, optionally, you may wait for job completion using following method: ```python - response = leonardo.wait_for_image_generation(generation_id=response['sdGenerationJob']['generationId']) +response = leonardo.wait_for_image_generation(generation_id=response['sdGenerationJob']['generationId']) ``` Finally, you'll get your array of images: ```python - [{'url': 'https://cdn.leonardo.ai/users/abcd-1234-5678-90ef-deadbeef00000/generations/123456-0987-aaaa-bbbb-01010101010/Absolute_Reality_v16_The_quick_brown_fox_jumps_0.jpg', 'nsfw': False, 'id': 'aaaaaa-bbbb-cccc-dddd-ffffffffff', 'likeCount': 0, 'generated_image_variation_generics': []}] +[{'url': 'https://cdn.leonardo.ai/users/abcd-1234-5678-90ef-deadbeef00000/generations/123456-0987-aaaa-bbbb-01010101010/Absolute_Reality_v16_The_quick_brown_fox_jumps_0.jpg', 'nsfw': False, 'id': 'aaaaaa-bbbb-cccc-dddd-ffffffffff', 'likeCount': 0, 'generated_image_variation_generics': []}] ``` ![The quick brown fox jumps over the lazy dog](https://raw.githubusercontent.com/wwakabobik/leonardo_api/master/src/assets/fox.jpeg) @@ -61,10 +60,10 @@ You'll find descriptions for rest of the methods in official [API reference](htt --- -As option, you may want to use pre-loaded dicts with models (nsfw/community/platform): +As option, you may want to use preloaded dicts with models (nsfw/community/platform): ```python - from leonardo_api import platform_models, custom_models, nsfw_models +from leonardo_api import platform_models, custom_models, nsfw_models ``` Which contains details of models like following: @@ -84,4 +83,7 @@ Which contains details of models like following: } ``` -Have fun and enjoy! \ No newline at end of file +Have fun and enjoy! + +## Donations +If you like this project, you can support it by donating via [DonationAlerts](https://www.donationalerts.com/r/rocketsciencegeek).