replicate-ruby 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82385c582239598bb4b62a3e133228b7e6fc417ea57a047c1489e5d94d787faf
4
- data.tar.gz: 4ccecfdb33f1a4cf3218587c7ed4fa28475da1ca13369e59d5875b07e4f092f8
3
+ metadata.gz: f7a1858f78be5077c9396f73607b07e9cc08531eb82476f8dc017d2da3cbcf38
4
+ data.tar.gz: 0a405743c2405687c58a27d8b6ad1078958eb0c237c3ab1a89922c9a17f150f2
5
5
  SHA512:
6
- metadata.gz: c8edef78b1309f5873997b33b1de5de82f2f8982ce2ec3ed32b0cdeca0e9038c77b4d56e6173441d106160e77fb1e0d2311024d5cae2c68a1fc91ef6c62cb725
7
- data.tar.gz: 56958524475fbd6636e1eb3f409b4dad100fe8179a982a746a0ee2ea4356ffa66724269a9da0e226e374bbe34c2526aacf3a358e5847ed55429ebf06700f2383
6
+ metadata.gz: 5141a0361e88ffec603dd331c813b3c99bff3e3f14bab88eb528ae7e519c117e5104463b8d7067ca0736be6e06b15d6ef512b668aa500caae40a1d2a3080d7a6
7
+ data.tar.gz: 23abec8601415dce6a56ac284889f1cf1c97ef6aff834cd23c2fdb1429be016a4b9880b401169cd4a04ceb67c1d022f109673c251b5314e2150d61a1e39c4ac6
data/Gemfile.lock CHANGED
@@ -1,61 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- replicate-ruby (0.1.7)
4
+ replicate-ruby (0.2.1)
5
5
  addressable
6
- faraday (>= 2.0)
6
+ faraday (>= 1.0)
7
7
  faraday-multipart
8
8
  faraday-retry
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.8.1)
13
+ addressable (2.8.4)
14
14
  public_suffix (>= 2.0.2, < 6.0)
15
15
  ast (2.4.2)
16
16
  byebug (11.1.3)
17
17
  coderay (1.1.3)
18
18
  crack (0.4.5)
19
19
  rexml
20
- faraday (2.7.2)
20
+ faraday (2.7.4)
21
21
  faraday-net_http (>= 2.0, < 3.1)
22
22
  ruby2_keywords (>= 0.0.4)
23
23
  faraday-multipart (1.0.4)
24
24
  multipart-post (~> 2)
25
25
  faraday-net_http (3.0.2)
26
- faraday-retry (2.0.0)
26
+ faraday-retry (2.1.0)
27
27
  faraday (~> 2.0)
28
28
  hashdiff (1.0.1)
29
- json (2.6.2)
29
+ json (2.6.3)
30
30
  method_source (1.0.0)
31
- minitest (5.16.3)
32
- multipart-post (2.2.3)
33
- parallel (1.22.1)
34
- parser (3.1.2.1)
31
+ minitest (5.18.0)
32
+ multipart-post (2.3.0)
33
+ parallel (1.23.0)
34
+ parser (3.2.2.1)
35
35
  ast (~> 2.4.1)
36
- pry (0.14.1)
36
+ pry (0.14.2)
37
37
  coderay (~> 1.1)
38
38
  method_source (~> 1.0)
39
- public_suffix (5.0.0)
39
+ public_suffix (5.0.1)
40
40
  rainbow (3.1.1)
41
41
  rake (13.0.6)
42
- regexp_parser (2.6.0)
42
+ regexp_parser (2.8.0)
43
43
  rexml (3.2.5)
44
- rubocop (1.36.0)
44
+ rubocop (1.51.0)
45
45
  json (~> 2.3)
46
46
  parallel (~> 1.10)
47
- parser (>= 3.1.2.1)
47
+ parser (>= 3.2.0.0)
48
48
  rainbow (>= 2.2.2, < 4.0)
49
49
  regexp_parser (>= 1.8, < 3.0)
50
50
  rexml (>= 3.2.5, < 4.0)
51
- rubocop-ast (>= 1.20.1, < 2.0)
51
+ rubocop-ast (>= 1.28.0, < 2.0)
52
52
  ruby-progressbar (~> 1.7)
53
- unicode-display_width (>= 1.4.0, < 3.0)
54
- rubocop-ast (1.21.0)
55
- parser (>= 3.1.1.0)
56
- ruby-progressbar (1.11.0)
53
+ unicode-display_width (>= 2.4.0, < 3.0)
54
+ rubocop-ast (1.28.1)
55
+ parser (>= 3.2.1.0)
56
+ ruby-progressbar (1.13.0)
57
57
  ruby2_keywords (0.0.5)
58
- unicode-display_width (2.3.0)
58
+ unicode-display_width (2.4.2)
59
59
  webmock (3.18.1)
60
60
  addressable (>= 2.8.0)
61
61
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -60,14 +60,13 @@ There is support for the [experimental dreambooth endpoint](https://replicate.co
60
60
 
61
61
  First, upload your training dataset:
62
62
 
63
- ```
64
- upload = Replicate.client.create_upload
65
- upload.attach('tmp/data.zip') # replace with the path to your zip file
63
+ ```ruby
64
+ upload = Replicate.client.upload_zip('tmp/data.zip') # replace with the path to your zip file
66
65
  ```
67
66
 
68
67
  Then start training a new model using, for instance:
69
68
 
70
- ```
69
+ ```ruby
71
70
  training = Replicate.client.create_training(
72
71
  input: {
73
72
  instance_prompt: "zwx style",
@@ -81,7 +80,7 @@ training = Replicate.client.create_training(
81
80
 
82
81
  As soon as the model has finished training, you can run predictions on it:
83
82
 
84
- ```
83
+ ```ruby
85
84
  prediction = Replicate.client.create_prediction(
86
85
  input: {
87
86
  prompt: 'your prompt, zwx style'
@@ -90,6 +89,12 @@ prediction = Replicate.client.create_prediction(
90
89
  )
91
90
  ```
92
91
 
92
+ You can also download the `output.zip` file from the dreambooth training prediction, unzip it, and then convert the trained model to a Stable Diffusion checkpoint with [convert_diffusers_to_sd.py](https://gist.github.com/jachiam/8a5c0b607e38fcc585168b90c686eb05).
93
+
94
+ ```bash
95
+ python ./convert_diffusers_to_sd.py --model_path ~/Downloads/output --checkpoint_path ~/Downloads/output.ckpt
96
+ ```
97
+
93
98
  ## Development
94
99
 
95
100
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -4,10 +4,18 @@ module Replicate
4
4
  class Client
5
5
  # Methods for the Prediction API
6
6
  module Upload
7
+ # Create upload object and upload zip file
8
+ def upload_zip(zip_path)
9
+ filename = zip_path.split('/')[-1]
10
+ upload = create_upload(filename)
11
+ upload.attach(zip_path)
12
+ upload
13
+ end
14
+
7
15
  # Create an upload
8
16
  # @see https://replicate.com/blog/dreambooth-api
9
- def create_upload
10
- response = dreambooth_endpoint.post("upload/data.zip")
17
+ def create_upload(filename = 'data.zip')
18
+ response = dreambooth_endpoint.post("upload/#{filename}")
11
19
  Replicate::Record::Upload.new(self, response)
12
20
  end
13
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Replicate
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: replicate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dreaming Tulpa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-08 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday-retry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.4.6
162
+ rubygems_version: 3.4.10
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Ruby client for Replicate