Mikael110 commited on
Commit
ff3fb2f
1 Parent(s): 9509157

Fix Tasks examples

Browse files

- Change prompt text to a string
- Change hardcoded `task='<OD>'` to `task=prompt`

These changes are necessary for most of the examples to work, and aligns the README with the Jupyter notebook examples.
These changes are also necessary in all of the other Florence-2 repos, but I'll only open the PR here since I don't want to spam PRs.

Files changed (1) hide show
  1. README.md +9 -9
README.md CHANGED
@@ -99,7 +99,7 @@ def run_example(prompt, text_input=None):
99
  )
100
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
101
 
102
- parsed_answer = processor.post_process_generation(generated_text, task="<OD>", image_size=(image.width, image.height))
103
 
104
  print(parsed_answer)
105
  ```
@@ -113,7 +113,7 @@ Here are the tasks `Florence-2` could perform:
113
  ### OCR
114
 
115
  ```python
116
- prompt = <OCR>
117
  run_example(prompt)
118
  ```
119
 
@@ -121,25 +121,25 @@ run_example(prompt)
121
  OCR with region output format:
122
  {'\<OCR_WITH_REGION>': {'quad_boxes': [[x1, y1, x2, y2, x3, y3, x4, y4], ...], 'labels': ['text1', ...]}}
123
  ```python
124
- prompt = <OCR_WITH_REGION>
125
  run_example(prompt)
126
  ```
127
 
128
  ### Caption
129
  ```python
130
- prompt = <CAPTION>
131
  run_example(prompt)
132
  ```
133
 
134
  ### Detailed Caption
135
  ```python
136
- prompt = <DETAILED_CAPTION>
137
  run_example(prompt)
138
  ```
139
 
140
  ### More Detailed Caption
141
  ```python
142
- prompt = <MORE_DETAILED_CAPTION>
143
  run_example(prompt)
144
  ```
145
 
@@ -150,7 +150,7 @@ OD results format:
150
  'labels': ['label1', 'label2', ...]} }
151
 
152
  ```python
153
- prompt = <OD>
154
  run_example(prompt)
155
  ```
156
 
@@ -159,7 +159,7 @@ Dense region caption results format:
159
  {'\<DENSE_REGION_CAPTION>' : {'bboxes': [[x1, y1, x2, y2], ...],
160
  'labels': ['label1', 'label2', ...]} }
161
  ```python
162
- prompt = <DENSE_REGION_CAPTION>
163
  run_example(prompt)
164
  ```
165
 
@@ -168,7 +168,7 @@ Dense region caption results format:
168
  {'\<REGION_PROPOSAL>': {'bboxes': [[x1, y1, x2, y2], ...],
169
  'labels': ['', '', ...]}}
170
  ```python
171
- prompt = <REGION_PROPOSAL>
172
  run_example(prompt)
173
  ```
174
 
 
99
  )
100
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
101
 
102
+ parsed_answer = processor.post_process_generation(generated_text, task=prompt, image_size=(image.width, image.height))
103
 
104
  print(parsed_answer)
105
  ```
 
113
  ### OCR
114
 
115
  ```python
116
+ prompt = '<OCR>'
117
  run_example(prompt)
118
  ```
119
 
 
121
  OCR with region output format:
122
  {'\<OCR_WITH_REGION>': {'quad_boxes': [[x1, y1, x2, y2, x3, y3, x4, y4], ...], 'labels': ['text1', ...]}}
123
  ```python
124
+ prompt = '<OCR_WITH_REGION>'
125
  run_example(prompt)
126
  ```
127
 
128
  ### Caption
129
  ```python
130
+ prompt = '<CAPTION>'
131
  run_example(prompt)
132
  ```
133
 
134
  ### Detailed Caption
135
  ```python
136
+ prompt = '<DETAILED_CAPTION>'
137
  run_example(prompt)
138
  ```
139
 
140
  ### More Detailed Caption
141
  ```python
142
+ prompt = '<MORE_DETAILED_CAPTION>'
143
  run_example(prompt)
144
  ```
145
 
 
150
  'labels': ['label1', 'label2', ...]} }
151
 
152
  ```python
153
+ prompt = '<OD>'
154
  run_example(prompt)
155
  ```
156
 
 
159
  {'\<DENSE_REGION_CAPTION>' : {'bboxes': [[x1, y1, x2, y2], ...],
160
  'labels': ['label1', 'label2', ...]} }
161
  ```python
162
+ prompt = '<DENSE_REGION_CAPTION>'
163
  run_example(prompt)
164
  ```
165
 
 
168
  {'\<REGION_PROPOSAL>': {'bboxes': [[x1, y1, x2, y2], ...],
169
  'labels': ['', '', ...]}}
170
  ```python
171
+ prompt = '<REGION_PROPOSAL>'
172
  run_example(prompt)
173
  ```
174