Этот коммит содержится в:
Petr Andriushchenko 2023-02-27 15:28:26 +01:00
родитель 75ed827958
Коммит b9ef52107b
2 изменённых файлов: 15 добавлений и 17 удалений

Просмотреть файл

@ -38,14 +38,6 @@ def test_analyse_image():
id_ = os.path.splitext(os.path.basename(img_path))[0]
mydict[id_] = {"filename": img_path}
summary_device = device("cuda" if cuda.is_available() else "cpu")
summary_model, summary_vis_processors, _ = load_model_and_preprocess(
name="blip_caption",
model_type="base_coco",
is_eval=True,
device=summary_device,
)
for key in mydict:
mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image()
keys = list(mydict.keys())
@ -90,6 +82,17 @@ def test_analyse_image():
"a person running on a beach near a rock formation"
)
del sm.SummaryDetector.summary_model, sm.SummaryDetector.summary_vis_processors
cuda.empty_cache()
summary_device = device("cuda" if cuda.is_available() else "cpu")
summary_model, summary_vis_processors, _ = load_model_and_preprocess(
name="blip_caption",
model_type="base_coco",
is_eval=True,
device=summary_device,
)
for key in mydict:
mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image(
summary_model, summary_vis_processors
@ -136,6 +139,9 @@ def test_analyse_image():
"a person running on a beach near a rock formation"
)
del summary_model, summary_vis_processors
cuda.empty_cache()
summary_model, summary_vis_processors, _ = load_model_and_preprocess(
name="blip_caption",
model_type="large_coco",
@ -210,14 +216,6 @@ def test_analyse_questions():
id_ = os.path.splitext(os.path.basename(img_path))[0]
mydict[id_] = {"filename": img_path}
summary_device = device("cuda" if cuda.is_available() else "cpu")
(
summary_VQA_model,
summary_VQA_vis_processors,
summary_VQA_txt_processors,
) = load_model_and_preprocess(
name="blip_vqa", model_type="vqav2", is_eval=True, device=summary_device
)
list_of_questions = [
"How many persons on the picture?",
"What happends on the picture?",

Просмотреть файл

@ -40,7 +40,7 @@ dependencies = [
"pytest-cov",
"matplotlib",
"pytest",
"opencv-contrib-python",
"opencv-contrib-python <= 4.6",
"googletrans==3.1.0a0",
"spacy",
"jupyterlab",