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

Function do_generate

utils/src/experiment/experiments.py:88–128  ·  view source on GitHub ↗
(
    genclass: Type[PPTCrew],
    setting: str,
    model_identifier: str,
    debug: bool,
    ppt_folder: str,
    thread_id: int,
    num_slides: int = 12,
)

Source from the content-addressed store, hash-verified

86
87
88def 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
131def generate_pres(

Callers

nothing calls this directly

Calls 10

set_rundirMethod · 0.95
ConfigClass · 0.90
get_text_modelFunction · 0.90
ImageLablerClass · 0.90
older_thanFunction · 0.90
from_fileMethod · 0.45
caption_imagesMethod · 0.45
loadMethod · 0.45
set_referenceMethod · 0.45
generate_presMethod · 0.45

Tested by

no test coverage detected