Spaces:
Running
Running
Update HF demo
Browse files- .gitattributes +1 -1
- app.py +8 -47
- fonts/.DS_Store +0 -0
- postergen-logo.png β fonts/Arial.ttf +2 -2
- fonts/HelveticaNeue.ttf +3 -0
- src/agents/renderer.py +5 -5
.gitattributes
CHANGED
@@ -33,4 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
-
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.ttf filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -149,16 +149,11 @@ def generate_poster(pdf_file, logo_file, aff_logo_file, text_model, vision_model
|
|
149 |
|
150 |
if final_state.get("errors"):
|
151 |
error_details = "; ".join(final_state["errors"])
|
152 |
-
return None,
|
153 |
|
154 |
output_dir = Path(final_state["output_dir"])
|
155 |
poster_name = final_state.get("poster_name", "poster")
|
156 |
|
157 |
-
poster_image_path = None
|
158 |
-
png_path = output_dir / f"{poster_name}.png"
|
159 |
-
if png_path.exists():
|
160 |
-
poster_image_path = str(png_path)
|
161 |
-
|
162 |
progress(0.9, desc="Packaging results...")
|
163 |
|
164 |
zip_path = job_dir / f"{poster_name}_output.zip"
|
@@ -169,15 +164,6 @@ def generate_poster(pdf_file, logo_file, aff_logo_file, text_model, vision_model
|
|
169 |
arcname = file_path.relative_to(output_dir)
|
170 |
zipf.write(file_path, arcname)
|
171 |
|
172 |
-
json_files_dict = {}
|
173 |
-
content_dir = output_dir / "content"
|
174 |
-
if content_dir.exists():
|
175 |
-
for json_file in content_dir.glob("*.json"):
|
176 |
-
try:
|
177 |
-
with open(json_file, 'r', encoding='utf-8') as f:
|
178 |
-
json_files_dict[json_file.name] = json.load(f)
|
179 |
-
except Exception:
|
180 |
-
continue
|
181 |
|
182 |
progress(1.0, desc="β
Completed!")
|
183 |
|
@@ -188,33 +174,18 @@ Output: {output_dir.name}
|
|
188 |
Package: {zip_path.name}
|
189 |
Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"""
|
190 |
|
191 |
-
return
|
192 |
|
193 |
except Exception as e:
|
194 |
error_msg = f"β Error: {str(e)}\n\n{traceback.format_exc()}"
|
195 |
-
return None,
|
196 |
|
197 |
-
def create_json_display(json_files_dict):
|
198 |
-
if not json_files_dict:
|
199 |
-
return "No files available"
|
200 |
-
|
201 |
-
html_content = "<div style='font-family: monospace;'>"
|
202 |
-
for filename, content in json_files_dict.items():
|
203 |
-
html_content += f"""
|
204 |
-
<details style='margin-bottom: 10px; border: 1px solid #ddd; border-radius: 5px; padding: 10px;'>
|
205 |
-
<summary style='cursor: pointer; font-weight: bold; margin-bottom: 10px;'>{filename}</summary>
|
206 |
-
<pre style='background: #f5f5f5; padding: 10px; border-radius: 3px; overflow: auto; max-height: 300px;'>{json.dumps(content, indent=2, ensure_ascii=False)}</pre>
|
207 |
-
</details>
|
208 |
-
"""
|
209 |
-
html_content += "</div>"
|
210 |
-
return html_content
|
211 |
|
212 |
with gr.Blocks(title="PosterGen") as demo:
|
213 |
|
214 |
gr.HTML("""
|
215 |
<div style="text-align: center; margin-bottom: 30px;">
|
216 |
-
<h1 style="
|
217 |
-
<img src="file/postergen-logo.png" alt="PosterGen Logo" style="height: 1.5em; margin-right: 0.5em;" />
|
218 |
PosterGen
|
219 |
</h1>
|
220 |
<p style="font-size: 18px; color: #666;">π¨ Generate design-aware academic posters from PDF papers</p>
|
@@ -268,28 +239,18 @@ with gr.Blocks(title="PosterGen") as demo:
|
|
268 |
gr.Markdown("### π Status")
|
269 |
status_output = gr.Textbox(label="Generation Status", placeholder="Click 'Generate Poster' to start...", lines=6)
|
270 |
|
271 |
-
gr.Markdown("### π Meta Files")
|
272 |
-
json_output = gr.HTML(label="JSON Files")
|
273 |
-
|
274 |
-
gr.Markdown("### πΌοΈ Preview")
|
275 |
-
poster_image = gr.Image(label="Generated Poster", type="filepath")
|
276 |
-
|
277 |
gr.Markdown("### π₯ Download")
|
278 |
download_file = gr.File(label="Download Package")
|
279 |
|
280 |
-
def update_json_display(json_files_dict):
|
281 |
-
return create_json_display(json_files_dict)
|
282 |
-
|
283 |
def generate_and_display(*args):
|
284 |
-
|
285 |
-
|
286 |
-
return poster_image_result, download_file_result, status_result, json_display
|
287 |
|
288 |
generate_btn.click(
|
289 |
fn=generate_and_display,
|
290 |
inputs=[pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key],
|
291 |
-
outputs=[
|
292 |
)
|
293 |
|
294 |
if __name__ == "__main__":
|
295 |
-
demo.launch(server_name="0.0.0.0", server_port=7860
|
|
|
149 |
|
150 |
if final_state.get("errors"):
|
151 |
error_details = "; ".join(final_state["errors"])
|
152 |
+
return None, f"β Generation errors: {error_details}"
|
153 |
|
154 |
output_dir = Path(final_state["output_dir"])
|
155 |
poster_name = final_state.get("poster_name", "poster")
|
156 |
|
|
|
|
|
|
|
|
|
|
|
157 |
progress(0.9, desc="Packaging results...")
|
158 |
|
159 |
zip_path = job_dir / f"{poster_name}_output.zip"
|
|
|
164 |
arcname = file_path.relative_to(output_dir)
|
165 |
zipf.write(file_path, arcname)
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
progress(1.0, desc="β
Completed!")
|
169 |
|
|
|
174 |
Package: {zip_path.name}
|
175 |
Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"""
|
176 |
|
177 |
+
return str(zip_path), success_msg
|
178 |
|
179 |
except Exception as e:
|
180 |
error_msg = f"β Error: {str(e)}\n\n{traceback.format_exc()}"
|
181 |
+
return None, error_msg
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
with gr.Blocks(title="PosterGen") as demo:
|
185 |
|
186 |
gr.HTML("""
|
187 |
<div style="text-align: center; margin-bottom: 30px;">
|
188 |
+
<h1 style="margin-bottom: 10px;">
|
|
|
189 |
PosterGen
|
190 |
</h1>
|
191 |
<p style="font-size: 18px; color: #666;">π¨ Generate design-aware academic posters from PDF papers</p>
|
|
|
239 |
gr.Markdown("### π Status")
|
240 |
status_output = gr.Textbox(label="Generation Status", placeholder="Click 'Generate Poster' to start...", lines=6)
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
gr.Markdown("### π₯ Download")
|
243 |
download_file = gr.File(label="Download Package")
|
244 |
|
|
|
|
|
|
|
245 |
def generate_and_display(*args):
|
246 |
+
download_file_result, status_result = generate_poster(*args)
|
247 |
+
return download_file_result, status_result
|
|
|
248 |
|
249 |
generate_btn.click(
|
250 |
fn=generate_and_display,
|
251 |
inputs=[pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key],
|
252 |
+
outputs=[download_file, status_output]
|
253 |
)
|
254 |
|
255 |
if __name__ == "__main__":
|
256 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
fonts/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
postergen-logo.png β fonts/Arial.ttf
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:413c78f91bd39e134f3c0bb204b1d5a90f29df9efddc8fd26950a178058d5d74
|
3 |
+
size 367112
|
fonts/HelveticaNeue.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c8390dd24ab15dec3b439a1560c0e8928ea6bbf9f6db0aa42c9ace2cbee7e08
|
3 |
+
size 794452
|
src/agents/renderer.py
CHANGED
@@ -42,12 +42,12 @@ class Renderer:
|
|
42 |
output_path = Path(state["output_dir"]) / f"{state['poster_name']}.pptx"
|
43 |
self._render_presentation(state, output_path)
|
44 |
|
45 |
-
# convert to png if possible
|
46 |
-
png_path = self._convert_to_png(output_path)
|
47 |
|
48 |
-
log_agent_success(self.name, f"rendered poster: {output_path}")
|
49 |
-
if png_path:
|
50 |
-
|
51 |
|
52 |
except Exception as e:
|
53 |
log_agent_error(self.name, f"rendering failed: {e}")
|
|
|
42 |
output_path = Path(state["output_dir"]) / f"{state['poster_name']}.pptx"
|
43 |
self._render_presentation(state, output_path)
|
44 |
|
45 |
+
# # convert to png if possible
|
46 |
+
# png_path = self._convert_to_png(output_path)
|
47 |
|
48 |
+
# log_agent_success(self.name, f"rendered poster: {output_path}")
|
49 |
+
# if png_path:
|
50 |
+
# log_agent_success(self.name, f"generated preview: {png_path}")
|
51 |
|
52 |
except Exception as e:
|
53 |
log_agent_error(self.name, f"rendering failed: {e}")
|