Budi Mulyo commited on
Commit ·
eae6d79
1
Parent(s): 697ca25
add app.py
Browse files
app.py
CHANGED
|
@@ -21,6 +21,7 @@ import datetime as _dt
|
|
| 21 |
import json
|
| 22 |
import uuid
|
| 23 |
from pathlib import Path
|
|
|
|
| 24 |
|
| 25 |
import gradio as gr
|
| 26 |
from PIL import Image, ImageDraw, ImageFont
|
|
@@ -39,6 +40,9 @@ PLACEHOLDER_COLOR = (24, 24, 32) # dark bluish‑gray bg
|
|
| 39 |
TEXT_COLOR = (220, 220, 230)
|
| 40 |
TMP_DIR = Path("/tmp")
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# -----------------------------------------------------------------------------
|
| 44 |
# Helper functions
|
|
@@ -63,6 +67,11 @@ def _timestamp() -> str:
|
|
| 63 |
return _dt.datetime.utcnow().isoformat(timespec="seconds") + "Z"
|
| 64 |
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# -----------------------------------------------------------------------------
|
| 67 |
# Core generator (stub – replace with your own AI calls)
|
| 68 |
# -----------------------------------------------------------------------------
|
|
@@ -151,11 +160,11 @@ def generate_prototype(prompt: str, reference_image: Image.Image | None, style:
|
|
| 151 |
|
| 152 |
def build_ui() -> gr.Blocks:
|
| 153 |
with gr.Blocks(title="SIXR Prompt‑to‑Prototype Studio") as demo:
|
| 154 |
-
gr.Markdown(
|
| 155 |
-
|
| 156 |
-
"
|
| 157 |
-
|
| 158 |
-
|
| 159 |
|
| 160 |
# --------------------------- Inputs ----------------------------------
|
| 161 |
with gr.Row():
|
|
|
|
| 21 |
import json
|
| 22 |
import uuid
|
| 23 |
from pathlib import Path
|
| 24 |
+
import os
|
| 25 |
|
| 26 |
import gradio as gr
|
| 27 |
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
| 40 |
TEXT_COLOR = (220, 220, 230)
|
| 41 |
TMP_DIR = Path("/tmp")
|
| 42 |
|
| 43 |
+
# It's good practice to load secrets from environment variables.
|
| 44 |
+
# On Hugging Face Spaces, you can set these in the repository settings.
|
| 45 |
+
ACCESS_TOKEN = os.environ.get("HF_TOKEN") # Or whatever you named your secret
|
| 46 |
|
| 47 |
# -----------------------------------------------------------------------------
|
| 48 |
# Helper functions
|
|
|
|
| 67 |
return _dt.datetime.utcnow().isoformat(timespec="seconds") + "Z"
|
| 68 |
|
| 69 |
|
| 70 |
+
def read_readme():
|
| 71 |
+
with open("README.md", "r") as f:
|
| 72 |
+
return f.read()
|
| 73 |
+
|
| 74 |
+
|
| 75 |
# -----------------------------------------------------------------------------
|
| 76 |
# Core generator (stub – replace with your own AI calls)
|
| 77 |
# -----------------------------------------------------------------------------
|
|
|
|
| 160 |
|
| 161 |
def build_ui() -> gr.Blocks:
|
| 162 |
with gr.Blocks(title="SIXR Prompt‑to‑Prototype Studio") as demo:
|
| 163 |
+
gr.Markdown(read_readme())
|
| 164 |
+
if ACCESS_TOKEN:
|
| 165 |
+
gr.Markdown("Your access token is configured!")
|
| 166 |
+
else:
|
| 167 |
+
gr.Markdown("Access token not found. Set it in your Space secrets.")
|
| 168 |
|
| 169 |
# --------------------------- Inputs ----------------------------------
|
| 170 |
with gr.Row():
|