florentgbelidji HF staff commited on
Commit
1d4aaa3
1 Parent(s): 0546112

Updated README

Browse files
Files changed (1) hide show
  1. README.md +38 -2
README.md CHANGED
@@ -38,9 +38,9 @@ def predict(path_to_image: str = None):
38
  with open(path_to_image, "rb") as i:
39
  image = i.read()
40
  payload = {
41
- "inputs": {"image": image},
42
  "parameters": {
43
- "sample": True,
44
  "top_p":0.9,
45
  "min_length":5,
46
  "max_length":20
@@ -55,6 +55,42 @@ prediction = predict(
55
  )
56
 
57
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  expected output
59
  ```python
60
  ['buckingham palace with flower beds and red flowers']
 
38
  with open(path_to_image, "rb") as i:
39
  image = i.read()
40
  payload = {
41
+ "inputs": [image],
42
  "parameters": {
43
+ "do_sample": True,
44
  "top_p":0.9,
45
  "min_length":5,
46
  "max_length":20
 
55
  )
56
 
57
  ```
58
+ Example parameters depending on the decoding strategy:
59
+
60
+ 1. Beam search
61
+
62
+ ```
63
+ "parameters": {
64
+ "num_beams":5,
65
+ "max_length":20
66
+ }
67
+ ```
68
+
69
+ 2. Nucleus sampling
70
+
71
+ ```
72
+ "parameters": {
73
+ "num_beams":1,
74
+ "max_length":20,
75
+ "do_sample": True,
76
+ "top_k":50,
77
+ "top_p":0.95
78
+ }
79
+ ```
80
+
81
+ 3. Contrastive search
82
+
83
+ ```
84
+ "parameters": {
85
+ "penalty_alpha":0.6,
86
+ "top_k":4
87
+ "max_length":512
88
+ }
89
+ ```
90
+
91
+ See [generate()](https://huggingface.co/docs/transformers/v4.25.1/en/main_classes/text_generation#transformers.GenerationMixin.generate) doc for additional detail
92
+
93
+
94
  expected output
95
  ```python
96
  ['buckingham palace with flower beds and red flowers']