getimg_client 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1028c687dea86e569bd237794d0a391db97d4079d7bbcdaa564eb5aff5fc1bc0
|
4
|
+
data.tar.gz: eac3cb2255aadf16b2c271aa3515201fd2a4bd55b5605ed276ebaac6e1252d92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 015ba46c1a34e85ceb8bc42727ffcc0abc99a596167fdc33d9adc1bd10b79502bf3831be68f31344025db72cb9ff0f08b8d836834582bb0f77cfb5f906d04f72
|
7
|
+
data.tar.gz: 76b468d1a099a92316f25cd531189348381572841f5ab82ea96acd19a2c226488b3335fda0a52ca4e5ded3f34b6ad253741b57a6e2028c75c5d4c0053e09c44b
|
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
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
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
|
-
###
|
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
|
-
|
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.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melvin Sommer
|
@@ -43,7 +43,8 @@ files:
|
|
43
43
|
homepage: https://gitlab.com/coeusit/getimg_client
|
44
44
|
licenses:
|
45
45
|
- MIT
|
46
|
-
metadata:
|
46
|
+
metadata:
|
47
|
+
source_code_uri: https://gitlab.com/coeusit/getimg_client
|
47
48
|
post_install_message:
|
48
49
|
rdoc_options: []
|
49
50
|
require_paths:
|