(
genclass: Type[PPTCrew],
setting: str,
model_identifier: str,
debug: bool,
ppt_folder: str,
thread_id: int,
num_slides: int = 12,
)
| 86 | |
| 87 | |
| 88 | def do_generate( |
| 89 | genclass: Type[PPTCrew], |
| 90 | setting: str, |
| 91 | model_identifier: str, |
| 92 | debug: bool, |
| 93 | ppt_folder: str, |
| 94 | thread_id: int, |
| 95 | num_slides: int = 12, |
| 96 | ): |
| 97 | app_config = Config(rundir=ppt_folder, debug=debug) |
| 98 | text_model = get_text_model(f"cuda:{thread_id % torch.cuda.device_count()}") |
| 99 | presentation = Presentation.from_file( |
| 100 | pjoin(ppt_folder, "source.pptx"), |
| 101 | app_config, |
| 102 | ) |
| 103 | ImageLabler(presentation, app_config).caption_images() |
| 104 | induct_cache = pjoin( |
| 105 | app_config.RUN_DIR, "template_induct", model_identifier, "induct_cache.json" |
| 106 | ) |
| 107 | if not older_than(induct_cache, wait=True): |
| 108 | print(f"induct_cache not found: {induct_cache}") |
| 109 | return |
| 110 | slide_induction = json.load(open(induct_cache)) |
| 111 | try: |
| 112 | pptgen: PPTCrew = genclass(text_model).set_reference(presentation, slide_induction) |
| 113 | except: |
| 114 | print("set_reference failed") |
| 115 | pptgen: PPTCrew = genclass(text_model).set_reference(presentation, slide_induction) |
| 116 | |
| 117 | topic = ppt_folder.split("/")[1] |
| 118 | for pdf_folder in glob(f"data/{topic}/pdf/*"): |
| 119 | app_config.set_rundir(pjoin(ppt_folder, setting, pbasename(pdf_folder))) |
| 120 | if pexists(pjoin(app_config.RUN_DIR, "history")): |
| 121 | continue |
| 122 | images = json.load( |
| 123 | open(pjoin(pdf_folder, "image_caption.json"), "r"), |
| 124 | ) |
| 125 | doc_json = json.load( |
| 126 | open(pjoin(pdf_folder, "refined_doc.json"), "r"), |
| 127 | ) |
| 128 | pptgen.generate_pres(app_config, images, num_slides, doc_json) |
| 129 | |
| 130 | |
| 131 | def generate_pres( |
nothing calls this directly
no test coverage detected