MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / prepare_induction

Function prepare_induction

utils/src/experiment/preprocess.py:205–229  ·  view source on GitHub ↗
(induct_id: int, wait: bool = False)

Source from the content-addressed store, hash-verified

203
204
205def prepare_induction(induct_id: int, wait: bool = False):
206 induct_llms = [
207 (llms.qwen2_5, llms.qwen_vl),
208 (llms.gpt4o, llms.gpt4o),
209 (llms.qwen_vl, llms.qwen_vl),
210 ]
211
212 def do_induct(llm: list[llms.LLM], ppt_folder: str, rank: int):
213 if not older_than(pjoin(ppt_folder, "source.pptx"), wait=wait):
214 return
215 llms.language_model = llm[0]
216 llms.vision_model = llm[1]
217 config = Config(rundir=ppt_folder)
218 ppt_image_folder = pjoin(ppt_folder, "source_slides")
219 template_image_folder = pjoin(ppt_folder, "template_images")
220 image_model = get_image_model(f"cuda:{rank % device_count}")
221 presentation = Presentation.from_file(pjoin(ppt_folder, "source.pptx"), config)
222 ImageLabler(presentation, config).caption_images()
223 slide_inducter = SlideInducter(
224 presentation, ppt_image_folder, template_image_folder, config, image_model
225 )
226 slide_inducter.content_induct()
227
228 for folder in tqdm(sorted(glob.glob("data/*/pptx/*")), desc="prepare induction"):
229 do_induct(induct_llms[induct_id], folder, 0)
230
231
232if __name__ == "__main__":

Callers 1

preprocess.pyFile · 0.70

Calls 1

do_inductFunction · 0.70

Tested by

no test coverage detected