Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -425,7 +425,7 @@ with gr.Blocks(title="NanoBanana Gemini Image Generator V9", theme=gr.themes.Sof
|
|
| 425 |
dataset_folder: str = "",
|
| 426 |
custom_filename: str = "",
|
| 427 |
return_image_data: bool = False
|
| 428 |
-
):
|
| 429 |
"""API endpoint for image generation"""
|
| 430 |
try:
|
| 431 |
if not prompt:
|
|
@@ -509,52 +509,27 @@ with gr.Blocks(title="NanoBanana Gemini Image Generator V9", theme=gr.themes.Sof
|
|
| 509 |
return {"error": str(e), "success": False}
|
| 510 |
|
| 511 |
# API専用エンドポイントとして公開(UIには表示されない)
|
| 512 |
-
|
| 513 |
-
fn=api_generate,
|
| 514 |
-
inputs=[
|
| 515 |
-
gr.Textbox(label="prompt"),
|
| 516 |
-
gr.Textbox(label="gemini_api_key"),
|
| 517 |
-
gr.Textbox(label="model", default="gemini-2.5-flash-image"),
|
| 518 |
-
gr.Textbox(label="size", default="1024x1024"),
|
| 519 |
-
gr.Textbox(label="style", default="Default"),
|
| 520 |
-
gr.Checkbox(label="save_to_dataset", default=True),
|
| 521 |
-
gr.Textbox(label="dataset_folder", default=""),
|
| 522 |
-
gr.Textbox(label="custom_filename", default=""),
|
| 523 |
-
gr.Checkbox(label="return_image_data", default=False)
|
| 524 |
-
],
|
| 525 |
-
outputs=gr.JSON(),
|
| 526 |
-
api_name="generate"
|
| 527 |
-
)
|
| 528 |
|
| 529 |
# Health check endpoint
|
| 530 |
-
def api_health():
|
| 531 |
"""Health check endpoint"""
|
| 532 |
from datetime import datetime
|
| 533 |
return {
|
| 534 |
"status": "healthy",
|
| 535 |
-
"timestamp": datetime.utcnow().isoformat(),
|
| 536 |
"version": "9.0.0",
|
| 537 |
"available_models": AVAILABLE_MODELS
|
| 538 |
}
|
| 539 |
|
| 540 |
-
|
| 541 |
-
fn=api_health,
|
| 542 |
-
inputs=[],
|
| 543 |
-
outputs=gr.JSON(),
|
| 544 |
-
api_name="health"
|
| 545 |
-
)
|
| 546 |
|
| 547 |
# Models endpoint
|
| 548 |
-
def api_models():
|
| 549 |
"""Get available models"""
|
| 550 |
return {"models": AVAILABLE_MODELS}
|
| 551 |
|
| 552 |
-
|
| 553 |
-
fn=api_models,
|
| 554 |
-
inputs=[],
|
| 555 |
-
outputs=gr.JSON(),
|
| 556 |
-
api_name="models"
|
| 557 |
-
)
|
| 558 |
|
| 559 |
# Footer
|
| 560 |
gr.Markdown(
|
|
|
|
| 425 |
dataset_folder: str = "",
|
| 426 |
custom_filename: str = "",
|
| 427 |
return_image_data: bool = False
|
| 428 |
+
) -> dict:
|
| 429 |
"""API endpoint for image generation"""
|
| 430 |
try:
|
| 431 |
if not prompt:
|
|
|
|
| 509 |
return {"error": str(e), "success": False}
|
| 510 |
|
| 511 |
# API専用エンドポイントとして公開(UIには表示されない)
|
| 512 |
+
gr.api(api_generate, api_name="generate")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
|
| 514 |
# Health check endpoint
|
| 515 |
+
def api_health() -> dict:
|
| 516 |
"""Health check endpoint"""
|
| 517 |
from datetime import datetime
|
| 518 |
return {
|
| 519 |
"status": "healthy",
|
| 520 |
+
"timestamp": datetime.utcnow().isoformat() + "Z",
|
| 521 |
"version": "9.0.0",
|
| 522 |
"available_models": AVAILABLE_MODELS
|
| 523 |
}
|
| 524 |
|
| 525 |
+
gr.api(api_health, api_name="health")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
# Models endpoint
|
| 528 |
+
def api_models() -> dict:
|
| 529 |
"""Get available models"""
|
| 530 |
return {"models": AVAILABLE_MODELS}
|
| 531 |
|
| 532 |
+
gr.api(api_models, api_name="models")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
| 534 |
# Footer
|
| 535 |
gr.Markdown(
|