|
11 | 11 | from labelbox.schema.queue_mode import QueueMode |
12 | 12 |
|
13 | 13 |
|
| 14 | +@pytest.fixture() |
| 15 | +def audio_data_row(rand_gen): |
| 16 | + return { |
| 17 | + "row_data": |
| 18 | + "https://storage.googleapis.com/labelbox-datasets/audio-sample-data/sample-audio-1.mp3", |
| 19 | + "global_key": |
| 20 | + f"https://storage.googleapis.com/labelbox-datasets/audio-sample-data/sample-audio-1.mp3-{rand_gen(str)}", |
| 21 | + "media_type": |
| 22 | + "AUDIO", |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | +@pytest.fixture() |
| 27 | +def conversation_data_row(rand_gen): |
| 28 | + return { |
| 29 | + "row_data": |
| 30 | + "https://storage.googleapis.com/labelbox-datasets/conversational-sample-data/sample-conversation-1.json", |
| 31 | + "global_key": |
| 32 | + f"https://storage.googleapis.com/labelbox-datasets/conversational-sample-data/sample-conversation-1.json-{rand_gen(str)}", |
| 33 | + "media_type": |
| 34 | + "CONVERSATIONAL", |
| 35 | + } |
| 36 | + |
| 37 | + |
| 38 | +@pytest.fixture() |
| 39 | +def dicom_data_row(rand_gen): |
| 40 | + return { |
| 41 | + "row_data": |
| 42 | + "https://storage.googleapis.com/labelbox-datasets/dicom-sample-data/sample-dicom-1.dcm", |
| 43 | + "global_key": |
| 44 | + f"https://storage.googleapis.com/labelbox-datasets/dicom-sample-data/sample-dicom-1.dcm-{rand_gen(str)}", |
| 45 | + "media_type": |
| 46 | + "DICOM", |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | +@pytest.fixture() |
| 51 | +def geospatial_data_row(rand_gen): |
| 52 | + return { |
| 53 | + "row_data": { |
| 54 | + "tile_layer_url": |
| 55 | + "https://s3-us-west-1.amazonaws.com/lb-tiler-layers/mexico_city/{z}/{x}/{y}.png", |
| 56 | + "bounds": [[19.405662413477728, -99.21052827588443], |
| 57 | + [19.400498983095076, -99.20534818927473]], |
| 58 | + "min_zoom": |
| 59 | + 12, |
| 60 | + "max_zoom": |
| 61 | + 20, |
| 62 | + "epsg": |
| 63 | + "EPSG4326", |
| 64 | + }, |
| 65 | + "global_key": |
| 66 | + f"https://s3-us-west-1.amazonaws.com/lb-tiler-layers/mexico_city/z/x/y.png-{rand_gen(str)}", |
| 67 | + "media_type": |
| 68 | + "TMS_GEO", |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | +@pytest.fixture() |
| 73 | +def html_data_row(rand_gen): |
| 74 | + return { |
| 75 | + "row_data": |
| 76 | + "https://storage.googleapis.com/labelbox-datasets/html_sample_data/sample_html_1.html", |
| 77 | + "global_key": |
| 78 | + f"https://storage.googleapis.com/labelbox-datasets/html_sample_data/sample_html_1.html-{rand_gen(str)}", |
| 79 | + } |
| 80 | + |
| 81 | + |
| 82 | +@pytest.fixture() |
| 83 | +def image_data_row(rand_gen): |
| 84 | + return { |
| 85 | + "row_data": |
| 86 | + "https://lb-test-data.s3.us-west-1.amazonaws.com/image-samples/sample-image-1.jpg", |
| 87 | + "global_key": |
| 88 | + f"https://lb-test-data.s3.us-west-1.amazonaws.com/image-samples/sample-image-1.jpg-{rand_gen(str)}", |
| 89 | + "media_type": |
| 90 | + "IMAGE", |
| 91 | + } |
| 92 | + |
| 93 | + |
| 94 | +@pytest.fixture() |
| 95 | +def document_data_row(rand_gen): |
| 96 | + return { |
| 97 | + "row_data": { |
| 98 | + "pdf_url": |
| 99 | + "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf", |
| 100 | + "text_layer_url": |
| 101 | + "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483-lb-textlayer.json" |
| 102 | + }, |
| 103 | + "global_key": |
| 104 | + f"https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf-{rand_gen(str)}", |
| 105 | + "media_type": |
| 106 | + "PDF", |
| 107 | + } |
| 108 | + |
| 109 | + |
| 110 | +@pytest.fixture() |
| 111 | +def text_data_row(rand_gen): |
| 112 | + return { |
| 113 | + "row_data": |
| 114 | + "https://lb-test-data.s3.us-west-1.amazonaws.com/text-samples/sample-text-1.txt", |
| 115 | + "global_key": |
| 116 | + f"https://lb-test-data.s3.us-west-1.amazonaws.com/text-samples/sample-text-1.txt-{rand_gen(str)}", |
| 117 | + "media_type": |
| 118 | + "TEXT", |
| 119 | + } |
| 120 | + |
| 121 | + |
| 122 | +@pytest.fixture() |
| 123 | +def video_data_row(rand_gen): |
| 124 | + return { |
| 125 | + "row_data": |
| 126 | + "https://storage.googleapis.com/labelbox-datasets/video-sample-data/sample-video-1.mp4", |
| 127 | + "global_key": |
| 128 | + f"https://storage.googleapis.com/labelbox-datasets/video-sample-data/sample-video-1.mp4-{rand_gen(str)}", |
| 129 | + "media_type": |
| 130 | + "VIDEO", |
| 131 | + } |
| 132 | + |
| 133 | + |
| 134 | +@pytest.fixture |
| 135 | +def data_row_json_by_data_type(audio_data_row, conversation_data_row, |
| 136 | + dicom_data_row, geospatial_data_row, |
| 137 | + html_data_row, image_data_row, document_data_row, |
| 138 | + text_data_row, video_data_row): |
| 139 | + return { |
| 140 | + 'audio': audio_data_row, |
| 141 | + 'conversation': conversation_data_row, |
| 142 | + 'dicom': dicom_data_row, |
| 143 | + 'geospatial': geospatial_data_row, |
| 144 | + 'html': html_data_row, |
| 145 | + 'image': image_data_row, |
| 146 | + 'document': document_data_row, |
| 147 | + 'text': text_data_row, |
| 148 | + 'video': video_data_row, |
| 149 | + } |
| 150 | + |
| 151 | + |
| 152 | +@pytest.fixture |
| 153 | +def annotations_by_data_type(polygon_inference, rectangle_inference, |
| 154 | + line_inference, entity_inference, |
| 155 | + checklist_inference, text_inference, |
| 156 | + video_checklist_inference): |
| 157 | + return { |
| 158 | + 'audio': [checklist_inference, text_inference], |
| 159 | + 'conversation': [checklist_inference, text_inference, entity_inference], |
| 160 | + 'dicom': [line_inference], |
| 161 | + 'document': [ |
| 162 | + entity_inference, checklist_inference, text_inference, |
| 163 | + rectangle_inference |
| 164 | + ], |
| 165 | + 'html': [text_inference, checklist_inference], |
| 166 | + 'image': [ |
| 167 | + polygon_inference, rectangle_inference, line_inference, |
| 168 | + checklist_inference, text_inference |
| 169 | + ], |
| 170 | + 'text': [entity_inference, checklist_inference, text_inference], |
| 171 | + 'video': [video_checklist_inference] |
| 172 | + } |
| 173 | + |
| 174 | + |
14 | 175 | @pytest.fixture |
15 | 176 | def ontology(): |
16 | 177 | bbox_tool = { |
@@ -168,10 +329,10 @@ def configured_project_pdf(client, ontology, rand_gen, pdf_url): |
168 | 329 |
|
169 | 330 |
|
170 | 331 | @pytest.fixture |
171 | | -def dataset_pdf_entity(client, rand_gen, pdf_entity_data_row): |
| 332 | +def dataset_pdf_entity(client, rand_gen, document_data_row): |
172 | 333 | dataset = client.create_dataset(name=rand_gen(str)) |
173 | 334 | data_row_ids = [] |
174 | | - data_row = dataset.create_data_row(pdf_entity_data_row) |
| 335 | + data_row = dataset.create_data_row(document_data_row) |
175 | 336 | data_row_ids.append(data_row.uid) |
176 | 337 | yield dataset, data_row_ids |
177 | 338 | dataset.delete() |
@@ -298,11 +459,13 @@ def entity_inference(prediction_id_mapping): |
298 | 459 | @pytest.fixture |
299 | 460 | def segmentation_inference(prediction_id_mapping): |
300 | 461 | segmentation = prediction_id_mapping['superpixel'].copy() |
301 | | - segmentation.update( |
302 | | - {'mask': { |
| 462 | + segmentation.update({ |
| 463 | + 'mask': { |
| 464 | + # TODO: Use a real URI |
303 | 465 | 'instanceURI': "sampleuri", |
304 | 466 | 'colorRGB': [0, 0, 0] |
305 | | - }}) |
| 467 | + } |
| 468 | + }) |
306 | 469 | del segmentation['tool'] |
307 | 470 | return segmentation |
308 | 471 |
|
|
0 commit comments