Spaces:
Sleeping
Sleeping
Update ui
Browse files
app.py
CHANGED
|
@@ -89,7 +89,6 @@ def validate_inputs(pdf_file, logo_file, aff_logo_file, text_model, vision_model
|
|
| 89 |
|
| 90 |
def generate_poster(pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key, anthropic_base_url, openai_base_url, progress=gr.Progress()):
|
| 91 |
try:
|
| 92 |
-
# Set API keys and base URLs first
|
| 93 |
set_api_keys(anthropic_key, openai_key, anthropic_base_url, openai_base_url)
|
| 94 |
|
| 95 |
error_msg = validate_inputs(pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key, anthropic_base_url, openai_base_url)
|
|
@@ -185,7 +184,18 @@ Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"""
|
|
| 185 |
return None, error_msg
|
| 186 |
|
| 187 |
|
| 188 |
-
with gr.Blocks(title="PosterGen"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
gr.HTML("""
|
| 191 |
<div style="text-align: center; margin-bottom: 30px;">
|
|
@@ -197,8 +207,7 @@ with gr.Blocks(title="PosterGen") as demo:
|
|
| 197 |
""")
|
| 198 |
|
| 199 |
with gr.Row():
|
| 200 |
-
|
| 201 |
-
with gr.Column(scale=1):
|
| 202 |
gr.Markdown("### π Upload Files")
|
| 203 |
|
| 204 |
pdf_file = gr.File(label="PDF Paper", file_types=[".pdf"], type="binary")
|
|
@@ -207,36 +216,36 @@ with gr.Blocks(title="PosterGen") as demo:
|
|
| 207 |
logo_file = gr.File(label="Conference Logo", file_types=["image"], type="binary")
|
| 208 |
aff_logo_file = gr.File(label="Affiliation Logo", file_types=["image"], type="binary")
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
with gr.Row():
|
| 216 |
-
anthropic_key = gr.Textbox(
|
| 217 |
-
label="Anthropic API Key",
|
| 218 |
-
type="password",
|
| 219 |
-
placeholder="sk-ant-...",
|
| 220 |
-
info="Required for Claude models"
|
| 221 |
-
)
|
| 222 |
-
openai_key = gr.Textbox(
|
| 223 |
-
label="OpenAI API Key",
|
| 224 |
-
type="password",
|
| 225 |
-
placeholder="sk-...",
|
| 226 |
-
info="Required for GPT models"
|
| 227 |
-
)
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
gr.Markdown("### π€ Model Settings")
|
| 242 |
|
|
@@ -250,16 +259,18 @@ with gr.Blocks(title="PosterGen") as demo:
|
|
| 250 |
poster_width = gr.Number(value=54, minimum=20, maximum=100, step=0.1, label="Width (inches)")
|
| 251 |
poster_height = gr.Number(value=36, minimum=10, maximum=60, step=0.1, label="Height (inches)")
|
| 252 |
|
| 253 |
-
generate_btn = gr.Button("π Generate Poster", variant="primary", size="lg")
|
| 254 |
|
| 255 |
-
|
| 256 |
-
with gr.Column(scale=1):
|
| 257 |
gr.Markdown("### π Status")
|
| 258 |
status_output = gr.Textbox(label="Generation Status", placeholder="Click 'Generate Poster' to start...", lines=6)
|
| 259 |
|
| 260 |
gr.Markdown("### π₯ Download")
|
| 261 |
download_file = gr.File(label="Download Package")
|
| 262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
def generate_and_display(*args):
|
| 264 |
download_file_result, status_result = generate_poster(*args)
|
| 265 |
return download_file_result, status_result
|
|
|
|
| 89 |
|
| 90 |
def generate_poster(pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key, anthropic_base_url, openai_base_url, progress=gr.Progress()):
|
| 91 |
try:
|
|
|
|
| 92 |
set_api_keys(anthropic_key, openai_key, anthropic_base_url, openai_base_url)
|
| 93 |
|
| 94 |
error_msg = validate_inputs(pdf_file, logo_file, aff_logo_file, text_model, vision_model, poster_width, poster_height, anthropic_key, openai_key, anthropic_base_url, openai_base_url)
|
|
|
|
| 184 |
return None, error_msg
|
| 185 |
|
| 186 |
|
| 187 |
+
with gr.Blocks(title="PosterGen", css="""
|
| 188 |
+
.gradio-column {
|
| 189 |
+
margin-left: 10px !important;
|
| 190 |
+
margin-right: 10px !important;
|
| 191 |
+
}
|
| 192 |
+
.gradio-column:first-child {
|
| 193 |
+
margin-left: 0 !important;
|
| 194 |
+
}
|
| 195 |
+
.gradio-column:last-child {
|
| 196 |
+
margin-right: 0 !important;
|
| 197 |
+
}
|
| 198 |
+
""") as demo:
|
| 199 |
|
| 200 |
gr.HTML("""
|
| 201 |
<div style="text-align: center; margin-bottom: 30px;">
|
|
|
|
| 207 |
""")
|
| 208 |
|
| 209 |
with gr.Row():
|
| 210 |
+
with gr.Column(scale=1, variant="panel"):
|
|
|
|
| 211 |
gr.Markdown("### π Upload Files")
|
| 212 |
|
| 213 |
pdf_file = gr.File(label="PDF Paper", file_types=[".pdf"], type="binary")
|
|
|
|
| 216 |
logo_file = gr.File(label="Conference Logo", file_types=["image"], type="binary")
|
| 217 |
aff_logo_file = gr.File(label="Affiliation Logo", file_types=["image"], type="binary")
|
| 218 |
|
| 219 |
+
with gr.Column(scale=1, variant="panel"):
|
| 220 |
+
with gr.Group():
|
| 221 |
+
gr.Markdown("### π API Keys")
|
| 222 |
+
gr.Markdown("β οΈ Keys are processed securely and not stored")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
+
with gr.Row():
|
| 225 |
+
anthropic_key = gr.Textbox(
|
| 226 |
+
label="Anthropic API Key",
|
| 227 |
+
type="password",
|
| 228 |
+
placeholder="sk-ant-...",
|
| 229 |
+
info="Required for Claude models"
|
| 230 |
+
)
|
| 231 |
+
openai_key = gr.Textbox(
|
| 232 |
+
label="OpenAI API Key",
|
| 233 |
+
type="password",
|
| 234 |
+
placeholder="sk-...",
|
| 235 |
+
info="Required for GPT models"
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
with gr.Row():
|
| 239 |
+
anthropic_base_url = gr.Textbox(
|
| 240 |
+
label="Anthropic Base URL (Optional)",
|
| 241 |
+
placeholder="https://api.anthropic.com",
|
| 242 |
+
info="Set the base url for compatible API services"
|
| 243 |
+
)
|
| 244 |
+
openai_base_url = gr.Textbox(
|
| 245 |
+
label="OpenAI Base URL (Optional)",
|
| 246 |
+
placeholder="https://api.openai.com/v1",
|
| 247 |
+
info="Set the base url for compatible API services"
|
| 248 |
+
)
|
| 249 |
|
| 250 |
gr.Markdown("### π€ Model Settings")
|
| 251 |
|
|
|
|
| 259 |
poster_width = gr.Number(value=54, minimum=20, maximum=100, step=0.1, label="Width (inches)")
|
| 260 |
poster_height = gr.Number(value=36, minimum=10, maximum=60, step=0.1, label="Height (inches)")
|
| 261 |
|
|
|
|
| 262 |
|
| 263 |
+
with gr.Column(scale=1, variant="panel"):
|
|
|
|
| 264 |
gr.Markdown("### π Status")
|
| 265 |
status_output = gr.Textbox(label="Generation Status", placeholder="Click 'Generate Poster' to start...", lines=6)
|
| 266 |
|
| 267 |
gr.Markdown("### π₯ Download")
|
| 268 |
download_file = gr.File(label="Download Package")
|
| 269 |
|
| 270 |
+
# Generate button spanning full width
|
| 271 |
+
with gr.Row():
|
| 272 |
+
generate_btn = gr.Button("π Generate Poster", variant="primary", size="lg")
|
| 273 |
+
|
| 274 |
def generate_and_display(*args):
|
| 275 |
download_file_result, status_result = generate_poster(*args)
|
| 276 |
return download_file_result, status_result
|