(self, data, num_images)
| 61 | return data_paths |
| 62 | |
| 63 | def change_format(self, data, num_images): |
| 64 | elements = [] |
| 65 | for conversation in data['conversations']: |
| 66 | if conversation['from'] == 'human': |
| 67 | if '<image>' not in conversation['value']: |
| 68 | elements.append({ |
| 69 | 'type': 'text', |
| 70 | 'has_loss': 0, |
| 71 | 'text': conversation['value'], |
| 72 | }) |
| 73 | else: |
| 74 | text_list = conversation['value'].split('<image>') |
| 75 | for idx, text in enumerate(text_list): |
| 76 | if text.strip() != '': |
| 77 | elements.append({ |
| 78 | 'type': 'text', |
| 79 | 'has_loss': 0, |
| 80 | 'text': text.strip(), |
| 81 | }) |
| 82 | if (idx != len(text_list) - 1) and (idx < num_images): |
| 83 | elements.append({'type': 'image',}) |
| 84 | elif conversation['from'] == 'gpt': |
| 85 | elements.append({ |
| 86 | 'type': 'text', |
| 87 | 'has_loss': 1, |
| 88 | 'text': conversation['value'], |
| 89 | }) |
| 90 | return elements |
| 91 | |
| 92 | def __iter__(self): |
| 93 | data_paths_per_worker, worker_id = self.get_data_paths_per_worker() |
nothing calls this directly
no outgoing calls
no test coverage detected