getimg_client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +51 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c270ce4b1b94d4fcecda2dbcd0424951bc97aca0eb81a8f64b77289bfbfb9545
4
- data.tar.gz: 60cc8120795a5f29d96245c1bcbf21c4cfd53b7dc1105dbc5bc5782df48608e6
3
+ metadata.gz: bebe5b9162ab45505ab6f74e4b816f9c14cee51734a12a8baf8e273824acae23
4
+ data.tar.gz: 506ab1f2ff553a225dc93fd0e5bd039c68a574d7c6f6c2a2a7da819940358cf3
5
5
  SHA512:
6
- metadata.gz: 7ce81853e15fffb3324c6f8892d1f159293dfd120aef733bb5baf15142adae5154e6b29c1fd7c9edf5ea6d6bf2faf07b6e32f8ff910d7585e29e65b31eabbc3c
7
- data.tar.gz: a7bc97f075fa1d32ccdbc50e84a60fdf806dfd5123d8179ff89cd07d773a97e585884511022a7c5a20793354d59eaff8dadd1285849c394a64fd85047249d7c9
6
+ metadata.gz: 251e4fef81fbaa5a0c6bcb5d9b2bd5b26717db6b7af29df3208461041ad02d07b74539256c24dc2bb080afd354e5ba58f48e253896781d8e186e5cc34f8e7dcd
7
+ data.tar.gz: 972aa553495c690c9e30d3eb45a1d86de972639235b3c4fa1e8916c635540b99ed662ac1579d8cb6e60a69326684541745e63184344647a1274475337bfaf62b
data/README.md CHANGED
@@ -3,6 +3,38 @@
3
3
  ## Introduction
4
4
  GetimgClient is a Ruby gem designed to interact with the Getimg.ai API, enabling users to generate, manipulate, and enhance images using various AI models. This gem simplifies the process of making API requests to Getimg.ai, allowing for seamless integration of image generation and manipulation capabilities into your Ruby applications.
5
5
 
6
+ ## Installation
7
+
8
+ To add it to a project using bundler, run the following command:
9
+
10
+ ```bash
11
+ bundle add getimg_client
12
+ ```
13
+
14
+ Alternatively you can add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'getimg_client'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```bash
23
+ bundle install
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```bash
29
+ gem install getimg_client
30
+ ```
31
+
32
+ Optionally, set the API key using the environment variable:
33
+
34
+ ```bash
35
+ export GETIMG_API_KEY=your_api_key
36
+ ```
37
+
6
38
  ## Functions
7
39
 
8
40
  ### `set_api_key(api_key)`
@@ -15,19 +47,20 @@ Fetch and cache the list of available models from the API.
15
47
  Retrieve cached models or fetch them if not already retrieved.
16
48
 
17
49
  ### `generate_image(prompt, model:, **options)`
18
- Generate an image based on a text prompt and specified model. Supports various image manipulation methods such as image-to-image, inpainting, controlnet, face fixing, and upscaling.
50
+ Generate an image based on a text prompt and specified model. Supports various image manipulation methods such as image-to-image, inpainting, controlnet, face fixing, instruct and upscaling.
19
51
 
20
52
  ### `get_balance`
21
53
  Retrieve the current account balance from the Getimg.ai API.
22
54
 
23
55
  ## Request Routing
24
- The `generate_image` method routes requests based on the provided options and the model's supported pipelines:
56
+ The `generate_image` method routes requests based on the provided options and the model's supported pipelines, sending it to its respective pipeline whether that's SD1.5, SDXL or LCM based:
25
57
  - **text-to-image**: Default if no images are provided.
26
58
  - **image-to-image**: Triggered if a base image is provided.
27
59
  - **inpaint**: Triggered if a mask image is provided.
28
60
  - **controlnet**: Triggered if controlnet options are provided.
29
61
  - **face-fix**: Triggered if the model supports face-fix and a base image is provided.
30
62
  - **upscale**: Triggered if the model supports upscale and a base image is provided.
63
+ - **instruct**: Triggered if the model supports instruct and a base image is provided.
31
64
 
32
65
  ## Parameters
33
66
  Parameters for `generate_image` and other methods are consistent with the official Getimg.ai API documentation. For detailed parameter descriptions, refer to the [official API documentation](https://docs.getimg.ai/reference/introduction).
@@ -46,13 +79,16 @@ raise StandardError, "Error: #{result['error']['message']} (code: #{result['erro
46
79
 
47
80
  If an HTTP error occurs, the error message will include both the HTTP status and the error message from the API response, if available.
48
81
 
49
- ### Models
82
+ ## Models
50
83
  The provided `model` option will determine the model use, and contribute to the client's inference of the desired endpoint. Models can be the string `id` listed online at [the GetImg dashboard](https://dashboard.getimg.ai/models) or retrieved using the `GetimgClient.models` method. Equally, you can use symbols instead. For example, `:realistic_vision_v5_1` will translate to `'realistic-vision-v5-1'`
51
84
 
52
- ### Base Image Options
53
- The `base_image` option can be provided, which will automatically set the "image" property for image-to-image, controlnet, face-fix, upscale and inpaint calls, and can be either a file path or a base64 encoded string of the file contents.
85
+ ## Latent Consistency Models (LCM)
86
+ Latent consistency models are designed to speed up image generation by circumventing the iterative generation process of diffusion-based methods. Building on direct consistency models that operate on image pixels, latent consistency models operate in the latent (lower-dimensional) space. The client will automatically route requests to these models as needed.
54
87
 
55
- ### Results
88
+ ## Base Image Options
89
+ The `base_image` option can be provided, which will automatically set the "image" property for image-to-image, controlnet, face-fix, upscale, inpaint and instruct calls, and can be either a file path or a base64 encoded string of the file contents.
90
+
91
+ ## Results
56
92
  If all went well and no errors were reported, the response will be equal to the API response received, and thus align with the official documentation. Typically, this will be a hash containing an `image` property with the Base64 encoded image contents, a `seed` property with the generation's seed value, and a `cost` property with the usage cost for the generation.
57
93
 
58
94
  ## Code Samples
@@ -104,10 +140,17 @@ result = GetimgClient.generate_image("Upscale image", model: :real_esrgan_4x, ba
104
140
  puts result["image"]
105
141
  ```
106
142
 
107
- ### Logging
143
+ ### Instruct
144
+ ```ruby
145
+ base_image = Base64.strict_encode64(File.read("path/to/base_image.jpg"))
146
+ result = GetimgClient.generate_image("Make it night time", model: :instruct_pix2pix, base_image:)
147
+ puts result["image"]
148
+ ```
149
+
150
+ ## Logging
108
151
  Request logging will automatically be enabled, if the **RAILS_ENV** environment variable is set to "development"
109
152
 
110
- ### Unit Testing
153
+ ## Unit Testing
111
154
  The gem includes unit tests using Minitest. Integration tests make real API calls and will incur usage fees. Ensure your API key is set in the environment before running tests.
112
155
 
113
156
  To run the integration tests:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getimg_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Melvin Sommer