15
from __future__ import annotations
19
from unittest import TestCase
21
from paddlenlp.utils import install_package
22
from paddlenlp.utils.downloader import get_path_from_url
23
from tests.testing_utils import argv_context_guard, load_test_config
26
class ErnieViLTest(TestCase):
27
def setUp(self) -> None:
28
self.path = "./model_zoo/ernie-vil2.0"
29
self.config_path = "./tests/fixtures/model_zoo/ernie_vil.yaml"
30
sys.path.insert(0, self.path)
32
def tearDown(self) -> None:
33
sys.path.remove(self.path)
35
def test_finetune(self):
36
install_package("lmdb", "1.3.0")
37
if not os.path.exists("./tests/fixtures/Flickr30k-CN"):
38
URL = "https://paddlenlp.bj.bcebos.com/tests/Flickr30k-CN-small.zip"
39
get_path_from_url(URL, root_dir="./tests/fixtures")
42
finetune_config = load_test_config(self.config_path, "finetune")
43
with argv_context_guard(finetune_config):
44
from run_finetune import do_train
50
"model_path": finetune_config["output_dir"],
51
"output_path": finetune_config["output_dir"],
53
with argv_context_guard(export_config):
54
from export_model import main
60
"image_path": "./tests/fixtures/tests_samples/COCO/000000039769.png",
61
"model_dir": export_config["output_path"],
62
"device": finetune_config["device"],
64
with argv_context_guard(infer_config):
65
from deploy.python.infer import main