|
| 1 | +from openvino.model_api.models import Model |
| 2 | + |
| 3 | + |
| 4 | +def test_detector_save(tmp_path): |
| 5 | + downloaded = Model.create_model( |
| 6 | + "ssd300", configuration={"mean_values": [0, 0, 0], "confidence_threshold": 0.6} |
| 7 | + ) |
| 8 | + xml_path = str(tmp_path / "a.xml") |
| 9 | + downloaded.save(xml_path) |
| 10 | + deserialized = Model.create_model(xml_path) |
| 11 | + assert type(downloaded) == type(deserialized) |
| 12 | + for attr in downloaded.parameters(): |
| 13 | + assert getattr(downloaded, attr) == getattr(deserialized, attr) |
| 14 | + |
| 15 | + |
| 16 | +def test_classifier_save(tmp_path): |
| 17 | + downloaded = Model.create_model( |
| 18 | + "efficientnet-b0-pytorch", configuration={"scale_values": [1, 1, 1], "topk": 6} |
| 19 | + ) |
| 20 | + xml_path = str(tmp_path / "a.xml") |
| 21 | + downloaded.save(xml_path) |
| 22 | + deserialized = Model.create_model(xml_path) |
| 23 | + assert type(downloaded) == type(deserialized) |
| 24 | + for attr in downloaded.parameters(): |
| 25 | + assert getattr(downloaded, attr) == getattr(deserialized, attr) |
| 26 | + |
| 27 | + |
| 28 | +def test_segmentor_save(tmp_path): |
| 29 | + downloaded = Model.create_model( |
| 30 | + "hrnet-v2-c1-segmentation", |
| 31 | + configuration={"reverse_input_channels": True, "labels": ["first", "second"]}, |
| 32 | + ) |
| 33 | + xml_path = str(tmp_path / "a.xml") |
| 34 | + downloaded.save(xml_path) |
| 35 | + deserialized = Model.create_model(xml_path) |
| 36 | + assert type(downloaded) == type(deserialized) |
| 37 | + for attr in downloaded.parameters(): |
| 38 | + assert getattr(downloaded, attr) == getattr(deserialized, attr) |
0 commit comments