diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..d4ed3f92241c5204b808d9e7a15555b2b18cfee7 --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +# Hugging Face Space -> Settings -> Variables +GROUNDING_BACKEND=zerogpu +GROUNDING_MODEL_REPO=XPENG-AI/GroundingPI-4B +GROUNDING_MODEL_REVISION=REPLACE_WITH_40_CHARACTER_MODEL_COMMIT_SHA +GROUNDING_MAX_TOKENS=1024 +GROUNDING_GPU_SECONDS=120 + +# For a private/gated model, put HF_TOKEN in Settings -> Secrets, not this file. +# Local CUDA test alternative: unset REPO/REVISION and set GROUNDING_MODEL_PATH. +# HTTP rollback: GROUNDING_BACKEND=http and your approved GROUNDING_API_BASE. diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..eb6071123359b58369237ca6ab07902bd8f79379 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,24 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +assets/Manrope-variable.ttf filter=lfs diff=lfs merge=lfs -text +cases/dense/dense-01-o365_bbox_gt50_00009110.jpg filter=lfs diff=lfs merge=lfs -text +cases/dense/dense-02-o365_bbox_gt50_00004676.jpg filter=lfs diff=lfs merge=lfs -text +cases/dense/dense-03-o365_bbox_gt50_00011992.jpg filter=lfs diff=lfs merge=lfs -text +cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg filter=lfs diff=lfs merge=lfs -text +cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg filter=lfs diff=lfs merge=lfs -text +cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg filter=lfs diff=lfs merge=lfs -text +cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg filter=lfs diff=lfs merge=lfs -text +cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg filter=lfs diff=lfs merge=lfs -text +cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg filter=lfs diff=lfs merge=lfs -text +cases/layout/layout-01-layout_doclaynet_train_16966.jpg filter=lfs diff=lfs merge=lfs -text +cases/layout/layout-02-layout_doclaynet_train_20356.jpg filter=lfs diff=lfs merge=lfs -text +cases/layout/layout-03-layout_doclaynet_train_3435.jpg filter=lfs diff=lfs merge=lfs -text +cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg filter=lfs diff=lfs merge=lfs -text +cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg filter=lfs diff=lfs merge=lfs -text +cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg filter=lfs diff=lfs merge=lfs -text +cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg filter=lfs diff=lfs merge=lfs -text +cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg filter=lfs diff=lfs merge=lfs -text +cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg filter=lfs diff=lfs merge=lfs -text +cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg filter=lfs diff=lfs merge=lfs -text +cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..edae624468ded97e1b2ecb6d4c16da6ed0e44513 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.venv/ +__pycache__/ +*.pyc +.env +.env.* +!.env.example +.cache/ +*.log +*.zip +*.safetensors +*.bin +model/ +models/ +verification/ diff --git a/LICENSE_PENDING.md b/LICENSE_PENDING.md new file mode 100644 index 0000000000000000000000000000000000000000..73ea9c2bb55d4f2d5ab5200536b2aca04f052d9f --- /dev/null +++ b/LICENSE_PENDING.md @@ -0,0 +1,9 @@ +# License and asset review pending + +This preparation does not grant a new project-wide license. The rights owner must +approve code distribution, model access, example-image reuse and XPENG branding +before public release. This notice is not a LICENSE file. Existing third-party +notices, including the bundled Manrope SIL Open Font License, remain applicable. + +Private upload also requires authorization to transfer these assets to the hosting +provider. Do not infer image redistribution rights from a training-pool path. diff --git a/README.md b/README.md index a537ba81f62f10f0bcc2e3fe270fa1b0df660348..6a09bc907718a6747c71eeee312307aabd11b3eb 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,125 @@ --- -title: GroundingPI 4B -emoji: 🚀 -colorFrom: red +title: GroundingPI +emoji: 🎯 +colorFrom: purple colorTo: green sdk: gradio -sdk_version: 6.27.0 -python_version: '3.12' -app_file: app.py +sdk_version: 5.49.1 +python_version: 3.12.12 +app_file: space_app.py pinned: false license: cc-by-nc-sa-4.0 -short_description: GroundingPI-4B +models: + - XPENG-AI/GroundingPI-4B --- -Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference +# GroundingPI · Precise Visual Grounding + +**From language to spatial evidence.** + +An interactive research workspace for locating objects, reading text and exploring +interaction targets. Choose a task, provide an image and a prompt, then inspect +the model's predictions directly on the image. + +Model: [XPENG-AI/GroundingPI-4B](https://huggingface.co/XPENG-AI/GroundingPI-4B). +This private preview is hosted at `FanLR/GroundingPI-4B`. HF ZeroGPU inference +acceptance remains pending. Licensing and asset permissions are pending: +see [license status](LICENSE_PENDING.md). + +## Explore visual evidence + +| Task | Interaction | +| --- | --- | +| Grounding | Enter object categories separated by commas | +| Dense | Localize instances in crowded or small-object scenes | +| Referring | Describe a particular object or person | +| Dense Point | Locate multiple targets as image-relative points | +| Referring Point | Identify a target position from a referring expression | +| Visual Prompt | Supply an input region as a visual condition | +| OCR | Read text with its associated location | +| Layout | Localize document regions | +| GUI | Point to an interface target; no UI action is executed | + +1. Select a task and a curated example, or upload your own image. +2. Write the request in the prompt field and select **Run Grounding**. +3. Select a category to focus individual instances. Use next/previous, zoom and + fit-to-canvas; press Escape to leave focus. +4. Inspect the compiled prompt, normalized coordinates and raw GAM tokens. + +Predictions are drawn directly on the canvas. There is no original/model/reference +view switch. Large regions use unfilled outlines; labels avoid obscuring small +targets. The renderer does not delete, merge or relocate predictions for appearance. +Visual Prompt's marked region is an **input condition**, not a model prediction. + +Examples are qualitative scenarios selected from training pools, not a held-out +benchmark. An operational demo is not evidence of a reported accuracy or speedup. + +## Run locally + +Use a separate Python 3.12 environment: + +```bash +python3 -m venv .venv +.venv/bin/python -m pip install -r requirements.txt +.venv/bin/python -m pip check +.venv/bin/python -m unittest discover -s tests -v +.venv/bin/python scripts/verify_ui.py +bash scripts/start.sh +``` + +Without a model source, the page is an explicitly disconnected UI preview. +For a compatible NVIDIA GPU, set `GROUNDING_MODEL_PATH=/absolute/model/directory` +before startup. Do not also set `GROUNDING_MODEL_REPO`. Local execution does not +automatically allocate Hugging Face GPU resources. + +The model is custom Oxygen-VL-v3 with a Kimi-K3 vision component, not a standard +Qwen3-VL package. Keep the checkpoint's tokenizer, processor, template and custom +code. Native generation uses BF16, SDPA and greedy decoding; vLLM/SGLang are not +required for this Space runtime. + +## Deploy a private Hugging Face Space + +Follow [the deployment guide](docs/HF_SPACE_DEPLOYMENT.md). Upload the contents of +this directory to a **Gradio Space**, not the parent release workspace and not a ZIP. + +Configure `GROUNDING_BACKEND=zerogpu`, `GROUNDING_MODEL_REPO` and +`GROUNDING_MODEL_REVISION` with the reviewed full 40-character model commit SHA. +Store a scoped read-only `HF_TOKEN` as a Space **Secret** for private weights. +Do not put credentials in code or Variables. + +The model is initialized once at process startup. ZeroGPU leases GPU compute for +inference; it is not an instruction to reload model weights on every request. +See [runtime design](docs/ZEROGPU_DEPLOYMENT.md). + +## Verification boundary + +The existing PPU implementation has completed real generation and UI checks. +This package includes automated regressions for prompts, parsing, stale-result +clearing, error recovery and overlay geometry. **NVIDIA / HF ZeroGPU acceptance +remains pending.** See [verification](docs/VERIFICATION.md). + +The default queue is single-concurrency with at most eight waiting requests. +Uploads are limited to 30 MiB / 50 megapixels, and input plus output to 8,192 tokens. +The default output budget is 1,024 tokens. Truncation is reported rather than +presented as a complete prediction. Failed calls never fall back to annotations. + +## Project map + +```text +space_app.py Startup and queue +app.py + assets/ Canvas, controls and presentation +grounding_demo/ Native inference, prompt compiler, GAM parser and overlays +cases/ + data/ Qualitative examples and provenance metadata +scripts/ Launch, package checks and regression helpers +tests/ Automated behavior and integrity checks +docs/ Deployment, runtime and verification notes +``` + +## Responsible release + +Do not upload confidential or personal images without permission. The demo is not +a safety-critical controller, and its coordinates are not calibrated robot/world +coordinates. Source data licenses, example redistribution, XPENG branding and final +model/code licenses require owner review. Font and asset notices are in +[assets/SOURCES.md](assets/SOURCES.md). Paper citation and approved benchmark results +will be added after confirmation; they are not invented in this release candidate. diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..f853ceecaece9891013ef4dcfcae40147d293cad --- /dev/null +++ b/app.py @@ -0,0 +1,515 @@ +from __future__ import annotations + +import base64 +import html +import json +import os +from io import BytesIO + +import gradio as gr +from PIL import Image + +from grounding_demo.catalog import ROOT, load_cases +from grounding_demo.client import GroundingClient +from grounding_demo.console import TASK_HELP, compile_query, metrics_html, query_from_prompt, targets_html, task_help_html +from grounding_demo.protocol import parse_gam, parse_reference_boxes +from grounding_demo.render import draw_primitives + +ROUTE_META = { + "grounding": ("Grounding", "Open-vocabulary object localization"), + "dense": ("Dense", "Dense instance localization"), + "referring": ("Referring", "Language-guided referring"), + "dense_point": ("Dense Point", "Dense point prediction"), + "refer_point": ("Referring Point", "Relational and affordance pointing"), + "visual_prompt": ("Visual Prompt", "Exemplar-guided localization"), + "ocr": ("OCR", "Text recognition and localization"), + "layout": ("Layout", "Document structure analysis"), + "gui": ("GUI", "Interface element grounding"), +} +CASES = load_cases() +BY_ID = {row["id"]: row for row in CASES} +BY_ROUTE = {route: [row for row in CASES if row["route"] == route] for route in ROUTE_META} + + +def route_choices(route): + return [(row["title"], row["id"]) for row in BY_ROUTE[route]] + + +def gallery_items(route): + return [ + (str(ROOT / row["image"]), case_caption(row, i)) + for i, row in enumerate(BY_ROUTE[route], 1) + ] + + +def case_caption(row, index): + return f"{ROUTE_META[row['route']][0]} {index:02d}" + + +def input_view(path, canonical, route): + """Show only user-supplied reference boxes; the client still receives raw path.""" + references = parse_reference_boxes(canonical) if route == "visual_prompt" else () + if not references or not path: + return path + with Image.open(path) as source: + return draw_primitives(source, (), references, "INPUT · example boxes") + + +def query_update(canonical, route): + return gr.update(value=query_from_prompt(canonical, route), placeholder=TASK_HELP[route][3]) + + +def case_meta(row): + return ( + "
TRAINING SOURCE" + f"{html.escape(row['source'])}IMAGE SHA256" + f"{row.get('image_sha256', '')[:16]}" + "Curated research examples for qualitative exploration, not a held-out benchmark. Inference receives only the image and task prompt.
" + ) + + +def status_html(text, kind="ready"): + return ( + f"
" + f"{html.escape(text)}" + + ("" if kind == "busy" else "") + + "
" + ) + + +def reset_image(path, case_id, route, canonical, meta): + return ( + path, + case_id, + input_view(path, canonical, route), + query_update(canonical, route), + canonical, + meta, + metrics_html(ROUTE_META[route][0]), + targets_html([]), + "[]", + "", + status_html("Image ready · Run grounding to extract visual evidence"), + task_help_html(route), + ) + + +def load_case(case_id): + row = BY_ID[case_id] + return reset_image( + str(ROOT / row["image"]), case_id, row["route"], row["prompt"], case_meta(row) + ) + + +def change_route(route): + row = BY_ROUTE[route][0] + return ( + gr.update(choices=route_choices(route), value=row["id"]), + gr.update(value=gallery_items(route), selected_index=0), + *load_case(row["id"]), + ) + + +def choose_case(case_id): + row = BY_ID[case_id] + return gr.update(selected_index=BY_ROUTE[row["route"]].index(row)), *load_case(case_id) + + +def choose_gallery(route, evt: gr.SelectData): + index = evt.index[0] if isinstance(evt.index, tuple | list) else evt.index + row = BY_ROUTE[route][index] + return gr.update(value=row["id"]), *load_case(row["id"]) + + +def upload_image(path, route, canonical): + if not path: + raise gr.Error("Select an image to continue.") + with Image.open(path) as image: + image.verify() + return reset_image( + path, + None, + route, + canonical, + "
YOUR IMAGEUploaded image" + "Select a task and describe the visual evidence to extract.
", + ) + + +def choose_upload(path, route, canonical): + return ( + gr.update(value=None), + gr.update(selected_index=None), + *upload_image(path, route, canonical), + ) + + +def edit_query(text, route, path): + return ( + compile_query(text, route), + input_view(path, compile_query(text, route), route), + metrics_html(ROUTE_META[route][0]), + targets_html([]), + "[]", + "", + status_html("Prompt updated · Run grounding to refresh the overlay"), + ) + + +def result_bundle(path, canonical, route, raw, elapsed=None, usage=None): + parsed = parse_gam(raw, route) + items = [dict(label=p.label, coordinates=list(p.coordinates)) for p in parsed.primitives] + valid_items = items if parsed.valid else [] + image = Image.open(path).convert("RGB") + source_bytes = BytesIO() + image.save(source_bytes, format="PNG") + image_source = "data:image/png;base64," + base64.b64encode(source_bytes.getvalue()).decode() + rendered = ( + draw_primitives( + image, + parsed.primitives, + parse_reference_boxes(canonical), + ) + if parsed.valid + else image + ) + state = "Completed" + if not parsed.valid: + state = "Protocol error" + message = ( + f"Complete · {len(valid_items)} visual targets" + if parsed.valid + else "Output validation failed · " + "; ".join(parsed.errors) + ) + return dict( + image=rendered, + metrics=metrics_html(ROUTE_META[route][0], state, len(valid_items), elapsed, usage), + targets=targets_html(valid_items, image_source=image_source), + normalized=json.dumps(valid_items, ensure_ascii=False, indent=2), + raw=raw, + status=status_html( + message, "error" if not parsed.valid else "ready" + ), + ) + + +def display_bundle(bundle): + return tuple( + bundle[key] for key in ("image", "metrics", "targets", "normalized", "raw", "status") + ) + + +def inference_error(exc): + timed_out = "timeout" in type(exc).__name__.lower() + return ( + "Request timed out. Check the connection and retry; your image and prompt are preserved." + if timed_out else + "Inference unavailable. Check the connection and retry; your image and prompt are preserved." + ) + + +def run_inference(path, query_text, route): + if not path: + raise gr.Error("Choose an example or upload an image first.") + canonical = compile_query(query_text, route) + try: + raw, elapsed, usage = GroundingClient().infer(path, canonical) + bundle = result_bundle(path, canonical, route, raw, elapsed, usage) + except Exception as exc: + message = inference_error(exc) + return ( + path, + metrics_html(ROUTE_META[route][0], "API error"), + targets_html([]), + "[]", + f"{type(exc).__name__}: {exc}", + status_html(message, "error"), + ) + return display_bundle(bundle) + + +RUN_LABEL = "Run Grounding" + + +def run_inference_stream(path, query_text, route): + """Expose real request state without an opaque progress mask or synthetic steps.""" + if not path: + raise gr.Error("Choose an example or upload an image first.") + yield ( + path, + metrics_html(ROUTE_META[route][0], "Awaiting inference"), + targets_html([], pending=True), + "[]", + "", + status_html("Awaiting inference", "busy"), + gr.update(value="Grounding in progress…", interactive=False), + ) + try: + result = run_inference(path, query_text, route) + except Exception as exc: + result = ( + path, + metrics_html(ROUTE_META[route][0], "API error"), + targets_html([]), + "[]", + f"{type(exc).__name__}: {exc}", + status_html(inference_error(exc), "error"), + ) + yield (*result, gr.update(value=RUN_LABEL, interactive=True)) + + +def run_console(path, query_text, route): + for state in run_inference_stream(path, query_text, route): + yield (*state, state[-1]) + + +def service_status(): + ok, detail = GroundingClient().health() + return ( + f"
" + f"{'Inference ready' if ok else 'Inference offline'}" + f"{'Model loaded. Ready to process your image.' if ok else 'Explore examples while the inference service is unavailable.'}
" + f"
Runtime details{html.escape(detail)}
" + ) + + +CSS = (ROOT / "assets" / "paper.css").read_text(encoding="utf-8") +CSS += "\n" + (ROOT / "assets" / "original.css").read_text(encoding="utf-8") +CSS = CSS.replace( + "__MANROPE_DATA__", + base64.b64encode((ROOT / "assets" / "Manrope-variable.ttf").read_bytes()).decode(), +) +# Gradio 5 scopes css= rules inside .contain, including media-query selectors. +# Host sizing must live in head; workbench styling remains scoped. +HOST_HEAD = """""" +JS = (ROOT / "assets" / "console.js").read_text(encoding="utf-8") +LOGO = ( + "data:image/png;base64," + + base64.b64encode((ROOT / "assets" / "xpeng-logo.png").read_bytes()).decode() +) +first_route = "grounding" +first_case = BY_ROUTE[first_route][2] + +with gr.Blocks( + css=CSS, + js=JS, + head=HOST_HEAD, + title="GroundingPI · Visual Studio", + theme=gr.themes.Base(font=["Manrope", "sans-serif"], font_mono=["ui-monospace", "monospace"]), + analytics_enabled=False, +) as demo: + image_state = gr.State(str(ROOT / first_case["image"])) + case_state = gr.State(first_case["id"]) + gr.HTML( + """
+

Precise Visual Grounding

From language to spatial evidence. Explore objects, text, and interaction targets in a unified visual workspace.

+ INTERACTIVE RESEARCH DEMO +
+ """ + ) + with gr.Column(elem_id="console"): + with gr.Row(elem_id="workspace-top", equal_height=True): + with gr.Column(scale=3, min_width=280, elem_id="controls"): + gr.HTML( + """
+ +

GroundingPI

+

A visual foundation for spatial understanding.

+
""".replace("__XPENG_LOGO__", LOGO) + ) + with gr.Column(elem_id="control-settings"): + with gr.Row(elem_id="control-fields"): + gr.HTML( + """
Media Type
+ Image
""", + elem_id="media-type", + ) + route = gr.Dropdown( + [(name, key) for key, (name, _) in ROUTE_META.items()], + value=first_route, + label="Task Type", + filterable=False, + elem_id="route-select", + ) + case = gr.Dropdown( + route_choices(first_route), + value=first_case["id"], + label="Selected example", + filterable=False, + visible=False, + elem_id="case-select", + ) + upload = gr.UploadButton( + "Upload Image", file_types=["image"], type="filepath", elem_id="upload-button" + ) + with gr.Accordion("Advanced Parameters", open=False, elem_id="advanced-options"): + gr.HTML( + "
Model" + + html.escape(os.getenv("GROUNDING_MODEL", "grounding-pi-vlm")) + + "Max output tokens" + + html.escape(os.getenv("GROUNDING_MAX_TOKENS", "1024")) + + "Read-only runtime configuration. Only the current image and task prompt enter inference.
" + ) + with gr.Column(elem_id="service-panel"): + health = gr.HTML("
Checking inference service…
") + health_btn = gr.Button("Refresh connection", size="sm", elem_id="health-button") + run_btn = gr.Button(RUN_LABEL, variant="primary", elem_id="run-button") + with gr.Column(scale=7, min_width=400, elem_id="visual-stage"): + task_help = gr.HTML(task_help_html(first_route), elem_id="task-guide") + with gr.Row(elem_id="stage-toolbar"): + status = gr.HTML(status_html("Image ready"), elem_id="stage-status") + with gr.Column(elem_id="canvas-viewport"): + stage = gr.Image( + value=input_view(str(ROOT / first_case["image"]), first_case["prompt"], first_route), + type="filepath", + interactive=False, + show_label=False, + height=400, + elem_id="stage-image", + show_download_button=False, + show_fullscreen_button=False, + ) + gr.HTML( + """
+ Image canvas +
+ + 100% + + + + + +
+
""", + elem_id="canvas-chrome", + ) + with gr.Row(elem_id="query-row"): + query = gr.Textbox( + value=query_from_prompt(first_case["prompt"], first_route), + label="What would you like to locate?", + show_label=False, + lines=2, + max_lines=4, + placeholder=TASK_HELP[first_route][3], + elem_id="query-dock", + ) + gr.HTML("

Enter to run · Shift + Enter for a new line

") + mobile_run = gr.Button(RUN_LABEL, variant="primary", elem_id="mobile-run-button") + with gr.Row(elem_id="review-row", equal_height=True): + with gr.Column(scale=4, min_width=320, elem_id="sandbox-panel"): + gr.HTML( + "

Explore Examples

Curated visual scenarios
" + ) + gallery = gr.Gallery( + value=gallery_items(first_route), + columns=3, + rows=1, + height=170, + show_label=False, + allow_preview=False, + object_fit="cover", + selected_index=2, + interactive=False, + elem_id="case-gallery", + ) + with gr.Accordion("Data provenance", open=False, elem_id="source-details"): + meta = gr.HTML(case_meta(first_case)) + with gr.Column(scale=6, min_width=420, elem_id="review-summary"): + with gr.Row(elem_id="result-columns", equal_height=True): + with gr.Column(scale=4, min_width=200, elem_id="metrics-panel"): + gr.HTML("

Inference Metrics

") + metrics = gr.HTML(metrics_html(ROUTE_META[first_route][0])) + with gr.Column(scale=6, min_width=240, elem_id="sidebar"): + gr.HTML( + "

Visual Evidence

Select a category to inspect individual instances.
" + ) + with gr.Column(elem_id="targets-panel"): + targets = gr.HTML(targets_html([]), elem_id="targets-content") + gr.HTML( + "", + elem_id="detail-panel", + ) + with gr.Accordion("Prompt Console", open=True, elem_id="prompt-console"): + prompt = gr.Textbox( + value=first_case["prompt"], label="COMPILED PROMPT", lines=3, interactive=False + ) + gr.HTML( + "
Transparent inputs: only this image and compiled prompt are sent to the model. No annotations, training answers, or expected counts are included.
" + ) + with gr.Accordion("Structured Output", open=True, elem_id="output-console"): + normalized = gr.Code( + value="[]", language="json", label="PARSED COORDINATES · 0–999", interactive=False + ) + with gr.Accordion("Native Token Sequence", open=False): + raw = gr.Textbox(label="RAW GAM SPECIAL TOKENS", lines=4, interactive=False) + gr.HTML( + "" + ) + + reset_outputs = [ + image_state, + case_state, + stage, + query, + prompt, + meta, + metrics, + targets, + normalized, + raw, + status, + task_help, + ] + event_options = dict(concurrency_id="console", concurrency_limit=1, show_progress="hidden") + case.input(choose_case, case, [gallery, *reset_outputs], **event_options) + route.input(change_route, route, [case, gallery, *reset_outputs], **event_options) + gallery.select(choose_gallery, route, [case, *reset_outputs], **event_options) + upload.upload( + choose_upload, [upload, route, prompt], [case, gallery, *reset_outputs], **event_options + ) + query.input( + edit_query, + [query, route, image_state], + [prompt, stage, metrics, targets, normalized, raw, status], + trigger_mode="always_last", + **event_options, + ) + run_btn.click( + run_console, + [image_state, query, route], + [stage, metrics, targets, normalized, raw, status, run_btn, mobile_run], + **event_options, + ) + query.submit( + run_console, + [image_state, query, route], + [stage, metrics, targets, normalized, raw, status, run_btn, mobile_run], + **event_options, + ) + mobile_run.click( + run_console, [image_state, query, route], + [stage, metrics, targets, normalized, raw, status, run_btn, mobile_run], + **event_options, + ) + health_btn.click(service_status, outputs=health, show_progress="hidden") + demo.load(service_status, outputs=health, show_progress="hidden") + + +if __name__ == "__main__": + demo.queue(default_concurrency_limit=1).launch( + server_name="0.0.0.0", + server_port=int(os.getenv("DEMO_PORT", "7860")), + root_path=os.getenv("DEMO_ROOT_PATH") or None, + show_error=True, + ) diff --git a/assets/Manrope-OFL.txt b/assets/Manrope-OFL.txt new file mode 100644 index 0000000000000000000000000000000000000000..472064afc4b8dec9079fab03b8ffafb617a1b2d8 --- /dev/null +++ b/assets/Manrope-OFL.txt @@ -0,0 +1,93 @@ +Copyright 2018 The Manrope Project Authors (https://github.com/sharanda/manrope) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/Manrope-variable.ttf b/assets/Manrope-variable.ttf new file mode 100644 index 0000000000000000000000000000000000000000..659833b52c280c37a0e3be4e58c5e47d42bd913b --- /dev/null +++ b/assets/Manrope-variable.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0639be45d0af36e798172419d7bd173c4bd4f29e2b76cbb69db1d11bf8b0a40 +size 165420 diff --git a/assets/SOURCES.md b/assets/SOURCES.md new file mode 100644 index 0000000000000000000000000000000000000000..02d3d6ac13e68771c991a59afe51c1003e5c5d50 --- /dev/null +++ b/assets/SOURCES.md @@ -0,0 +1,7 @@ +# UI assets + +- `xpeng-logo.png`: unchanged asset reused from the existing Oxygen demo at `X-CG_demo/public/xpeng-logo.png`; SHA256 `ff0db78ddf8f9a122eec74e8eb79581f8e5dbc46803dddeb780a06f5ae295750`. XPENG brand ownership is unchanged. The image is not a newly drawn logo. +- `Manrope-variable.ttf`: [Google Fonts Manrope source](https://github.com/google/fonts/tree/main/ofl/manrope), SIL Open Font License bundled as `Manrope-OFL.txt`. Embedded locally to avoid font-service requests through the Fuyao proxy. +- Empty-state, close and focus marks: authored SVG geometry in `grounding_demo/console.py` and `console.js`; focus geometry is generated exclusively from validated GAM coordinates. + +Design guidance consulted: [Anthropic frontend-design](https://github.com/anthropics/skills/tree/main/skills/frontend-design) and [Impeccable](https://github.com/pbakaus/impeccable), animate/polish workflows. These are design references, not runtime dependencies. diff --git a/assets/console.js b/assets/console.js new file mode 100644 index 0000000000000000000000000000000000000000..0f03a634c76041d364ca4827fe1aa286aa21eae9 --- /dev/null +++ b/assets/console.js @@ -0,0 +1,274 @@ +() => { + // Progressive enhancement: inference and view controls work without this script. + window.groundingConsoleCleanup?.(); + const reduced = window.matchMedia('(prefers-reduced-motion: reduce)'); + const abort = new AbortController(); + const listen = (el, event, fn) => el.addEventListener(event, fn, { signal: abort.signal }); + let observer, resize, frame, interval, selected, targetRoot, image, lastSrc, lastDraw; + let waiting = false, waitStart = 0, ready = false, watchdog, instanceIndex = 0; + let zoom = 1, panX = 0, panY = 0, drag, moved = false; + const $ = s => document.querySelector(s); + const svg = (tag, attrs = {}) => { + const el = document.createElementNS('http://www.w3.org/2000/svg', tag); + Object.entries(attrs).forEach(([name, value]) => el.setAttribute(name, String(value))); + return el; + }; + function removeLayer() { + $('#stage-image .focus-layer')?.remove(); + $('#stage-image .focus-pixels')?.remove(); + $('#canvas-viewport .focus-caption')?.remove(); + lastDraw = null; + } + function clearSelection() { + selected = null; + instanceIndex = 0; + document.querySelectorAll('.target-chip[aria-pressed=true]').forEach(b => b.setAttribute('aria-pressed', 'false')); + const clear = $('.clear-focus'); + if (clear) clear.hidden = true; + removeLayer(); + const detail = $('.evidence-detail'); if (detail) detail.hidden = true; + } + function showDetail(coords) { + const detail = $('.evidence-detail'), preview = $('.detail-image'); + if (!detail || !preview || !image?.naturalWidth) return; + detail.hidden = false; + const p = coords[instanceIndex]; + const box = p.length === 4 ? p : [Math.max(0,p[0]-65), Math.max(0,p[1]-65), Math.min(999,p[0]+65), Math.min(999,p[1]+65)]; + const iw = image.naturalWidth, ih = image.naturalHeight; + const cx = (box[0]+box[2])/1998*iw, cy = (box[1]+box[3])/1998*ih; + const cw = Math.max(32,(box[2]-box[0])/999*iw*1.3), ch = Math.max(32,(box[3]-box[1])/999*ih*1.3); + const scale = Math.min(preview.clientWidth/cw, preview.clientHeight/ch, 8); + const source = $('.focus-source'); + preview.style.backgroundImage = `url(${JSON.stringify(source?.src || image.currentSrc || image.src)})`; + preview.style.backgroundSize = `${iw*scale}px ${ih*scale}px`; + preview.style.backgroundPosition = `${preview.clientWidth/2-cx*scale}px ${preview.clientHeight/2-cy*scale}px`; + $('.detail-coordinates').textContent = `Instance ${instanceIndex + 1} / ${coords.length} · [${p.join(', ')}]`; + } + function canvasTransform() { + const stage = $('#stage-image'); if (!stage) return; + const maxX = stage.clientWidth*(zoom-1)/2, maxY = stage.clientHeight*(zoom-1)/2; + panX = Math.max(-maxX,Math.min(maxX,panX)); panY = Math.max(-maxY,Math.min(maxY,panY)); + stage.style.transform = `translate(${panX}px,${panY}px) scale(${zoom})`; + $('#canvas-viewport')?.classList.toggle('is-zoomed',zoom>1); + const value = $('.zoom-value'); if (value) value.textContent = `${Math.round(zoom*100)}%`; + const out = $('[data-canvas=out]'), up = $('[data-canvas=in]'); + if (out) out.disabled = zoom<=1; if (up) up.disabled = zoom>=4; + } + function resetCanvas() { zoom=1; panX=panY=0; canvasTransform(); } + function drawSelection() { + const stage = $('#stage-image'); + if (!selected?.isConnected || !image?.complete || !image.naturalWidth || waiting) return; + let coords; + try { coords = JSON.parse(selected.dataset.coordinates); } catch { clearSelection(); return; } + if (!Array.isArray(coords) || !coords.length || !coords.every(p => [2, 4].includes(p.length) && p.every(n => Number.isFinite(n) && n >= 0 && n <= 999))) { + clearSelection(); return; + } + const rect = image.getBoundingClientRect(), outer = stage.getBoundingClientRect(); + const matrix = getComputedStyle(stage).transform; + const zoomNow = matrix === 'none' ? 1 : new DOMMatrixReadOnly(matrix).a; + const scale = Math.min(rect.width / zoomNow / image.naturalWidth, rect.height / zoomNow / image.naturalHeight); + const w = image.naturalWidth * scale, h = image.naturalHeight * scale; + if (w <= 0 || h <= 0) return; + const left = (rect.left - outer.left) / zoomNow + (rect.width / zoomNow - w) / 2; + const top = (rect.top - outer.top) / zoomNow + (rect.height / zoomNow - h) / 2; + instanceIndex = Math.max(0, Math.min(instanceIndex, coords.length - 1)); + const signature = JSON.stringify([selected.dataset.label, instanceIndex, coords, image.currentSrc, left, top, w, h]); + if (signature === lastDraw) return; + const activeAction = document.activeElement?.closest('.focus-caption button')?.dataset.instance; + removeLayer(); lastDraw = signature; + const source = $('.focus-source'); + if (source) { + const pixels = document.createElement('img'); + pixels.className = 'focus-pixels'; pixels.alt = ''; pixels.setAttribute('aria-hidden', 'true'); pixels.src = source.src; + Object.assign(pixels.style, {left: `${left}px`, top: `${top}px`, width: `${w}px`, height: `${h}px`}); + stage.append(pixels); + } + const layer = svg('svg', { viewBox: `0 0 ${w} ${h}`, 'aria-hidden': 'true', class: 'focus-layer' }); + Object.assign(layer.style, { left: `${left}px`, top: `${top}px`, width: `${w}px`, height: `${h}px` }); + const defs = svg('defs'), mask = svg('mask', { id: 'grounding-focus-mask', maskUnits: 'userSpaceOnUse', x: 0, y: 0, width: w, height: h }); + mask.append(svg('rect', { width: w, height: h, fill: 'white' })); + const marks = []; + for (const p of [coords[instanceIndex]]) { + const attr = p.length === 4 + ? { x: p[0] / 999 * w, y: p[1] / 999 * h, width: (p[2] - p[0]) / 999 * w, height: (p[3] - p[1]) / 999 * h, rx: 2 } + : { cx: p[0] / 999 * w, cy: p[1] / 999 * h, r: 13 }; + const tag = p.length === 4 ? 'rect' : 'circle'; + mask.append(svg(tag, { ...attr, fill: 'black' })); + marks.push(svg(tag, { ...attr, class: 'focus-outline', pathLength: 1 })); + } + defs.append(mask); layer.append(defs); + layer.append(svg('rect', { width: w, height: h, mask: 'url(#grounding-focus-mask)', class: 'focus-dimmer' }), ...marks); + const caption = document.createElement('div'); caption.className = 'focus-caption'; + const label = document.createElement('span'); + label.setAttribute('role', 'status'); label.setAttribute('aria-live', 'polite'); + const evidence = 'Prediction'; + label.textContent = `${evidence} · ${selected.dataset.label} · ${instanceIndex + 1} / ${coords.length}`; + label.title = label.textContent; + caption.append(label); + for (const [action, name, path] of [['prev', 'Previous instance', 'm12 5-5 5 5 5'], ['next', 'Next instance', 'm8 5 5 5-5 5']]) { + const button = document.createElement('button'); button.type = 'button'; button.dataset.instance = action; + button.setAttribute('aria-label', name); button.title = name; button.disabled = coords.length < 2; + const icon = svg('svg', {viewBox: '0 0 20 20', width: 16, height: 16, fill: 'none', 'aria-hidden': 'true'}); + icon.append(svg('path', {d: path, stroke: 'currentColor', 'stroke-width': 1.7})); + button.append(icon); caption.append(button); + } + const close = document.createElement('button'); close.type = 'button'; close.className = 'focus-close'; close.setAttribute('aria-label', 'Close target focus'); + const icon = svg('svg', { viewBox: '0 0 20 20', width: 16, height: 16, fill: 'none', 'aria-hidden': 'true' }); + icon.append(svg('path', { d: 'm6 6 8 8m0-8-8 8', stroke: 'currentColor', 'stroke-width': 1.7, 'stroke-linecap': 'round' })); + close.title = 'Close focus and return to targets'; + close.append(icon); caption.append(close); stage.append(layer); $('#canvas-viewport').append(caption); + if (activeAction) caption.querySelector(`[data-instance=${activeAction}]`)?.focus({preventScroll: true}); + showDetail(coords); + } + function tick() { + if (document.hidden || !waiting) return; + const clock = $('.wait-clock'); + if (clock) clock.textContent = `${((performance.now() - waitStart) / 1000).toFixed(1)} s`; + } + function setWaiting(value) { + if (value === waiting) return; + waiting = value; + $('#console').setAttribute('aria-busy', String(value)); + for (const button of document.querySelectorAll('#run-button,#mobile-run-button')) { + button.disabled = value; + button.classList.toggle('is-waiting', value); + if (value) button.setAttribute('aria-label', 'Grounding in progress'); + else button.removeAttribute('aria-label'); + } + for (const id of ['controls', 'sandbox-panel', 'query-dock', 'upload-button', 'canvas-chrome']) { + const el = $(`#${id}`); if (el) el.inert = value; + } + clearInterval(interval); + if (!value) clearTimeout(watchdog); + if (value) { clearSelection(); resetCanvas(); waitStart = performance.now(); interval = setInterval(tick, 100); } + } + function clientStatus(text, phase) { + const node = document.createElement('div'); + node.className = `stage-status ${phase}`; node.dataset.phase = phase; + node.setAttribute('role', 'status'); node.setAttribute('aria-live', 'polite'); + const dot = document.createElement('i'); dot.setAttribute('aria-hidden', 'true'); + const label = document.createElement('span'); label.textContent = text; + node.append(dot, label); + if (phase === 'busy') { + const clock = document.createElement('time'); clock.className = 'wait-clock'; + clock.setAttribute('aria-hidden', 'true'); clock.textContent = '0.0 s'; node.append(clock); + } + $('#stage-status .stage-status')?.replaceWith(node); + } + // A reverse proxy can buffer the first SSE event. Acknowledge the actual click + // immediately; backend events still own final results and measured latency. + window.groundingConsoleBegin = () => { + if (!ready || waiting) return; + clientStatus('Request submitted · Awaiting inference', 'busy'); setWaiting(true); + watchdog = setTimeout(() => { + if (!waiting) return; + clientStatus('No result received. Check the connection and refresh. The server request has not been cancelled.', 'error'); + setWaiting(false); + }, 330000); + }; + function schedule() { + if (frame) return; + frame = requestAnimationFrame(() => { frame = null; reconcile(); }); + } + function reconcile() { + const stage = $('#stage-image'), targets = $('#targets-content'); + if (!stage || !targets) return; + setWaiting($('.stage-status')?.dataset.phase === 'busy'); + const chips = targets.querySelector('.target-chips'); + if (targetRoot !== chips) { targetRoot = chips; clearSelection(); } + const nextImage = stage.querySelector('img'); + if (image !== nextImage) { image = nextImage; if (image) listen(image, 'load', schedule); } + const src = image?.currentSrc || image?.src; + const download = $('.canvas-download'); + if (download && src) download.href = src; + if (src !== lastSrc) { + clearSelection(); resetCanvas(); lastSrc = src; + } + const dimensions = $('.image-dimensions'); + if (dimensions && image?.naturalWidth) dimensions.textContent = `${image.naturalWidth} × ${image.naturalHeight} px${zoom>1 ? ' / drag to pan' : ''}`; + drawSelection(); + } + function onClick(event) { + // The native click has already reached Gradio's button handler. Keep its + // State inputs untouched; only enhance presentation during network latency. + if (event.target.closest?.('#run-button,#mobile-run-button')) window.groundingConsoleBegin?.(); + const instance = event.target.closest?.('[data-instance]')?.dataset.instance; + if (instance && selected && !waiting) { + const count = JSON.parse(selected.dataset.coordinates).length; + instanceIndex = (instanceIndex + (instance === 'next' ? 1 : -1) + count) % count; + drawSelection(); return; + } + const action = event.target.closest?.('[data-canvas]')?.dataset.canvas; + if (action && !waiting) { + if (action === 'fit') resetCanvas(); + else { zoom=Math.max(1,Math.min(4,zoom+(action==='in'?.5:-.5))); canvasTransform(); } + schedule(); return; + } + const chip = event.target.closest?.('#targets-content .target-chip'); + if (chip && !waiting) { + const wasSelected = chip === selected; + clearSelection(); + if (!wasSelected) { + selected = chip; chip.setAttribute('aria-pressed', 'true'); $('.clear-focus').hidden = false; drawSelection(); + const bounds = $('#canvas-viewport').getBoundingClientRect(); + if (bounds.top < 0 || bounds.bottom > innerHeight) { + $('#canvas-viewport').scrollIntoView({block: 'center', behavior: reduced.matches ? 'instant' : 'smooth'}); + $('.focus-close')?.focus({preventScroll: true}); + } + } + } else if (event.target.closest?.('.clear-focus,.focus-close')) { + const previous = selected; clearSelection(); previous?.focus(); + } + // Select an actual returned box directly on the image; no invented geometry. + if (!waiting && !moved && event.target === image) { + const rect=image.getBoundingClientRect(), scale=Math.min(rect.width/image.naturalWidth,rect.height/image.naturalHeight); + const w=image.naturalWidth*scale, h=image.naturalHeight*scale; + const x=(event.clientX-rect.left-(rect.width-w)/2)/w*999, y=(event.clientY-rect.top-(rect.height-h)/2)/h*999; + const hits=[]; + document.querySelectorAll('.target-chip').forEach(chip=>{ + let coords; try{coords=JSON.parse(chip.dataset.coordinates);}catch{return;} + coords.forEach((p,index)=>{ + if (p.length===4 && x>=p[0] && x<=p[2] && y>=p[1] && y<=p[3]) hits.push({chip,index,size:(p[2]-p[0])*(p[3]-p[1])}); + if (p.length===2 && Math.hypot(x-p[0],y-p[1])<20) hits.push({chip,index,size:0}); + }); + }); + const hit=hits.sort((a,b)=>a.size-b.size)[0]; + if(hit){clearSelection();selected=hit.chip;instanceIndex=hit.index;selected.setAttribute('aria-pressed','true');$('.clear-focus').hidden=false;drawSelection();$('.focus-close')?.focus({preventScroll:true});} + } + moved=false; + } + function init() { + if (ready || !$('#console') || !$('#targets-content') || !$('#stage-status')) return; + ready = true; observer.disconnect(); + listen(document, 'click', onClick); + listen(document, 'change', schedule); + listen(document, 'keydown', e => { if (e.key === 'Escape') {const previous=selected;clearSelection();resetCanvas();previous?.focus();} }); + const viewport=$('#canvas-viewport'); + listen(viewport,'pointerdown',e=>{ + moved=false; + if(zoom<=1 || waiting || e.button!==0 || e.target.closest('button') || !e.target.closest('#stage-image')) return; + drag={x:e.clientX,y:e.clientY,px:panX,py:panY}; viewport.setPointerCapture(e.pointerId); viewport.classList.add('is-panning'); e.preventDefault(); + }); + listen(viewport,'pointermove',e=>{ + if(!drag)return; + const dx=e.clientX-drag.x,dy=e.clientY-drag.y; moved ||= Math.hypot(dx,dy)>4; + panX=drag.px+dx;panY=drag.py+dy;canvasTransform(); + }); + const endDrag=()=>{drag=null;viewport.classList.remove('is-panning');}; + listen(viewport,'pointerup',endDrag);listen(viewport,'pointercancel',endDrag); + listen(viewport,'dragstart',e=>{if(zoom>1)e.preventDefault();}); + listen(document, 'visibilitychange', () => { $('#console')?.classList.toggle('tab-hidden', document.hidden); tick(); }); + observer = new MutationObserver(records => { + if (records.some(r => !r.target.closest?.('.focus-layer,.focus-caption,.wait-clock'))) schedule(); + }); + for (const id of ['stage-image', 'targets-content', 'stage-status']) observer.observe($(`#${id}`), { childList: true, subtree: true, attributes: true, attributeFilter: ['src'] }); + resize = new ResizeObserver(schedule); resize.observe($('#stage-image')); resize.observe($('#controls')); reconcile(); + document.fonts.ready.then(schedule); + } + observer = new MutationObserver(init); observer.observe(document.body, { childList: true, subtree: true }); init(); + window.groundingConsoleCleanup = () => { + abort.abort(); observer?.disconnect(); resize?.disconnect(); cancelAnimationFrame(frame); clearInterval(interval); clearTimeout(watchdog); + if (ready) setWaiting(false); removeLayer(); + delete window.groundingConsoleBegin; + }; +} diff --git a/assets/frosted.css b/assets/frosted.css new file mode 100644 index 0000000000000000000000000000000000000000..1e448c59db2f82a906027f9a81c7dd70adcfbe3e --- /dev/null +++ b/assets/frosted.css @@ -0,0 +1,148 @@ +/* Screenshot-led console: settings left, image right, examples/results below. + paper.css supplies shared evidence geometry and interaction primitives. */ +:root{ + --purple:#7954ae;--purple-deep:#60418c;--lime:#257a4d; + --ink:#202127;--muted:#636570;--line:rgba(47,47,65,.1); + --paper:#f5f6f9;--lavender:#efebf6;--canvas:#f0eff5; + --surface:#fdfdfe;--selection:#f1ecf8;--action-hover:#1d653e; + --glass:rgba(250,252,255,.58);--glass-strong:rgba(255,255,255,.8); + --ease:cubic-bezier(.22,1,.36,1); + --ui:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Manrope,"PingFang SC","Microsoft YaHei",sans-serif; +} +.gradio-container{padding-top:28px!important} +.studio-header{padding:4px 2px 26px;align-items:center} +.studio-header h1{font-family:var(--ui);font-size:30px;font-weight:650;line-height:1.25;letter-spacing:-.025em;color:var(--ink);margin:0} +.studio-header p{font-family:var(--ui);font-size:14px;color:var(--muted);margin:8px 0 0} +.header-note{display:flex;gap:8px;font-family:var(--ui)} +.header-note>span{background:rgba(255,255,255,.8);border:0;border-radius:20px;color:var(--muted);font-size:12px;font-weight:400;padding:8px 13px} +#console{display:flex!important;flex-direction:column!important;gap:20px!important;border:0;border-radius:0;overflow:visible;background:transparent;box-shadow:none} +#workspace-top{display:flex!important;flex-wrap:nowrap!important;gap:0!important;align-items:stretch;border-radius:24px;background:linear-gradient(125deg,#ece6f5 0%,#f1f3f7 44%,#eaf0e8 100%);box-shadow:0 18px 48px rgba(42,46,73,.07),inset 0 1px 0 #fff;overflow:visible} +#controls{position:relative!important;top:auto;z-index:12;flex:0 0 28.5%!important;min-width:290px!important;gap:20px!important;margin:0!important;padding:36px!important;border-radius:24px 0 0 24px;background:rgba(255,255,255,.67);backdrop-filter:blur(24px) saturate(1.2);-webkit-backdrop-filter:blur(24px) saturate(1.2);box-shadow:inset 1px 1px 0 rgba(255,255,255,.94)} +#controls>*{flex-grow:0!important}.control-brand{padding-bottom:12px} +.xpeng-logo{width:174px;height:auto;margin:0 0 26px!important;border-radius:5px} +.control-brand h2{font-family:var(--ui);font-size:34px;font-weight:650;line-height:1.18;letter-spacing:-.035em;color:var(--ink);margin:0 0 13px} +.control-brand p{font-family:var(--ui);font-size:14px;font-weight:400;line-height:1.8;color:var(--muted);max-width:22ch;margin:0} +#control-fields{flex-wrap:nowrap!important;gap:14px!important;align-items:stretch} +#media-type{flex:0 0 86px!important;min-width:86px!important} +.media-field>span{display:block;font-family:var(--ui);font-size:12px;color:var(--muted);margin-bottom:8px} +.media-field>div{display:flex;align-items:center;justify-content:center;gap:7px;background:#e8efea;min-height:46px;border-radius:12px;font-family:var(--ui);font-size:13px;font-weight:600;color:#275c3e} +.media-field svg{width:16px;height:16px;stroke:currentColor;stroke-width:1.5} +#route-select,#case-select{min-width:0!important;background:transparent!important;border:0!important;padding:0!important;overflow:visible!important} +#route-select{flex:1 1 0!important} +#route-select label,#case-select label{display:block!important;min-height:0!important;padding:0!important;margin:0!important;font-family:var(--ui)!important;font-size:12px!important;font-weight:400!important;color:var(--muted)!important;background:transparent!important;box-shadow:none!important;border:0!important;border-radius:0!important} +#route-select label>span,#case-select label>span{display:block;margin-bottom:8px!important;font-size:12px!important;color:var(--muted)!important} +#route-select .wrap,#case-select .wrap{display:flex!important;position:relative;flex-wrap:nowrap!important;gap:4px!important;min-height:46px!important;border:1px solid rgba(87,83,105,.15)!important;border-radius:12px!important;padding:10px 12px!important;background:rgba(255,255,255,.74)!important;box-shadow:inset 0 1px 0 #fff;overflow:visible!important;isolation:auto} +#route-select input,#case-select input{position:static!important;flex:1 1 0!important;min-width:0!important;width:100%!important;height:auto!important;opacity:1!important;margin:0!important;padding:0!important;color:var(--ink)!important;font-family:var(--ui)!important;font-size:14px!important;font-weight:500!important} +#route-select .icon-wrap,#case-select .icon-wrap{flex:0 0 18px!important;width:18px!important;height:18px!important} +#route-select svg,#case-select svg,#advanced-options>.label-wrap svg{width:16px!important;height:16px!important} +/* Never resurrect Gradio's hidden progress layers with a material selector. */ +#console .wrap.hide{display:none!important} +#route-select .wrap:focus-within,#case-select .wrap:focus-within{border-color:var(--purple)!important} +#route-select ul,#case-select ul{z-index:60!important;background:#fdfdfe!important;color:var(--ink)!important;box-shadow:0 12px 28px rgba(35,29,51,.14);border-radius:12px!important} +#route-select li,#case-select li{font-size:14px!important} +#upload-button{width:100%!important;flex:0 0 auto!important;min-width:0!important;min-height:46px!important;border:0!important;border-radius:12px!important;padding:12px 16px!important;background:var(--glass)!important;color:var(--purple-deep)!important;font-family:var(--ui)!important;font-size:14px!important;font-weight:500!important;backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);box-shadow:inset 0 1px 0 #fff,0 3px 10px rgba(48,42,71,.055)!important} +#upload-button:hover{background:rgba(255,255,255,.9)!important} +#advanced-options{border:0!important;border-top:1px solid var(--line)!important;border-bottom:1px solid var(--line)!important;border-radius:0!important;background:transparent!important;padding:6px 0!important} +#advanced-options>.label-wrap{font-family:var(--ui)!important;font-size:13px!important;font-weight:400!important;min-height:40px!important;color:var(--muted)!important} +.runtime-options{display:grid;grid-template-columns:auto 1fr;gap:10px;font-family:var(--ui);font-size:12px;line-height:1.6;color:var(--muted);padding:10px 0} +.runtime-options b{text-align:right;overflow-wrap:anywhere;color:var(--ink);font-weight:500}.runtime-options small{grid-column:1/-1;font-size:12px;line-height:1.7} +#service-panel{padding-top:12px!important;border-top:1px solid var(--line);gap:7px!important} +.api-status,.api-status span{font-family:var(--ui);font-weight:400;font-size:12px;line-height:1.65;color:var(--muted)} +.api-status.online{color:#306443}.api-status.offline{color:#a63b42} +#health-button{font-family:var(--ui)!important;font-size:12px!important;font-weight:400!important;min-height:36px!important} +#run-button{margin-top:auto!important;flex:0 0 auto!important;width:100%!important;min-width:0!important;min-height:50px!important;border-radius:25px!important;background:var(--lime)!important;color:#fff!important;font-family:var(--ui)!important;font-size:15px!important;font-weight:600!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.24),0 7px 18px rgba(37,122,77,.15)!important} +#run-button:hover:not(:disabled){background:var(--action-hover)!important}#run-button:disabled{background:var(--lavender)!important;color:var(--purple-deep)!important;box-shadow:none!important}#run-button.is-waiting{color:transparent!important} +#visual-stage{position:relative;isolation:isolate;flex:1 1 0!important;min-width:0!important;gap:0!important;padding:0!important;overflow:hidden;border-radius:0 24px 24px 0;background:var(--canvas)} +.scene-atmosphere{position:absolute;inset:-40px;width:auto!important;z-index:-1;pointer-events:none;background-position:center;background-size:cover;filter:blur(34px) saturate(.85);opacity:.2} +#stage-toolbar{position:relative!important;top:auto;left:auto;width:100%;z-index:8;display:flex;flex-wrap:nowrap!important;align-items:center;justify-content:space-between;gap:16px!important;min-height:76px;padding:20px 28px 12px!important;background:transparent!important;pointer-events:auto} +#view-toggle{flex:0 0 auto!important;width:fit-content!important;min-width:0!important;pointer-events:auto} +#view-toggle .wrap{padding:5px!important;gap:3px!important;background:var(--glass)!important;border-radius:23px!important;backdrop-filter:blur(24px) saturate(1.4);-webkit-backdrop-filter:blur(24px) saturate(1.4);box-shadow:inset 0 1.5px 1px rgba(255,255,255,.98),inset 0 -1px 1px rgba(255,255,255,.55),0 5px 16px rgba(39,43,64,.085)} +#view-toggle label{border-radius:20px!important;min-height:34px!important;padding:8px 13px!important;font-family:var(--ui)!important;font-size:12px!important;font-weight:500!important;color:#24242b!important} +#view-toggle label:hover{background:rgba(255,255,255,.38)!important} +#view-toggle label:has(input:checked){color:var(--purple-deep)!important;font-weight:600!important} +#view-toggle .active-tab-indicator{border-radius:20px;background:rgba(255,255,255,.83);box-shadow:0 2px 6px rgba(39,43,64,.07),inset 0 1px 0 #fff;transition-duration:300ms} +#stage-status{flex:1 1 0!important;width:auto!important;min-width:0!important;min-height:0!important;max-width:47%;padding:0!important} +.stage-status{display:flex;gap:7px;padding:8px 11px;border-radius:14px;background:rgba(255,255,255,.7);font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.6;color:#326144;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)} +.stage-status span{color:inherit}.stage-status i{margin-top:6px} +.stage-status.reference,.stage-status.busy{color:var(--purple-deep)}.stage-status.error{color:#a63b42}.wait-clock{font-family:var(--ui);font-size:12px;font-weight:500;font-variant-numeric:tabular-nums} +#canvas-viewport{padding:12px 40px 54px!important;background:transparent!important;isolation:auto} +#stage-image{height:440px!important;transition-duration:380ms} +#stage-image img{border-radius:9px;box-shadow:0 10px 24px rgba(35,35,47,.09)}#stage-image .buttons{top:8px!important} +.canvas-tools{min-height:54px;padding:8px 28px;font-family:var(--ui);font-size:12px;font-weight:400;color:#282830} +.image-dimensions{padding:6px 10px;background:rgba(255,255,255,.64);border-radius:16px} +.zoom-tools{padding:4px 8px;border-radius:23px;background:var(--glass);backdrop-filter:blur(24px) saturate(1.4);-webkit-backdrop-filter:blur(24px) saturate(1.4);box-shadow:inset 0 1.5px 1px #fff,inset 0 -1px 1px rgba(255,255,255,.55),0 5px 16px rgba(39,43,64,.085)} +.zoom-tools button{width:32px;height:32px;border-radius:50%;color:#24242b}.zoom-tools button:hover{background:rgba(255,255,255,.6)} +.zoom-value{font-family:var(--ui);font-size:12px;font-weight:500;color:var(--ink);font-variant-numeric:tabular-nums}.tool-divider{background:var(--line)} +#query-row{position:relative;z-index:2;display:block!important;padding:14px 40px 28px!important;background:transparent!important;border:0!important} +#query-dock{max-width:760px;margin:0 auto!important;padding:14px 18px!important;border:0!important;border-radius:15px!important;background:rgba(255,255,255,.75)!important;backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);box-shadow:inset 0 1px 1px #fff,0 6px 22px rgba(39,43,64,.075)!important} +#query-dock label>span{font-family:var(--ui)!important;font-size:12px!important;font-weight:500!important;color:var(--purple-deep)!important;margin-bottom:6px!important} +#query-dock textarea{font-family:var(--ui)!important;font-size:14px!important;line-height:1.65!important;font-weight:400!important;color:var(--ink)!important} +#query-dock:focus-within{outline:2px solid rgba(121,84,174,.5);outline-offset:2px} +#review-row{display:flex!important;flex-wrap:nowrap!important;gap:20px!important;align-items:stretch} +#sandbox-panel{flex:0 0 38%!important;min-width:0!important;padding:24px!important;gap:17px!important;background:rgba(255,255,255,.86);border-radius:20px;box-shadow:0 8px 24px rgba(42,46,73,.045)} +.film-heading{align-items:center;font-family:var(--ui);font-size:14px;font-weight:500;color:var(--ink)}.film-heading h2{font-family:var(--ui);font-size:16px;font-weight:600;margin:0!important}.film-heading small{font-family:var(--ui);font-size:12px;font-weight:400;color:var(--muted)} +#case-gallery{height:170px!important} +#case-gallery .grid-container{gap:10px!important;grid-template-columns:repeat(3,minmax(0,1fr))!important} +#case-gallery .thumbnail-item{min-width:0!important} +#case-gallery .thumbnail-item{height:154px!important;flex-direction:column!important;align-items:stretch;gap:6px;border-radius:12px!important;background:#fff!important;border-color:rgba(70,64,88,.12)!important;padding:5px!important} +#case-gallery .thumbnail-item img{width:100%!important;height:112px!important;flex:1 1 0!important;min-height:0!important;border-radius:8px!important} +#case-gallery .caption-label{max-width:100%!important;text-align:center!important;font-family:var(--ui)!important;font-size:12px!important;line-height:1.5!important;font-weight:500!important;color:#52525f!important;padding:3px!important} +#case-gallery .thumbnail-item:hover{border-color:#a797bc!important;background:#faf8fd!important} +#case-gallery .thumbnail-item.selected{background:var(--selection)!important;border:2px solid var(--purple)!important;padding:4px!important} +#source-details{margin-top:auto;border:0!important;border-top:1px solid var(--line)!important;padding:10px 0 0!important} +#source-details .label-wrap{font-family:var(--ui)!important;font-size:12px!important;font-weight:400!important;min-height:36px!important} +.source-meta{font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.7}.source-meta>span,.source-meta small{font-size:12px} +#review-summary{flex:1 1 0!important;min-width:0!important;padding:0!important;background:var(--surface);border-radius:20px;box-shadow:0 8px 24px rgba(42,46,73,.045)} +#result-columns{display:flex!important;flex-wrap:nowrap!important;gap:0!important;align-items:stretch} +#metrics-panel{flex:0 0 41%!important;min-width:0!important;padding:24px!important;border:0!important;gap:20px!important} +.inspector-subheading{font-family:var(--ui)!important;font-size:16px!important;font-weight:600!important;color:var(--ink)!important;line-height:1.4} +.metrics-list{font-family:var(--ui);font-size:12px;font-weight:400}.metrics-list>div{padding:8px 0;gap:14px}.metrics-list dd{font-family:var(--ui);font-size:12px;font-weight:500;line-height:1.6;color:#41424c} +#sidebar{flex:1 1 0!important;min-width:0!important;width:auto;padding:24px!important;border:0;border-left:1px solid var(--line);background:transparent;gap:20px!important} +.inspector-heading h2{font-family:var(--ui)!important;font-size:16px!important;font-weight:600!important;color:var(--ink)!important} +.inspector-heading{align-items:baseline;flex-wrap:wrap;gap:7px}.live-mark{font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.6;color:var(--muted)} +#targets-panel{flex:1 1 auto!important} +.empty-targets{min-height:174px}.empty-targets svg{width:32px;height:32px;color:#8a7f9c}.empty-targets>b{font-family:var(--ui);font-size:14px;font-weight:500;color:#4a4655}.empty-targets>small{font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.8} +.targets-summary{font-family:var(--ui);font-size:12px;font-weight:400}.targets-summary b{font-family:var(--ui);font-size:19px;font-weight:600}.targets-summary>span{font-size:11px} +.target-chips{max-height:240px;display:flex;flex-direction:column} +.target-chip{min-height:36px!important;padding:8px 10px!important;border-radius:8px!important;font-family:var(--ui)!important;font-size:13px!important;font-weight:400!important;color:#53535d!important} +.target-chip:hover{background:#f5f2fa!important}.target-chip[aria-pressed=true]{background:var(--selection)!important;color:var(--purple-deep)!important}.target-chip b{font-family:var(--ui);font-size:12px;font-weight:500} +.focus-help,.targets-caption{font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.7}.clear-focus{font-family:var(--ui);font-size:12px;font-weight:500} +.detail-heading{font-family:var(--ui);font-size:13px;font-weight:500}.detail-heading small{font-family:var(--ui);font-size:12px;font-weight:400}.detail-image{height:150px;border-radius:9px}.detail-coordinates{font-size:12px;line-height:1.6} +.focus-dimmer{fill:#1c1c28;opacity:.42;animation-duration:260ms}.focus-outline{animation-duration:360ms}.evidence-detail{animation-duration:300ms} +.focus-caption{top:auto;bottom:12px;left:12px;max-width:calc(100% - 24px);padding:5px 6px 5px 13px;border-radius:12px;background:var(--glass-strong);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);box-shadow:0 4px 14px rgba(20,20,32,.1),inset 0 1px 0 #fff;color:var(--ink);font-family:var(--ui);font-size:13px;font-weight:500} +.focus-caption button{background:rgba(220,220,230,.55);color:#55555e;border-radius:7px} +.glass-control{position:relative;--glint-x:35%} +.glass-control::after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;background:radial-gradient(ellipse at var(--glint-x) 0%,rgba(255,255,255,.66),transparent 65%);transition:opacity 200ms var(--ease)} +.glass-control:hover::after{opacity:.8}.glass-control:active::after{opacity:1} +#prompt-console,#output-console{margin-top:6px;border-bottom-color:var(--line)!important;padding:5px 3px!important} +#prompt-console>.label-wrap,#output-console>.label-wrap{font-family:var(--ui)!important;font-size:13px!important;font-weight:400!important;min-height:40px;color:var(--muted)!important} +.console-note,.studio-footer{font-family:var(--ui);font-size:12px;font-weight:400;line-height:1.7;color:var(--muted)}.studio-footer{padding:12px 2px} +@keyframes focus-dim{from{opacity:0}to{opacity:.42}} +@media(min-width:1500px){#controls{padding:42px!important}#stage-image{height:500px!important}#canvas-viewport{padding:14px 54px 56px!important}#query-row{padding:16px 54px 32px!important}#sidebar{flex:1 1 0!important;min-width:0!important;padding:28px!important}#metrics-panel{padding:28px!important}} +@media(max-width:1100px){#controls{flex-basis:30%!important;min-width:260px!important;padding:26px!important}.control-brand h2{font-size:30px}.xpeng-logo{width:150px}.control-brand p{font-size:13px}#control-fields{gap:10px!important}#media-type{flex-basis:74px!important;min-width:74px!important}#stage-toolbar{padding:16px 18px 10px!important;gap:10px!important;flex-wrap:wrap!important}#stage-status{max-width:100%;flex-basis:100%!important}.stage-status{width:fit-content;padding:5px 10px}#canvas-viewport{padding:12px 24px 54px!important}#stage-image{height:390px!important}#query-row{padding:12px 24px 24px!important}#sandbox-panel{padding:20px!important}#metrics-panel{flex-basis:42%!important;padding:20px!important}#sidebar{flex:1 1 0!important;min-width:0!important;padding:20px!important}#case-gallery .thumbnail-item{height:144px!important}} +@media(max-width:760px){ + .studio-header{padding:4px 2px 18px}.studio-header h1{font-size:25px}.studio-header p{font-size:13px;margin-top:6px}.header-note{display:none} + #console{gap:16px!important}#workspace-top{flex-direction:column!important;border-radius:20px} + #controls{flex:0 0 auto!important;min-width:0!important;padding:24px!important;border-radius:20px 20px 0 0;gap:16px!important} + .control-brand{display:flex;align-items:center;flex-wrap:wrap;gap:14px;padding-bottom:4px}.xpeng-logo{width:108px;margin:0!important}.control-brand h2{font-size:25px;margin:0}.control-brand p{display:none} + #control-fields{gap:14px!important}#media-type{flex-basis:92px!important;min-width:92px!important} + #run-button{min-height:48px!important;height:auto!important;margin-top:0!important;font-size:14px!important;min-width:0!important;flex:0 0 auto!important} + #visual-stage{flex:0 0 auto!important;border-radius:0 0 20px 20px}#stage-toolbar{padding:16px 16px 8px!important;gap:10px!important;min-height:0} + #stage-status{max-width:none;flex-basis:100%!important}.stage-status{font-size:12px} + #view-toggle label{padding:8px 12px!important;font-size:12px!important;min-height:36px!important} + #canvas-viewport{padding:10px 16px 58px!important}#stage-image{height:300px!important} + .canvas-tools{padding:9px 16px;min-height:58px;font-size:12px}.zoom-tools button{width:34px;height:34px} + #query-row{padding:10px 16px 22px!important}#query-dock{padding:13px 15px!important} + #review-row{flex-direction:column!important;gap:16px!important}#sandbox-panel{flex:0 0 auto!important;width:100%;padding:22px 18px!important} + #case-gallery{height:150px!important}#case-gallery .thumbnail-item{height:136px!important}.film-heading small{font-size:12px;max-width:none} + #review-summary{width:100%}#result-columns{flex-direction:column!important} + #metrics-panel{flex:0 0 auto!important;width:100%;padding:24px!important;gap:14px!important}.metrics-list{display:grid;grid-template-columns:1fr 1fr;gap:8px 24px}.metrics-list>div{gap:4px;padding:4px 0} + #sidebar{flex:0 0 auto!important;width:100%;padding:24px!important;border-left:0;border-top:1px solid var(--line);gap:16px!important} + .target-chips{display:grid;grid-template-columns:1fr 1fr;max-height:250px}.target-chip{min-height:42px!important} + .empty-targets{min-height:174px}.detail-image{height:170px}.evidence-detail{max-width:none} + #source-details .label-wrap{min-height:40px!important}.studio-footer{gap:5px;padding:12px 2px;line-height:1.7} +} +@media(max-width:430px){#stage-image{height:262px!important}.canvas-tools .image-dimensions{font-size:12px}.control-brand{gap:12px}.control-brand h2{font-size:24px}.xpeng-logo{width:102px}.film-heading h2{font-size:15px}} +@media(prefers-reduced-transparency:reduce){#controls,#view-toggle .wrap,#upload-button,#query-dock,.zoom-tools,.focus-caption,.stage-status{backdrop-filter:none!important;-webkit-backdrop-filter:none!important;background:#fafafc!important}.scene-atmosphere{opacity:0}.glass-control::after{display:none}} +@media(prefers-contrast:more){#controls,#view-toggle .wrap,#upload-button,#query-dock,.zoom-tools,.focus-caption,.stage-status{background:#fff!important;outline:1px solid #53535e}.scene-atmosphere{opacity:.1}} +@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition-duration:0ms!important}} diff --git a/assets/original.css b/assets/original.css new file mode 100644 index 0000000000000000000000000000000000000000..3002459b5f929c7eb2af20e544b49ee08d94fb21 --- /dev/null +++ b/assets/original.css @@ -0,0 +1,272 @@ +/* Original Oxygen Spatial console, adapted to the standalone Gradio DOM. + Visual authority: X-CG_demo/src/styles.css (.heroBoard / .controlPanel / + .controlCard / .runButton / .lowerGrid), verified on 2026-09-11. + paper.css retains coordinate, focus, zoom and accessible state primitives. + The previous frosted.css is deliberately NOT loaded. */ +:root { + --ink:#222132; --muted:#657083; --line:#e4deed; + --green:#5e7d24; --lime:#91c331; --paper:#f4f5f8; + --surface:#fff; --canvas:#f5f3f9; --selection:#eee7f7; + /* Paper palette: purple for perception, lime for the primary action. */ + --purple:#784ebc; --purple-deep:#5b358b; --lavender:#eee7f7; + --ui:Manrope,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif; + --mono:ui-monospace,SFMono-Regular,Menlo,monospace; + --ease:cubic-bezier(.16,1,.3,1); +} +.gradio-container { + background:radial-gradient(circle at 18% 8%,rgba(120,78,188,.06),transparent 28%),linear-gradient(180deg,#fff 0%,#f4f5f8 56%,#fff 100%)!important; + --block-radius:8px; --color-accent:var(--green); +} +* {scrollbar-color:#c2d2b6 transparent} +::selection {background:#e5d7f5;color:#172018} +input,textarea {caret-color:var(--green)} +.studio-header {justify-content:space-between;gap:18px;padding:0 2px 22px;align-items:center} +.header-description {margin:8px 0 0;color:var(--muted);font:500 14px/1.6 var(--ui)} +.header-scope {color:var(--muted);font:600 12px var(--ui);white-space:nowrap} +.chapter-mark {display:grid;place-items:center;flex:0 0 40px;width:40px;height:40px;border-radius:8px;background:#32831b;color:#fff;font:900 13px var(--mono)} +.eyebrow {display:block;color:var(--green);font:850 11px/1.6 var(--mono);letter-spacing:.07em;text-transform:uppercase} +.studio-header .eyebrow {margin:0 0 3px} +.studio-header h1 {margin:0;color:var(--ink);font:850 32px/1.12 var(--ui);letter-spacing:0} +.grounding-intro {display:flex;align-items:flex-end;justify-content:space-between;gap:28px;padding:0 2px 18px} +.grounding-intro h2 {margin:5px 0 0;font:800 25px/1.18 var(--ui);letter-spacing:0;color:var(--ink)} +.grounding-intro p {max-width:350px;color:var(--muted);font:700 13px/1.55 var(--ui);text-align:right;margin:0} +#console {display:flex!important;flex-direction:column!important;gap:16px!important;background:transparent;border:0;border-radius:0;box-shadow:none;overflow:visible} +#workspace-top {display:flex!important;flex-wrap:nowrap!important;align-items:stretch;gap:0!important;min-height:620px;border:1px solid #e4deed;border-radius:8px;overflow:visible;background:radial-gradient(circle at 75% 36%,rgba(145,195,49,.06),transparent 34%),linear-gradient(120deg,#fff 0%,#fcfbfe 46%,#f5f3f9 100%);box-shadow:0 30px 85px rgba(45,29,69,.06)} +#controls {position:relative!important;z-index:12;flex:0 0 28.5%!important;min-width:290px!important;padding:28px!important;margin:0!important;gap:20px!important;background:#ffffffed;border-right:1px solid #e4deed;border-radius:8px 0 0 8px;backdrop-filter:none;-webkit-backdrop-filter:none} +#controls>* {flex-grow:0!important} +.control-brand {display:grid;gap:13px;padding-bottom:0} +.xpeng-logo {width:200px;height:auto;margin:0!important;border-radius:3px;filter:drop-shadow(0 16px 28px rgba(47,125,36,.14))} +.control-brand .eyebrow {font-size:11px;line-height:1.45} +.control-brand h2 {margin:4px 0 0;font:850 clamp(32px,2.8vw,44px)/1.08 var(--ui);letter-spacing:0;color:var(--ink)} +.control-brand h2 span {color:#91c331} +.control-brand p {max-width:390px;margin:0;font:700 14px/1.6 var(--ui);color:#657083} +#control-settings {padding:14px!important;gap:14px!important;border:1px solid var(--line);border-radius:8px;background:#fff;box-shadow:none;overflow:visible!important} +#control-fields {flex-wrap:nowrap!important;gap:12px!important;align-items:stretch} +#control-fields>.form {min-width:0!important;flex:1 1 0!important;width:0!important} +#control-settings .form {min-width:0!important;overflow:visible} +#media-type {flex:0 0 40%!important;min-width:0!important} +.media-field>span,#route-select [data-testid=block-info] {display:block;margin-bottom:8px!important;color:#657386!important;font:800 10px/1.4 var(--mono)!important;letter-spacing:.07em;text-transform:uppercase} +.media-field>div {display:flex;align-items:stretch;height:39px;padding:3px;border:1px solid #e4deed;border-radius:8px;background:#f2eff7} +.media-field>div>span {display:grid;place-items:center;min-width:64px;padding:0 12px;border-radius:6px;color:#0c1608;background:#91c331;font:800 13px var(--ui);box-shadow:0 7px 18px rgba(131,200,50,.18)} +#route-select {flex:1 1 0!important;min-width:0!important;background:transparent!important;border:0!important;padding:0!important;overflow:visible!important} +#route-select label {display:block!important;min-height:0!important;padding:0!important;margin:0!important;background:transparent!important;box-shadow:none!important;border:0!important;border-radius:0!important} +#route-select .wrap {display:flex!important;position:relative;flex-wrap:nowrap!important;gap:4px!important;min-height:39px!important;border:1px solid #e4deed!important;border-radius:8px!important;padding:6px 10px!important;background:#fff!important;box-shadow:none;overflow:visible!important;isolation:auto} +#route-select .container,#route-select .wrap-inner {min-width:0!important;width:100%!important} +#route-select .secondary-wrap {min-width:0!important;width:100%!important;display:flex!important;align-items:center;gap:6px} +#route-select input {position:static!important;flex:1 1 0!important;min-width:0!important;width:100%!important;height:auto!important;opacity:1!important;margin:0!important;padding:0!important;color:#172018!important;font:750 12px var(--ui)!important} +#route-select .icon-wrap {flex:0 0 14px!important;width:14px!important;height:14px!important} +#route-select svg,#advanced-options>.label-wrap svg {width:14px!important;height:14px!important;color:var(--muted)} +#console .wrap.hide {display:none!important} +#route-select .wrap:focus-within {border-color:var(--green)!important;outline:2px solid #ddd0ee} +#route-select ul {z-index:60!important;background:#fff!important;color:var(--ink)!important;border:1px solid var(--line);border-radius:8px!important;box-shadow:0 12px 28px rgba(25,49,31,.14)} +#route-select li {font:650 13px var(--ui)!important} +#route-select li:hover {background:var(--selection)!important} +#upload-button {width:100%!important;flex:0 0 auto!important;min-width:0!important;min-height:48px!important;border:1px dashed #c1dca6!important;border-radius:8px!important;padding:12px!important;background:#fcfbfe!important;color:#30263f!important;font:750 12px var(--ui)!important;box-shadow:none!important;text-align:left;justify-content:flex-start;gap:10px} +#upload-button:hover {background:#f3eef9!important;border-color:var(--green)!important} +#upload-button::before {content:"";display:block;width:18px;height:18px;flex-shrink:0;background:var(--green);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6'%3E%3Cpath d='M11 3H4v14h13v-7M13 4h6M16 1v6M4 14l4-4 3 3 2-2 4 4'/%3E%3Ccircle cx='8' cy='7' r='1'/%3E%3C/svg%3E") center/contain no-repeat} +#advanced-options {border:0!important;border-top:1px solid #e9e5ef!important;border-bottom:1px solid #e9e5ef!important;border-radius:0!important;background:transparent!important;padding:0!important} +#advanced-options>.label-wrap {display:flex!important;align-items:center;justify-content:space-between;width:100%!important;padding:10px 0!important;font:750 10px var(--mono)!important;letter-spacing:.055em;text-transform:uppercase;min-height:39px!important;color:var(--muted)!important;gap:4px} +#advanced-options>.label-wrap>span,#prompt-console>.label-wrap>span,#output-console>.label-wrap>span,#source-details>.label-wrap>span {font:inherit!important;color:inherit!important;letter-spacing:inherit} +#advanced-options>.label-wrap>.icon {flex-shrink:0;font-size:10px!important} +#advanced-options>.label-wrap {overflow:hidden!important;font-family:var(--ui)!important;font-size:12px!important;letter-spacing:0!important} +#advanced-options>.label-wrap>span {min-width:0;overflow-wrap:anywhere} +.runtime-options {display:grid;grid-template-columns:auto 1fr;gap:10px;font:12px/1.6 var(--ui);color:var(--muted);padding:10px 0} +.runtime-options b {text-align:right;overflow-wrap:anywhere;color:var(--ink);font-weight:650} +.runtime-options small {grid-column:1/-1;font-size:11px;line-height:1.7} +#service-panel {padding-top:12px!important;border-top:1px solid var(--line);gap:7px!important} +.api-status {align-items:center;gap:7px}.api-status b {font-size:12px}.api-status small {flex-basis:100%;font:400 12px/1.65 var(--ui);color:var(--muted)} +.connection-detail {font:12px/1.6 var(--ui);color:var(--muted)} +.connection-detail summary {cursor:pointer;padding:4px 0}.connection-detail code {display:block;max-height:90px;overflow:auto;overflow-wrap:anywhere;font:11px/1.6 var(--mono)} +.api-status,.api-status span {font:12px/1.65 var(--ui);color:var(--muted)} +.api-status.online {color:#168a45}.api-status.offline {color:#a53246} +#health-button {font:12px var(--ui)!important;min-height:36px!important;text-decoration-color:#9dba89} +#run-button {display:flex!important;align-items:center;justify-content:center;gap:10px;margin-top:auto!important;flex:0 0 auto!important;width:100%!important;min-width:0!important;min-height:54px!important;border-radius:999px!important;color:#0b1408!important;background:linear-gradient(180deg,#a3d749,#91c331)!important;font:850 16px var(--ui)!important;box-shadow:0 20px 40px rgba(118,184,38,.28),inset 0 1px 0 rgba(255,255,255,.5)!important} +#run-button::before {content:"";width:17px;height:17px;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6'%3E%3Cpath d='m5 3 11 7-11 7Z'/%3E%3C/svg%3E") center/contain no-repeat} +#run-button:hover:not(:disabled) {background:linear-gradient(180deg,#ade153,#98ca39)!important} +#run-button:disabled {background:#edf4e7!important;color:#536947!important;box-shadow:none!important} +#run-button.is-waiting {color:transparent!important}#run-button.is-waiting::before {visibility:hidden} +#mobile-run-button {display:none!important} +#task-guide {padding:20px 24px 0!important} +.task-guide {display:grid;gap:5px}.task-guide strong {font:750 17px/1.4 var(--ui);color:var(--ink)} +.task-guide p {margin:0;color:#51495e;font:500 13px/1.6 var(--ui)} +.task-guide small {color:var(--muted);font:400 12px/1.6 var(--ui)} +#visual-stage {position:relative;isolation:isolate;flex:1 1 0!important;min-width:0!important;gap:0!important;padding:0!important;overflow:hidden;border-radius:0 8px 8px 0;background:transparent} +#stage-toolbar {position:relative!important;width:100%;z-index:8;display:flex;flex-wrap:nowrap!important;align-items:center;justify-content:space-between;gap:12px!important;min-height:64px;padding:18px 22px 8px!important;background:transparent!important} +#view-toggle {flex:0 0 auto!important;width:fit-content!important;min-width:0!important;pointer-events:auto} +#view-toggle .wrap {position:relative;isolation:isolate;padding:3px!important;gap:2px!important;background:#f2eff7!important;border:1px solid #e4deed;border-radius:8px!important;backdrop-filter:none;-webkit-backdrop-filter:none;box-shadow:none} +#view-toggle label {border-radius:6px!important;min-height:30px!important;padding:6px 10px!important;font:700 11px var(--ui)!important;color:#657083!important} +#view-toggle label:hover {background:#eee7f7!important} +#view-toggle label:has(input:checked) {color:#30263f!important} +#view-toggle .active-tab-indicator {border-radius:6px;background:#fff;box-shadow:0 2px 5px rgba(30,48,35,.08);transition-duration:200ms} +#stage-status {flex:1 1 0!important;width:auto!important;min-width:0!important;min-height:0!important;max-width:47%;padding:0!important} +.stage-status {display:flex;gap:7px;padding:6px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;font:600 12px/1.6 var(--ui);color:#30263f;box-shadow:none} +.stage-status span {color:inherit}.stage-status i {margin-top:5px}.stage-status.ready i {background:#784ebc} +.stage-status.reference {color:#5b358b}.stage-status.busy {color:#536947}.stage-status.error {color:#a53246} +.wait-clock {font:700 11px var(--mono);font-variant-numeric:tabular-nums} +#canvas-viewport {padding:16px 54px 48px!important;background:transparent!important;isolation:auto} +#stage-image {height:400px!important;transition-duration:300ms} +#stage-image img {border-radius:8px;box-shadow:0 26px 58px rgba(45,29,69,.09),0 0 0 1px #d9e3d9;filter:none} +.canvas-tools {min-height:48px;padding:8px 24px;font:10px var(--mono);color:var(--muted)} +.image-dimensions {padding:5px 8px;background:#fff;border:1px solid var(--line);border-radius:6px} +.zoom-tools {padding:2px 4px;border:1px solid var(--line);border-radius:8px;background:#fff;box-shadow:none} +.zoom-tools button {width:28px;height:28px;border-radius:5px;color:#657083}.zoom-tools button:hover {background:#eee7f7} +.zoom-value {font:700 10px var(--mono);color:#30263f}.tool-divider {background:var(--line)} +#query-row {position:relative;z-index:2;display:block!important;padding:10px 54px 28px!important;background:transparent!important;border:0!important} +#query-dock {max-width:600px;margin:0 auto!important;padding:12px 15px!important;border:1px solid #e4deed!important;border-radius:8px!important;background:#fff!important;box-shadow:0 18px 42px rgba(45,29,69,.06)!important} +#query-dock textarea {font:700 13px/1.65 var(--ui)!important;color:#30263f!important} +#query-dock:focus-within {outline:2px solid #9873c8;outline-offset:2px} +.query-hint {margin:9px 0 0;text-align:center;color:var(--muted);font:650 11px/1.6 var(--ui)} +#review-row {display:flex!important;flex-wrap:nowrap!important;gap:24px!important;align-items:stretch} +#sandbox-panel {flex:0 0 38%!important;min-width:0!important;padding:20px!important;gap:15px!important;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 16px 40px rgba(45,29,69,.04)} +.film-heading {align-items:center;gap:12px}.film-heading h2 {font:800 11px/1.5 var(--mono);letter-spacing:.07em;text-transform:uppercase;color:var(--muted);margin:0!important} +.film-heading small {font:650 11px/1.5 var(--ui);color:var(--green);flex-shrink:0} +#case-gallery {height:166px!important} +#case-gallery .grid-container {gap:10px!important;grid-template-columns:repeat(3,minmax(0,1fr))!important} +#case-gallery .thumbnail-item {min-width:0!important;height:150px!important;flex-direction:column!important;align-items:stretch;gap:6px;border-radius:8px!important;background:#fff!important;border-color:var(--line)!important;padding:6px!important;box-shadow:0 6px 16px rgba(28,52,34,.05)} +#case-gallery .thumbnail-item img {width:100%!important;height:106px!important;flex:1 1 0!important;min-height:0!important;border-radius:6px!important} +#case-gallery .caption-label {max-width:100%!important;text-align:center!important;font:800 11px/1.5 var(--ui)!important;color:#30263f!important;padding:3px!important} +#case-gallery .thumbnail-item:hover {border-color:#9873c8!important;background:#fcfbfe!important} +#case-gallery .thumbnail-item.selected {background:#f3eef9!important;border:2px solid #91c331!important;padding:5px!important} +#source-details {margin-top:auto;border:0!important;border-top:1px solid #e9e5ef!important;padding:8px 0 0!important} +#source-details .label-wrap {font:650 11px var(--ui)!important;min-height:30px!important;color:var(--muted)!important} +.source-meta {font:12px/1.7 var(--ui)}.source-meta>span,.source-meta small {font-size:11px} +#review-summary {flex:1 1 0!important;min-width:0!important;padding:18px!important;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 18px 45px rgba(45,29,69,.04)} +#result-columns {display:flex!important;flex-wrap:nowrap!important;gap:16px!important;align-items:stretch} +#metrics-panel {flex:0 0 40%!important;min-width:0!important;padding:14px!important;border:0!important;border-radius:0;gap:14px!important;box-shadow:none;background:#fff} +.inspector-subheading,#sidebar .inspector-heading h2 {font:800 11px/1.5 var(--mono)!important;letter-spacing:.06em;text-transform:uppercase;color:var(--green)!important;margin:0!important} +.metrics-list {font:11px var(--mono)}.metrics-list>div {border-top:1px solid #e9e5ef;padding:9px 0;gap:14px} +.metrics-list dd {font:750 11px/1.6 var(--mono);color:#30263f} +#sidebar {flex:1 1 0!important;min-width:0!important;width:auto;padding:14px!important;border:0;border-left:1px solid var(--line);border-radius:0;background:#fff;gap:14px!important;box-shadow:none} +#sandbox-panel>*,#metrics-panel>*,#sidebar>* {flex-grow:0!important} +.inspector-heading {align-items:flex-start;flex-direction:column;gap:6px}.live-mark {font:11px/1.6 var(--ui);color:var(--muted)} +#targets-panel {flex:1 1 auto!important} +#targets-content {overflow-x:hidden!important} +#targets-content .target-chips {margin-left:0;margin-right:0;max-width:100%;box-sizing:border-box} +.empty-targets {min-height:172px;gap:10px}.empty-targets svg {width:26px;height:26px;color:#819275;margin:0} +.empty-targets>b {font:700 12px var(--mono);color:var(--muted)}.empty-targets>small {font:11px/1.8 var(--ui);color:var(--muted);max-width:28ch} +.targets-summary {font:12px var(--ui)}.targets-summary b {font:800 18px var(--ui)}.targets-summary>span {font-size:11px} +.target-chips {max-height:240px;display:flex;flex-direction:column;gap:4px} +.target-chip {min-height:36px!important;padding:7px 9px!important;border:1px solid #e4deed!important;border-radius:6px!important;background:#fcfbfe!important;font:600 12px var(--ui)!important;color:#30263f!important} +.target-chip:hover {background:#f3eef9!important}.target-chip[aria-pressed=true] {background:#eee7f7!important;color:#5b358b!important;border-color:#91c331!important} +.target-chip i {border-color:#9873c8}.target-chip b {font:700 11px var(--mono);color:var(--green)} +.focus-help,.targets-caption {font:11px/1.7 var(--ui)}.clear-focus {font:650 11px var(--ui)} +.detail-heading {font:700 12px var(--ui)}.detail-heading small {font:11px var(--ui)}.detail-image {height:150px;border-radius:6px}.detail-coordinates {font-size:11px;line-height:1.6} +.focus-dimmer {fill:#172018;opacity:.24;animation-duration:180ms}.focus-outline {stroke:#a3d749;animation-duration:220ms} +.focus-pixels {position:absolute!important;pointer-events:none;z-index:4;object-fit:fill!important;box-shadow:none!important} +.focus-source[hidden] {display:none!important} +.focus-caption {top:auto;bottom:60px;left:22px;right:auto!important;width:fit-content!important;max-width:calc(100% - 44px);padding:5px 6px 5px 12px;border:1px solid var(--line);border-radius:8px;background:#fff;color:#30263f;font:650 12px var(--ui);box-shadow:0 4px 14px rgba(25,49,31,.1)} +.focus-caption span {white-space:normal;overflow-wrap:anywhere;line-height:1.5;max-height:60px} +.focus-caption button:disabled {opacity:.35;cursor:default} +.focus-caption button {background:#eee7f7;color:#5b358b;border-radius:5px} +#prompt-console,#output-console {margin-top:4px!important;padding:18px!important;border:1px solid var(--line)!important;border-radius:8px!important;background:#fff!important;box-shadow:0 16px 40px rgba(45,29,69,.04)} +#prompt-console>.label-wrap,#output-console>.label-wrap {font:800 11px var(--mono)!important;letter-spacing:.06em;text-transform:uppercase;min-height:30px;color:var(--green)!important} +#prompt-console .block {border-color:#e4deed!important;border-radius:7px!important;background:#fcfef9!important} +#prompt-console textarea,#output-console textarea {background:#fff!important;border-color:var(--line)!important;color:#30263f!important;font:12px/1.8 var(--mono)!important} +#prompt-console label>span,#output-console label>span {color:var(--green)!important;font:700 10px var(--mono)!important} +.console-note {font:11px/1.7 var(--ui);color:var(--muted)} +#output-console .cm-editor {max-height:360px;overflow:hidden} +#output-console .cm-scroller {max-height:330px;overflow:auto!important} +#output-console .cm-content {min-height:0!important} +#prompt-console textarea {max-height:220px!important;overflow-y:auto!important} +.studio-footer {padding:12px 2px;font:11px/1.7 var(--ui);color:var(--muted)}.studio-footer i {color:var(--muted)} +@keyframes focus-dim {from{opacity:0}to{opacity:.24}} +@media(min-width:1500px) { + #controls {padding:42px 42px 34px!important}.xpeng-logo {width:220px} + #stage-image {height:440px!important}#canvas-viewport {padding:16px 60px 48px!important}#query-row {padding:12px 60px 30px!important} +} +@media(max-width:1100px) { + .studio-header h1 {font-size:28px}.studio-header .eyebrow {font-size:10px}.grounding-intro h2 {font-size:22px}.grounding-intro p {max-width:220px;font-size:12px} + #controls {flex-basis:30%!important;min-width:260px!important;padding:26px 22px!important;gap:20px!important} + .control-brand h2 {font-size:30px}.xpeng-logo {width:172px}.control-brand p {font-size:13px} + #control-settings {padding:12px!important}#control-fields {gap:9px!important} + #control-fields {flex-direction:column!important}#control-fields>.form {width:100%!important;flex-basis:auto!important}#media-type {flex-basis:auto!important} + #stage-toolbar {padding:16px 18px 8px!important;gap:10px!important;flex-wrap:wrap!important}#stage-status {max-width:100%;flex-basis:100%!important}.stage-status {width:fit-content} + #canvas-viewport {padding:12px 24px 48px!important}#stage-image {height:350px!important}#query-row {padding:12px 24px 24px!important} + #sandbox-panel {padding:16px!important}.film-heading {align-items:flex-start;flex-direction:column;gap:4px}#review-row {gap:18px!important} + #review-summary {padding:12px!important}#result-columns {gap:12px!important}#metrics-panel {flex-basis:43%!important;padding:12px!important}#sidebar {padding:12px!important} + #case-gallery {height:150px!important}#case-gallery .thumbnail-item {height:136px!important} + .metrics-list>div {gap:8px}.metrics-list,.metrics-list dd {font-size:10px} +} +@media(max-width:760px) { + .header-scope {display:none}.header-description {font-size:12px;margin-top:5px} + .studio-header {padding:4px 0 18px;gap:12px}.chapter-mark {width:36px;height:36px;flex-basis:36px}.studio-header h1 {font-size:25px}.studio-header .eyebrow {font-size:9px;line-height:1.6} + .grounding-intro {display:block;padding:0 0 10px}.grounding-intro h2 {font-size:20px;line-height:1.35}.grounding-intro p {max-width:none;margin-top:8px;text-align:left;font-size:12px}.eyebrow {font-size:10px} + #workspace-top {flex-direction:column!important;min-height:0;border-radius:8px}#console {gap:14px!important} + #controls {flex:0 0 auto!important;min-width:0!important;padding:24px!important;border-right:0;border-bottom:1px solid var(--line);border-radius:8px 8px 0 0;gap:20px!important} + .control-brand {gap:10px}.control-brand h2 {font-size:32px}.control-brand p {font-size:13px}.xpeng-logo {width:160px} + #control-settings {padding:14px!important;gap:12px!important}#control-fields {gap:14px!important}#media-type {flex-basis:43%!important} + #controls {padding:16px!important;gap:12px!important} + .control-brand {display:flex;align-items:center;gap:12px;flex-wrap:wrap} + .control-brand .xpeng-logo {width:104px;filter:none}.control-brand h2 {font-size:24px;margin:0}.control-brand p {display:none} + #control-settings {padding:0!important;border:0;gap:8px!important} + #control-fields {flex-direction:row!important;gap:12px!important}#control-fields>.form {width:0!important;flex:1 1 0!important} + #media-type {flex:0 0 30%!important} + #upload-button {min-height:40px!important;padding:8px 10px!important} + #service-panel {padding-top:8px!important;gap:2px!important}.api-status small {font-size:11px} + #service-panel #health-button {min-height:32px!important} + #run-button {display:none!important} + #task-guide {padding:14px 16px 0!important}.task-guide {gap:4px}.task-guide strong {font-size:15px}.task-guide small {font-size:11px} + #mobile-run-button {display:flex!important;align-items:center;justify-content:center;width:100%;min-height:48px!important;margin-top:12px;border-radius:999px!important;border:0!important;background:linear-gradient(180deg,#a3d749,#91c331)!important;color:#0b1408!important;font:800 15px var(--ui)!important} + #mobile-run-button:disabled {background:#edf4e7!important;color:#536947!important} + #run-button {min-height:48px!important;font-size:15px!important;margin-top:4px!important} + #visual-stage {flex:0 0 auto!important;min-width:0!important;border-radius:0 0 8px 8px} + #stage-toolbar {padding:14px 14px 8px!important;gap:10px!important}#view-toggle label {padding:8px 12px!important;min-height:36px!important;font-size:11px!important} + #stage-status {max-width:100%;width:100%;flex-basis:100%!important}.stage-status {font-size:10px;width:fit-content} + #canvas-viewport {padding:12px 14px 52px!important}#stage-image {height:300px!important} + .canvas-tools {padding:4px 12px}.zoom-tools button {width:44px;height:44px} + .focus-caption {left:14px;max-width:calc(100% - 28px);gap:4px;bottom:62px;padding-left:8px} + .focus-caption button {width:44px;height:44px}.focus-caption span {font-size:11px} + #query-row {padding:12px 16px 22px!important}#query-dock {padding:12px!important}#query-dock textarea {font-size:12px!important} + .query-hint {font-size:10px} + #review-row {flex-direction:column!important;gap:14px!important}#sandbox-panel {flex:0 0 auto!important;padding:18px!important;gap:12px!important}.film-heading {flex-direction:row;align-items:center}.film-heading h2 {font-size:10px}.film-heading small {font-size:10px} + #case-gallery {height:140px!important}#case-gallery .thumbnail-item {height:128px!important}#case-gallery .grid-container {gap:8px!important}#case-gallery .caption-label {font-size:10px!important} + #review-summary {flex:0 0 auto!important;padding:14px!important}#result-columns {flex-direction:column!important;gap:14px!important} + #metrics-panel {flex:0 0 auto!important;padding:16px!important}#sidebar {flex:0 0 auto!important;min-width:0!important;padding:16px!important;border:1px solid var(--line)} + .metrics-list {grid-template-columns:1fr 1fr;gap:2px 18px}.metrics-list>div {gap:4px}.metrics-list,.metrics-list dd {font-size:11px} + .empty-targets {min-height:150px}.target-chips {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.target-chip {min-height:44px!important} + .inspector-heading {flex-direction:row;flex-wrap:wrap;align-items:baseline}.live-mark {font-size:10px}.detail-image {height:170px} + #prompt-console,#output-console {padding:14px!important}#prompt-console>.label-wrap,#output-console>.label-wrap {font-size:10px!important}.studio-footer {font-size:10px} +} +@media(max-width:430px) { + #controls {padding:14px!important}#stage-image {height:262px!important}.film-heading {gap:8px}.film-heading h2 {max-width:160px}.image-dimensions {font-size:9px} +} +@media(prefers-reduced-motion:reduce) { + *,*::before,*::after {animation:none!important;transition-duration:0ms!important;scroll-behavior:auto!important} +} + +/* Paper-demo r7: scoped refinements, same left-controls / right-canvas layout. */ +.control-brand h2 {color:var(--purple-deep);letter-spacing:-.04em} +.control-brand h2 span {color:var(--lime)} +.control-brand p {font-weight:500;color:var(--muted)} +.studio-header h1 {color:var(--purple-deep);letter-spacing:-.035em} +.header-description {max-width:720px;font-weight:450} +.header-scope {font:650 10px/1.5 var(--mono);letter-spacing:.08em;color:var(--purple)} +.xpeng-logo {filter:none} +.task-guide strong {color:var(--purple-deep)} +#stage-toolbar {min-height:44px;padding-top:12px!important} +#stage-status {max-width:100%;flex:1!important} +.stage-status {background:#fff;color:#51495e;width:fit-content} +#stage-image .buttons {display:none!important} +#canvas-viewport {padding-bottom:64px!important} +#stage-image img {box-shadow:0 14px 34px rgba(45,29,69,.09);border-radius:4px} +#run-button {box-shadow:0 8px 22px rgba(114,153,34,.18)!important} +#query-dock textarea {font-weight:550!important} +.query-hint {font-weight:500} +.inspector-subheading,#sidebar .inspector-heading h2,#prompt-console>.label-wrap,#output-console>.label-wrap {color:var(--purple-deep)!important} +.film-heading h2 {color:var(--purple-deep)} +.target-chip i {background:var(--category-color)!important;border-color:var(--category-color)!important} +.focus-caption {position:relative;bottom:auto;left:auto;max-width:100%;margin:8px 0 0} +#canvas-viewport:has(.focus-caption) {padding-bottom:64px!important} +.detail-heading {flex-wrap:wrap;gap:4px} +.canvas-download {display:grid;place-items:center;width:28px;height:28px;border-radius:5px;color:var(--purple-deep);cursor:pointer} +.canvas-download:hover {background:var(--lavender)} +.canvas-download:focus-visible {outline:2px solid var(--purple);outline-offset:2px} +#console .translucent {opacity:1!important} +@media(max-width:760px) { + .studio-header h1 {font-size:25px} + .header-description {font-size:12px;line-height:1.6} + .focus-caption {max-width:100%;left:auto;bottom:auto;margin-top:8px} + .focus-caption span {font-size:11px} + .film-heading {flex-wrap:wrap} + .canvas-download {width:44px;height:44px} +} diff --git a/assets/paper.css b/assets/paper.css new file mode 100644 index 0000000000000000000000000000000000000000..19a1eb589fdcb5e8cef8735861688848c1bc2b00 --- /dev/null +++ b/assets/paper.css @@ -0,0 +1,62 @@ +@font-face{font-family:Manrope;src:url(data:font/ttf;base64,__MANROPE_DATA__) format('truetype');font-weight:200 800;font-display:swap} +:root{--purple:#7651aa;--purple-deep:#563a80;--lime:#afd064;--ink:#292633;--muted:#686371;--line:#e5e1eb;--paper:#f3f1f7;--lavender:#ebe5f4;--canvas:#e9e6ef;--ease:cubic-bezier(.16,1,.3,1);--ui:Manrope,"PingFang SC","Microsoft YaHei",sans-serif} +body{background:var(--paper)!important;color-scheme:light} +.gradio-container{max-width:1660px!important;margin:0 auto!important;padding:22px 32px 18px!important;font-family:var(--ui)!important;background:var(--paper)!important;color:var(--ink)!important;--body-text-color:var(--ink);--body-text-color-subdued:var(--muted);--block-background-fill:#fff;--input-background-fill:#fff;--block-border-color:var(--line);--input-border-color:var(--line);--block-radius:12px;--color-accent:var(--purple);--checkbox-background-color-selected:var(--purple)} +*{scrollbar-width:thin;scrollbar-color:#c9bdd9 transparent;box-sizing:border-box} +::selection{background:#dcd0ed;color:#40275e}input,textarea{caret-color:var(--purple)} +button,a,input,textarea{font-family:var(--ui)}:is(button,a,input,textarea):focus-visible{outline:2px solid var(--purple)!important;outline-offset:3px} +button{-webkit-tap-highlight-color:transparent}button:disabled{cursor:wait!important}.gap{gap:12px}.html-container{padding:0!important} +.form{background:transparent!important;border:0!important;box-shadow:none!important;overflow:visible!important} +.studio-header{display:flex;justify-content:space-between;align-items:center;gap:22px;padding:4px 0 20px}.studio-identity{display:flex;align-items:center;gap:16px;min-width:0} +.xpeng-logo{display:block;width:118px;height:auto;object-fit:contain;border-radius:3px;margin:0!important}.brand-divider{height:28px;width:1px;background:#d6cfdf;margin:0 3px} +.studio-identity h1{font:800 28px/1.2 var(--ui)!important;letter-spacing:-.035em;color:var(--purple-deep)!important;margin:0!important;white-space:nowrap}.studio-name{color:var(--muted);font:500 13px var(--ui);padding-top:6px;white-space:nowrap} +.header-note{font:500 12px var(--ui);color:var(--muted);display:flex;gap:22px;align-items:center;white-space:nowrap}.header-note>span{padding:6px 10px;border:1px solid #d7cede;border-radius:6px;font-size:11px;color:var(--purple-deep)} +#controls{gap:0!important;min-width:0!important;margin-bottom:5px}#route-select{padding:0!important;border:0!important;background:transparent!important;min-width:0!important;overflow:visible!important} +#route-select .wrap{display:flex!important;flex-wrap:nowrap!important;gap:2px!important;position:relative;overflow-x:auto!important;scrollbar-width:none;padding:4px 2px 12px} +#route-select label{flex:1 0 auto;display:flex!important;justify-content:center;align-items:center;min-height:42px!important;padding:10px 16px!important;border:0!important;box-shadow:none!important;background:transparent!important;color:#655c72!important;font:650 12px var(--ui)!important;white-space:nowrap;border-radius:9px!important;gap:0!important;z-index:1;transition:color 180ms} +#route-select label:hover{color:var(--purple-deep)!important;background:#eae4f1!important}#route-select label:has(input:checked){color:#fff!important;background:var(--purple-deep)!important}#route-select.enhanced label:has(input:checked){background:transparent!important} +#route-select input,#view-toggle input{position:absolute;width:0!important;height:0!important;opacity:0;margin:0!important}#route-select label:has(input:focus-visible),#view-toggle label:has(input:focus-visible){outline:2px solid var(--purple);outline-offset:2px} +.active-tab-indicator{position:absolute;left:0;top:0;background:var(--purple-deep);border-radius:9px;pointer-events:none;z-index:0;transition:transform 340ms var(--ease);height:42px} +#console{flex-wrap:nowrap!important;gap:0!important;align-items:stretch;background:#fff;border:0;border-radius:16px;overflow:hidden;box-shadow:0 16px 48px #44365312} +#visual-stage{flex:1 1 0!important;min-width:0!important;gap:0!important;padding:0!important;background:#fff;position:relative} +#visual-stage>*,#sidebar>.block{flex-grow:0!important} +#stage-toolbar{flex-wrap:nowrap!important;align-items:center;justify-content:space-between;gap:16px!important;padding:14px 20px!important;background:#fff;min-height:66px} +#view-toggle{min-width:0!important;flex:1 1 auto!important;padding:0!important;background:transparent!important;border:0!important}#view-toggle .wrap{display:flex;gap:2px!important;position:relative;isolation:isolate;padding:3px;width:fit-content;background:#f1eef5;border-radius:9px} +#view-toggle label{min-height:32px!important;padding:7px 15px!important;justify-content:center;border:0!important;border-radius:6px!important;background:transparent!important;color:#665d73!important;box-shadow:none!important;font:600 12px var(--ui)!important;gap:0!important;z-index:1;transition:color 160ms} +#view-toggle label:hover{color:var(--purple-deep)!important;background:#e7dfef!important}#view-toggle label:has(input:checked){background:#fff!important;color:var(--purple-deep)!important;box-shadow:0 2px 5px #3c2b5410!important}#view-toggle.enhanced label:has(input:checked){background:transparent!important;box-shadow:none!important}#view-toggle .active-tab-indicator{background:#fff;border-radius:6px;box-shadow:0 2px 5px #3c2b5410;z-index:-1} +#upload-button{flex:0 0 104px!important;min-width:104px!important;min-height:36px!important;background:#fff!important;border:1px solid var(--line)!important;border-radius:7px!important;box-shadow:none!important;padding:8px 12px!important;color:var(--purple-deep)!important;font:650 12px var(--ui)!important;transition:background 150ms,border-color 150ms}#upload-button:hover{background:#f4f0f8!important;border-color:#ad97c7!important} +#canvas-viewport{position:relative;overflow:hidden!important;border-radius:0!important;background:var(--canvas);min-width:0!important;gap:0!important;padding:20px 24px 48px!important;isolation:isolate} +#stage-image{position:relative!important;isolation:isolate;min-width:0!important;height:clamp(350px,48vh,570px)!important;min-height:0!important;background:transparent!important;border:0!important;padding:0!important;border-radius:0!important;box-shadow:none!important;transform-origin:50% 50%;transition:transform 430ms var(--ease);overflow:visible!important;touch-action:pan-y} +#canvas-viewport.is-panning #stage-image{transition:none!important}#canvas-viewport.is-zoomed #stage-image{touch-action:none;cursor:grab}#canvas-viewport.is-panning #stage-image{cursor:grabbing} +#stage-image img{object-fit:contain!important;border-radius:3px;box-shadow:0 9px 22px #251b3b13}#stage-image .image-container{background:transparent!important}#stage-image .buttons{opacity:0;transition:opacity 160ms}#stage-image:hover .buttons,#stage-image:focus-within .buttons{opacity:1} +#canvas-chrome{position:absolute!important;bottom:0;left:0;width:100%;min-height:0!important;z-index:8;pointer-events:none}.canvas-tools{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:8px 18px;color:#655c72;font:500 10px ui-monospace,monospace;min-height:44px}.image-dimensions{font-variant-numeric:tabular-nums;white-space:nowrap} +.zoom-tools{display:flex;align-items:center;gap:3px;background:#fff;border-radius:8px;padding:2px 4px;box-shadow:0 3px 9px #3121410c;pointer-events:auto}.zoom-tools button{border:0;background:transparent;color:var(--purple-deep);width:30px;height:30px;display:grid;place-items:center;border-radius:5px;cursor:pointer}.zoom-tools button:hover{background:var(--lavender)}.zoom-tools button:disabled{opacity:.35;cursor:default!important}.zoom-tools svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.zoom-value{font:650 10px ui-monospace,monospace;min-width:42px;text-align:center;color:var(--purple-deep)}.tool-divider{width:1px;height:15px;background:var(--line);margin:0 3px} +#query-row{display:flex;flex-wrap:nowrap!important;align-items:center;gap:16px!important;padding:17px 22px!important;background:#fff;border-bottom:1px solid var(--line)}#query-dock{flex:1 1 0!important;min-width:0!important;background:transparent!important;border:0!important;padding:0!important;border-radius:0!important;box-shadow:none!important} +#query-dock label>span{font:750 12px var(--ui)!important;color:var(--purple-deep)!important;margin-bottom:7px!important}#query-dock textarea{border:0!important;box-shadow:none!important;padding:0!important;background:transparent!important;color:var(--ink)!important;font:500 12px/1.65 var(--ui)!important;resize:none!important}#query-dock textarea::placeholder{color:var(--muted);opacity:1}#query-dock:focus-within label>span{color:#8059b1!important} +#run-button{flex:0 0 136px!important;min-width:136px!important;min-height:46px!important;border:0!important;border-radius:9px!important;background:var(--lime)!important;color:#2c4018!important;font:800 14px var(--ui)!important;padding:12px 18px!important;box-shadow:none!important;transition:background 150ms,transform 150ms var(--ease)}#run-button:hover:not(:disabled){background:#bfdc81!important}#run-button:active:not(:disabled){transform:scale(.975)}#run-button:disabled{background:var(--lavender)!important;color:var(--purple-deep)!important;opacity:1!important}#run-button.is-waiting{position:relative;color:transparent!important}#run-button.is-waiting::after{content:"Grounding…";position:absolute;inset:0;display:grid;place-items:center;color:var(--purple-deep)} +#sandbox-panel{padding:15px 22px 19px!important;background:#fff;gap:10px!important;min-width:0!important}.film-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;color:#62596f;font:700 11px var(--ui)}.film-heading small{font:500 10px var(--ui);color:var(--muted)} +#case-gallery{background:transparent!important;border:0!important;padding:0!important;min-height:0!important}#case-gallery .grid-wrap{border:0!important}#case-gallery .grid-container{gap:12px!important;padding:3px!important;grid-template-rows:1fr!important;height:100%!important} +#case-gallery .thumbnail-item{aspect-ratio:auto!important;height:112px!important;min-height:0!important} +#case-gallery .thumbnail-item{display:flex!important;flex-direction:row;align-items:center;gap:11px;border:1px solid var(--line)!important;border-radius:9px!important;background:#fff!important;padding:5px!important;overflow:hidden!important;transition:border-color 180ms,background 180ms}#case-gallery .thumbnail-item:hover{border-color:#b49dcf!important;background:#faf7fd!important}#case-gallery .thumbnail-item.selected{border:2px solid #a387c3!important;background:#f5f0fa!important;padding:4px!important}#case-gallery .thumbnail-item img{width:62%!important;height:100%!important;object-fit:cover!important;border-radius:5px!important;min-width:0!important;flex:0 0 62%}#case-gallery .caption-label{position:static!important;white-space:normal!important;word-break:normal;overflow-wrap:anywhere;background:transparent!important;color:var(--purple-deep)!important;font:700 11px/1.6 var(--ui)!important;padding:4px!important;max-width:36%!important;text-align:left!important;box-shadow:none!important} +#sidebar{flex:0 0 290px!important;min-width:290px!important;padding:22px!important;background:#fcfbfe;border-left:1px solid var(--line);gap:16px!important}.inspector-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.inspector-heading h2{font:750 17px var(--ui)!important;color:var(--ink)!important;margin:0!important;letter-spacing:-.02em}.live-mark{font:500 10px var(--ui);color:#746b7e} +#targets-content{flex-grow:0!important}.target-chips{max-height:232px}#sidebar:has(.evidence-detail:not([hidden])) .target-chips{max-height:184px} +#stage-status{min-height:32px}.stage-status{display:flex;align-items:flex-start;gap:7px;font:550 11px/1.65 var(--ui);color:#5b6e40;overflow-wrap:anywhere;flex-wrap:wrap}.stage-status>span{flex:1;min-width:0}.stage-status i,.api-status i{width:6px;height:6px;border-radius:50%;background:#8b8790;flex-shrink:0;margin-top:6px}.stage-status.ready i,.api-status.online i{background:#729642}.stage-status.reference,.stage-status.busy{color:var(--purple-deep)}.stage-status.reference i{background:var(--purple)}.stage-status.error,.api-status.offline{color:#a53246}.stage-status.error i,.api-status.offline i{background:#b54559}.stage-status.busy i{width:10px;height:10px;border:2px solid #cbbbdc;border-top-color:var(--purple);background:transparent;animation:wait-turn .9s linear infinite;margin-top:4px}.wait-clock{font:600 11px ui-monospace,monospace;font-variant-numeric:tabular-nums;color:var(--purple-deep)}.tab-hidden .stage-status.busy i{animation-play-state:paused} +#targets-panel{min-width:0!important;flex:1 1 0!important;gap:0!important}.empty-targets{min-height:205px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center;color:#71617f}.empty-targets svg{width:40px;height:40px;color:#9175b0;margin-bottom:5px}.empty-targets>b{font:700 13px var(--ui);color:#5e4f70}.empty-targets>small{font:500 11px/1.8 var(--ui);color:var(--muted);max-width:23ch} +.targets-summary{font:550 11px var(--ui);display:flex;align-items:baseline;gap:5px;color:var(--muted)}.targets-summary b{font:750 18px var(--ui);color:var(--purple-deep);font-variant-numeric:tabular-nums}.targets-summary>span{margin-left:auto;font-size:10px}.target-chips{display:flex;flex-direction:column;gap:2px;max-height:282px;overflow:auto;padding:3px;margin:12px -3px 0} +.target-chip{display:flex;align-items:center;gap:9px;min-height:33px;padding:7px 9px!important;background:transparent!important;border:0!important;border-radius:6px!important;font:550 11px var(--ui)!important;color:#594e67!important;cursor:pointer;transition:background 160ms,color 160ms}.target-chip:hover{background:#f0eaf7!important}.target-chip[aria-pressed=true]{background:#e8ddf3!important;color:#4f326f!important}.target-chip>span{flex:1;text-align:left;overflow-wrap:anywhere}.target-chip i{width:6px;height:6px;border:1.5px solid #a186bc;border-radius:2px;flex-shrink:0}.target-chip[aria-pressed=true] i{background:var(--purple);border-color:var(--purple)}.target-chip b{font:600 10px ui-monospace,monospace;color:#756385} +.focus-help{font:500 10px/1.6 var(--ui);color:var(--muted);display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:12px}.clear-focus{font:650 10px var(--ui);background:none!important;border:0!important;color:var(--purple-deep);cursor:pointer;text-decoration:underline;text-underline-offset:4px;padding:4px!important}.clear-focus[hidden],.evidence-detail[hidden]{display:none!important}.targets-caption{font:550 9px/1.7 var(--ui);color:var(--muted);margin-top:9px;padding-top:8px;border-top:1px solid var(--line)} +#detail-panel:has(.evidence-detail[hidden]){display:none!important}.evidence-detail{padding:12px 0 3px;border-top:1px solid var(--line);animation:detail-in 360ms var(--ease)}.detail-heading{display:flex;justify-content:space-between;align-items:center;font:650 11px var(--ui);color:var(--purple-deep);margin-bottom:9px}.detail-heading small{font:500 9px var(--ui);color:var(--muted)}.detail-image{height:130px;border-radius:6px;overflow:hidden;background-color:var(--canvas);background-repeat:no-repeat}.detail-coordinates{font:500 9px/1.6 ui-monospace,monospace;color:var(--muted);margin-top:6px;overflow-wrap:anywhere} +#metrics-panel{flex-grow:0!important;min-width:0!important;gap:8px!important;padding-top:15px!important;border-top:1px solid var(--line)}.inspector-subheading{font:700 12px var(--ui)!important;color:#53465f!important;margin:0!important}.metrics-list{margin:0!important;font:500 10px var(--ui)}.metrics-list>div{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:5px 0}.metrics-list dt{color:var(--muted)}.metrics-list dd{margin:0;text-align:right;color:#55485f;font:600 10px ui-monospace,monospace;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.metrics-list>div:nth-child(1) dd{font-family:var(--ui)} +#source-details{border:0!important;border-top:1px solid var(--line)!important;border-radius:0!important;padding:10px 0 0!important;background:transparent!important;overflow:hidden!important}#source-details .label-wrap{width:calc(100% - 4px)!important;min-height:28px!important;font:600 10px var(--ui)!important;color:var(--muted)!important}.source-meta{display:grid;gap:6px;font:500 10px/1.6 var(--ui);color:var(--muted);overflow-wrap:anywhere;padding-top:8px}.source-meta>span{font-size:9px;color:var(--purple-deep);font-weight:700;margin-top:5px}.source-meta small{font-size:10px;line-height:1.7} +#service-panel{flex-grow:0!important;gap:2px!important;padding-top:12px!important;border-top:1px solid var(--line)}.api-status{display:flex;gap:6px;align-items:center;font:600 10px var(--ui);color:#607245;flex-wrap:wrap}.api-status i{margin:0}.api-status span{font:500 9px ui-monospace,monospace;color:var(--muted);margin-left:auto}#health-button{background:none!important;border:0!important;box-shadow:none!important;color:var(--muted)!important;text-align:left;font:500 10px var(--ui)!important;min-height:28px!important;padding:5px 0!important;text-decoration:underline;text-underline-offset:4px;text-decoration-color:#b6a9c3} +.focus-layer{position:absolute;pointer-events:none;z-index:5;overflow:visible}.focus-dimmer{fill:#251437;opacity:.5;animation:focus-dim 320ms var(--ease)}.focus-outline{fill:none;stroke:#d1ef91;stroke-width:2;vector-effect:non-scaling-stroke;filter:drop-shadow(0 1px 2px #2228);stroke-dasharray:1;stroke-dashoffset:0;animation:focus-ink 440ms var(--ease)}.focus-caption{position:absolute;top:10px;left:10px;z-index:6;display:flex;align-items:center;gap:10px;max-width:calc(100% - 20px);padding:6px 7px 6px 12px;border-radius:7px;background:#fff;box-shadow:0 4px 14px #22153720;color:var(--purple-deep);font:650 11px var(--ui)}.focus-caption span{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.focus-caption button{display:grid;place-items:center;border:0;background:var(--lavender);color:var(--purple-deep);border-radius:5px;width:28px;height:28px;cursor:pointer;flex-shrink:0} +#console[aria-busy=true] #canvas-viewport{cursor:progress}#controls[inert]{opacity:.65}#console .wrap.center.full{display:none!important} +#prompt-console,#output-console{border:0!important;border-bottom:1px solid #ded7e8!important;border-radius:0!important;background:transparent!important;padding:4px 2px!important}#prompt-console>.label-wrap,#output-console>.label-wrap{font:600 11px var(--ui)!important;color:#6b5d7b!important;min-height:33px}#prompt-console textarea,#output-console textarea{font:12px/1.7 ui-monospace,monospace!important}.console-note{font:500 11px/1.6 var(--ui);color:var(--muted);margin-top:8px} +.studio-footer{display:flex;justify-content:space-between;align-items:center;gap:12px;font:500 10px var(--ui);color:#736b7d;padding:8px 0 2px}.studio-footer i{font-style:normal;margin-left:12px;color:#807887}.gradio-container>footer{display:none!important} +@keyframes wait-turn{to{transform:rotate(360deg)}}@keyframes focus-dim{from{opacity:0}to{opacity:.5}}@keyframes focus-ink{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}@keyframes detail-in{from{clip-path:inset(0 0 100% 0);opacity:.5}to{clip-path:inset(0);opacity:1}} +@media(min-width:1500px){#sidebar{flex-basis:310px!important;min-width:310px!important;padding:26px!important}.target-chips{max-height:315px}#stage-image{height:clamp(420px,50vh,610px)!important}} +@media(max-width:1100px){.header-note{display:none}#route-select label{padding:10px 13px!important;font-size:11px!important}#sidebar{flex-basis:252px!important;min-width:252px!important;padding:18px!important}#canvas-viewport{padding:18px 18px 46px!important}#query-row{padding:16px!important;gap:12px!important}#sandbox-panel{padding:14px 16px!important}#case-gallery .thumbnail-item{flex-direction:column;gap:1px}#case-gallery .thumbnail-item img{width:100%!important;flex:1 1 0;min-height:0!important}#case-gallery .caption-label{max-width:100%!important;line-height:1.4!important;text-align:center!important}#stage-image{height:390px!important}#run-button{flex-basis:112px!important;min-width:112px!important}} +@media(max-width:760px){.studio-header{padding:8px 0 15px}.studio-identity{gap:11px}.xpeng-logo{width:90px}.brand-divider{height:22px;margin:0 1px}.studio-identity h1{font-size:24px!important}.studio-name{display:none}#controls{margin:0!important}#route-select label{font-size:12px!important;min-height:42px!important;padding:10px 16px!important}#console{flex-direction:column!important;border-radius:12px}#sidebar{flex:auto!important;min-width:0!important;width:100%;padding:20px!important;border-left:0;border-top:1px solid var(--line);gap:14px!important}#visual-stage{min-width:0!important}#stage-toolbar{padding:12px!important;gap:8px!important}#view-toggle label{padding:8px 10px!important;min-height:38px!important;font-size:11px!important}#upload-button{min-width:85px!important;flex-basis:85px!important;font-size:11px!important;min-height:40px!important;padding:8px!important}#canvas-viewport{padding:14px 12px 46px!important}#stage-image{height:330px!important}.canvas-tools{padding:8px 12px}.zoom-tools button{width:32px;height:32px}#query-row{align-items:stretch;gap:10px!important;padding:15px!important}#query-dock textarea{font-size:12px!important}#run-button{min-width:85px!important;flex-basis:85px!important;padding:10px!important;font-size:12px!important}#sandbox-panel{padding:14px 12px!important}#case-gallery{height:120px!important}#case-gallery .grid-container{gap:7px!important}#case-gallery .caption-label{font-size:10px!important}.film-heading small{font-size:9px}.target-chips{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));max-height:250px;gap:4px}.target-chip{min-height:42px}.empty-targets{min-height:150px}.evidence-detail{max-width:360px}.detail-image{height:170px}.metrics-list{display:grid;grid-template-columns:1fr 1fr;gap:5px 20px}.metrics-list>div{align-items:flex-start;flex-direction:column;gap:5px;padding:5px 0}.metrics-list dd{text-align:left}.studio-footer{align-items:flex-start;flex-direction:column;gap:5px;line-height:1.7}.studio-footer i{display:block;margin-left:0}#source-details .label-wrap{min-height:38px!important}#health-button{min-height:38px!important}.focus-help,.targets-caption{font-size:10px}} +@media(max-width:430px){#stage-image{height:282px!important}.studio-identity h1{font-size:22px!important}.xpeng-logo{width:85px}.canvas-tools .image-dimensions{font-size:9px}.film-heading{font-size:10px}.film-heading small{max-width:150px;text-align:right}} +@media(max-width:760px){#case-gallery .thumbnail-item{height:96px!important}#query-row{align-items:center!important}#run-button{min-height:48px!important;height:48px!important}#sidebar:has(.evidence-detail:not([hidden])) .target-chips{max-height:230px}} +@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;scroll-behavior:auto!important;transition-duration:0ms!important}.stage-status.busy i{background:var(--purple);border:0}#run-button:active:not(:disabled){transform:none}} diff --git a/assets/xpeng-logo.png b/assets/xpeng-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a42e962038a3a70febc7513c592ba77d84a769aa Binary files /dev/null and b/assets/xpeng-logo.png differ diff --git a/cases/dense/dense-01-o365_bbox_gt50_00009110.jpg b/cases/dense/dense-01-o365_bbox_gt50_00009110.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8f6b49406d33f921bf9ce4205c6e609e3e453edb --- /dev/null +++ b/cases/dense/dense-01-o365_bbox_gt50_00009110.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:398038106cbac731516dd01de25354fe4d61f3599df64baa611f1d5a99e0e8fb +size 330374 diff --git a/cases/dense/dense-02-o365_bbox_gt50_00004676.jpg b/cases/dense/dense-02-o365_bbox_gt50_00004676.jpg new file mode 100644 index 0000000000000000000000000000000000000000..33ff8aee6aaef4a9077150389d9b808228c11dc6 --- /dev/null +++ b/cases/dense/dense-02-o365_bbox_gt50_00004676.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ee3beb63bdfd50c183538bd56f9d7e079fa41bde78aad9d5fe0d22c041c2673 +size 739087 diff --git a/cases/dense/dense-03-o365_bbox_gt50_00011992.jpg b/cases/dense/dense-03-o365_bbox_gt50_00011992.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1b526a3c40498e720e43e5be381961c8b313a3ac --- /dev/null +++ b/cases/dense/dense-03-o365_bbox_gt50_00011992.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb9331146b66a1af1e8c832a22043c6f1b45d5d3bb7231816f975ced2cd88e39 +size 152034 diff --git a/cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg b/cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg new file mode 100644 index 0000000000000000000000000000000000000000..abbfda9b65e4a0460349a5daaa90cbc652e3b00b --- /dev/null +++ b/cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:917975c9b31791290a2a660c91af8ae0653cfe258fa0c53539bcb868867aece2 +size 525970 diff --git a/cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg b/cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3ce4599293c61e259bb7a485293f16f97566936f --- /dev/null +++ b/cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b9a2281fec580c02b9292d8b3f96b675a8659d721f4dd8a1ae16a1eadbaf4e9 +size 966429 diff --git a/cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg b/cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg new file mode 100644 index 0000000000000000000000000000000000000000..927d5e09a5158b0d72a84e34f6c09f8412f913fd --- /dev/null +++ b/cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2f0e070f49cc001ef6855964175c8c383358fcc2185d62abf29ba0de0d1be22 +size 497412 diff --git a/cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg b/cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1459d6849bd800b0130362a0cbeb2391e09e1c14 Binary files /dev/null and b/cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg differ diff --git a/cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg b/cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7119d7bf4b868c3c998a63258dfb376b0de0cf29 Binary files /dev/null and b/cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg differ diff --git a/cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg b/cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6384a9c24afab42497a5fce4a1a20a4d0bfda1a6 Binary files /dev/null and b/cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg differ diff --git a/cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg b/cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5d6952bde7a3dd20afe5aa22ba1d8c2e0f8d9831 --- /dev/null +++ b/cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9c27a9df49bac1c9664eb74ecf1fe9967e20281add73fff1273437af06b743b +size 455581 diff --git a/cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg b/cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b05aff2817323da3e3979952be4b4772b47fe95d --- /dev/null +++ b/cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ff12fde621319e2959b3112fa6c1fe4e6ef83b8943a6ee169d7fc2140f59e74 +size 148868 diff --git a/cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg b/cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f4673ca873bd0880d1115047bbce07efdfb0c492 --- /dev/null +++ b/cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ba06f95a90cf6954aa7c8f7554b4f28d966afbfc8b8151c96e540e224139cf5 +size 133264 diff --git a/cases/layout/layout-01-layout_doclaynet_train_16966.jpg b/cases/layout/layout-01-layout_doclaynet_train_16966.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f00ea00a07e08850d80525259b3005953153e35a --- /dev/null +++ b/cases/layout/layout-01-layout_doclaynet_train_16966.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ba09e49907c5d7a3a31148a3fceaf2695bd04f35a017a62ef8c455b985f7218 +size 231266 diff --git a/cases/layout/layout-02-layout_doclaynet_train_20356.jpg b/cases/layout/layout-02-layout_doclaynet_train_20356.jpg new file mode 100644 index 0000000000000000000000000000000000000000..18b3ff1f2b57c00b7defa8f062e30c2d19bf6b3b --- /dev/null +++ b/cases/layout/layout-02-layout_doclaynet_train_20356.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fbf03f82cc66566e4630547b53b7f51cd0ebd772a072c1d6f37f8c0bafdb646 +size 241948 diff --git a/cases/layout/layout-03-layout_doclaynet_train_3435.jpg b/cases/layout/layout-03-layout_doclaynet_train_3435.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5304633b05006cc27f2f59f31144f83cad7ba905 --- /dev/null +++ b/cases/layout/layout-03-layout_doclaynet_train_3435.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e035b83d1ca53298816550d4891fd9f2d84f83b59bba178cafdf6bf8623a9fe +size 313091 diff --git a/cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg b/cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b125ee7e0cb1d6a1cc5db3737977404a9c0206f2 Binary files /dev/null and b/cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg differ diff --git a/cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg b/cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fa887e69a59341bab1d25357a3751aa357db996e --- /dev/null +++ b/cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8db936cadff524299c5b61b94992f3b70ec90e1dd3873f072b34d41692393bdd +size 171710 diff --git a/cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg b/cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9ca3beb408eb85a34c7ff659440902e772ba33cf --- /dev/null +++ b/cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d959da84d676117701e6d3920bff692aab94d6075e5714e2a324df3b61f18cf8 +size 132319 diff --git a/cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg b/cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg new file mode 100644 index 0000000000000000000000000000000000000000..960a3a13a13a2976c21e02df3c1eba8ed6d82116 Binary files /dev/null and b/cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg differ diff --git a/cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg b/cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg new file mode 100644 index 0000000000000000000000000000000000000000..792b95b3fb7ee8abc7c2423f1d4f13a79093f15f Binary files /dev/null and b/cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg differ diff --git a/cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg b/cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg new file mode 100644 index 0000000000000000000000000000000000000000..996e083995705b355bc202460b6050801c056a26 Binary files /dev/null and b/cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg differ diff --git a/cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg b/cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg new file mode 100644 index 0000000000000000000000000000000000000000..df78c0c46c85784c8383306e37903e0955ccddc8 --- /dev/null +++ b/cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fac0cc45af121260bc7468aa63fbe7f6dfdcbc5a2f251c04a8a0e06212048df +size 496669 diff --git a/cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg b/cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6398f1e3ad96076481ae732c089ba73acb0cf5bf --- /dev/null +++ b/cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b7ec8dc3ad013a57fab9d1199ee0ce14a3104f8e56f60df908b8769d32e195d +size 312930 diff --git a/cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg b/cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2463a5dc1a627a9ceb72e2aa2b9e72e28963f5a3 --- /dev/null +++ b/cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44978de1893cdcf9c0c3ed7dd40df3d3f38b7c5334ba0929d2604a2a2fb5d561 +size 241923 diff --git a/cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg b/cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg new file mode 100644 index 0000000000000000000000000000000000000000..678907e788bf8d617b560949a52c17b839fff20d --- /dev/null +++ b/cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57104d07c82cfb97a72075ef479f7d8d1c00db82386aa5c38da0ef163a82dc2f +size 858505 diff --git a/cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg b/cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg new file mode 100644 index 0000000000000000000000000000000000000000..05181e5280e872f45f8a0b77f08a7157e86446ea --- /dev/null +++ b/cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba96beb1cc54682f56e34b1381fefc9b7b95905363cff917bbfdac886e265bac +size 546290 diff --git a/cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg b/cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d5010a017bf3040082728b77176793c922f03b9e --- /dev/null +++ b/cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2593b4f81c4fbfd70e73df0710fb143af232126daa0a96bc86c72575713475a5 +size 673625 diff --git a/constraints-app.txt b/constraints-app.txt new file mode 100644 index 0000000000000000000000000000000000000000..d226659a2764fe51f6ddcf69f4834809b966d18a --- /dev/null +++ b/constraints-app.txt @@ -0,0 +1,68 @@ +# App-layer versions observed in the successful 2026-09-15 clean install. +# Accelerator packages are intentionally platform-specific, not pinned here. +aiofiles==24.1.0 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anyio==4.15.1 +brotli==1.2.0 +certifi==2026.7.22 +charset-normalizer==3.5.1 +click==8.5.0 +einops==0.8.1 +fastapi==0.141.1 +ffmpy==1.0.0 +filelock==3.32.6 +fsspec==2026.7.0 +gradio==5.49.1 +gradio_client==1.13.3 +groovy==0.1.2 +h11==0.16.0 +hf-xet==1.6.0 +httpcore==1.0.9 +httpx==0.28.1 +huggingface_hub==1.4.1 +idna==3.19 +Jinja2==3.1.6 +markdown-it-py==4.2.0 +MarkupSafe==3.0.3 +mdurl==0.1.2 +mpmath==1.3.0 +networkx==3.6.1 +numpy==1.26.0 +orjson==3.12.0 +packaging==26.3 +pandas==2.3.3 +pillow==11.3.0 +pydantic==2.11.10 +pydantic_core==2.33.2 +pydub==0.25.1 +Pygments==2.21.0 +python-dateutil==2.9.0.post0 +python-multipart==0.0.32 +pytz==2026.3.post1 +PyYAML==6.0.3 +regex==2026.9.10 +requests==2.34.2 +rich==15.0.0 +ruff==0.16.7 +safehttpx==0.1.7 +safetensors==0.6.2 +semantic-version==2.10.0 +setuptools==84.0.0 +shellingham==1.5.4 +six==1.17.0 +spaces==0.51.3 +starlette==0.52.1 +sympy==1.14.0 +tokenizers==0.22.2 +tomlkit==0.13.3 +tqdm==4.70.1 +transformers==5.3.0 +typer==0.27.2 +typer-slim==0.24.0 +typing-inspection==0.4.4 +typing_extensions==4.16.0 +tzdata==2026.4 +urllib3==2.7.0 +uvicorn==0.53.0 +websockets==15.0.1 diff --git a/data/cases.json b/data/cases.json new file mode 100644 index 0000000000000000000000000000000000000000..48fd30fe158dcea71c3301307b59fa1c9ddf3e84 --- /dev/null +++ b/data/cases.json @@ -0,0 +1,677 @@ +[ + { + "id": "grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924", + "route": "grounding", + "route_title": "Open-vocabulary grounding", + "title": "Open-vocabulary grounding #1", + "prompt": "\nLocate all the instances that match the following categories: BookBottleBowl/BasinCabinet/shelfCannedChairCupDeskExtractorFaucetFlowerGas stoveLampPeachPersonPlatePotted PlantRefrigeratorSinkToasterVase.", + "expected": "<|object_ref_start|>Book<|object_ref_end|><|box_start|><657><613><974><722><|box_end|>, <|object_ref_start|>Bottle<|object_ref_end|><|box_start|><443><371><467><391>,<829><386><913><434>,<874><433><913><446><|box_end|>, <|object_ref_start|>Bowl/Basin<|object_ref_end|><|box_start|><724><377><751><389><|box_end|>, <|object_ref_start|>Cabinet/shelf<|object_ref_end|><|box_start|><630><412><997><602><|box_end|>, <|object_ref_start|>Canned<|object_ref_end|><|box_start|><870><412><894><433>,<894><411><915><433><|box_end|>, <|object_ref_start|>Chair<|object_ref_end|><|box_start|><565><654><851><998>,<874><577><997><603><|box_end|>, <|object_ref_start|>Cup<|object_ref_end|><|box_start|><960><665><997><734><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><661><603><997><998><|box_end|>, <|object_ref_start|>Extractor<|object_ref_end|><|box_start|><498><271><702><312><|box_end|>, <|object_ref_start|>Faucet<|object_ref_end|><|box_start|><262><358><314><421><|box_end|>, <|object_ref_start|>Flower<|object_ref_end|><|box_start|><334><336><410><391><|box_end|>, <|object_ref_start|>Gas stove<|object_ref_end|><|box_start|><500><384><708><412><|box_end|>, <|object_ref_start|>Lamp<|object_ref_end|><|box_start|><679><119><831><306><|box_end|>, <|object_ref_start|>Peach<|object_ref_end|><|box_start|><154><430><193><447><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><882><654><954><682><|box_end|>, <|object_ref_start|>Plate<|object_ref_end|><|box_start|><141><435><275><456><|box_end|>, <|object_ref_start|>Potted Plant<|object_ref_end|><|box_start|><215><350><256><400>,<778><381><829><416><|box_end|>, <|object_ref_start|>Refrigerator<|object_ref_end|><|box_start|><782><265><956><413><|box_end|>, <|object_ref_start|>Sink<|object_ref_end|><|box_start|><279><416><359><424>,<305><412><371><418><|box_end|>, <|object_ref_start|>Toaster<|object_ref_end|><|box_start|><318><372><363><402>,<498><412><630><485><|box_end|>, <|object_ref_start|>Vase<|object_ref_end|><|box_start|><361><374><383><394><|box_end|>", + "image": "cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg", + "source": "la_object365", + "image_sha256": "009d5239ba1519670f9dff2a624d474ab2bd58d28fb913335f4fa52e6c67e41f", + "difficulty": { + "score": 86.07, + "primitive_count": 28, + "label_count": 21, + "smallest_bbox_area_ratio": 0.0003246, + "prompt_chars": 291 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "2e3946eafcbdc2d2ac9e0b62343595e0b51e71b38eb15c3b0669fab46c78e9f6" + }, + { + "id": "grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030", + "route": "grounding", + "route_title": "Open-vocabulary grounding", + "title": "Open-vocabulary grounding #2", + "prompt": "\nLocate all the instances that match the following categories: BaksetBookCabinet/shelfChairCouchCupDeskGlassesHandbag/SatchelHigh HeelsLampLeather ShoesNecklacePersonPillowPotted PlantRingStorage boxWatch.", + "expected": "<|object_ref_start|>Bakset<|object_ref_end|><|box_start|><32><387><90><456><|box_end|>, <|object_ref_start|>Book<|object_ref_end|><|box_start|><0><3><68><93>,<0><133><62><213><|box_end|>, <|object_ref_start|>Cabinet/shelf<|object_ref_end|><|box_start|><0><0><172><692><|box_end|>, <|object_ref_start|>Chair<|object_ref_end|><|box_start|><92><453><420><996><|box_end|>, <|object_ref_start|>Couch<|object_ref_end|><|box_start|><352><459><777><908><|box_end|>, <|object_ref_start|>Cup<|object_ref_end|><|box_start|><869><464><899><493>,<879><493><921><519><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><731><722><997><996>,<735><500><945><778><|box_end|>, <|object_ref_start|>Glasses<|object_ref_end|><|box_start|><515><344><569><363><|box_end|>, <|object_ref_start|>Handbag/Satchel<|object_ref_end|><|box_start|><34><716><146><855><|box_end|>, <|object_ref_start|>High Heels<|object_ref_end|><|box_start|><180><954><238><996>,<314><876><372><991><|box_end|>, <|object_ref_start|>Lamp<|object_ref_end|><|box_start|><813><272><903><514><|box_end|>, <|object_ref_start|>Leather Shoes<|object_ref_end|><|box_start|><591><866><671><954>,<639><895><707><983><|box_end|>, <|object_ref_start|>Necklace<|object_ref_end|><|box_start|><543><419><597><503><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><78><195><432><996>,<404><288><709><983>,<787><395><997><778>,<973><671><997><783><|box_end|>, <|object_ref_start|>Pillow<|object_ref_end|><|box_start|><356><419><501><642><|box_end|>, <|object_ref_start|>Potted Plant<|object_ref_end|><|box_start|><727><368><837><516><|box_end|>, <|object_ref_start|>Ring<|object_ref_end|><|box_start|><320><275><326><288><|box_end|>, <|object_ref_start|>Storage box<|object_ref_end|><|box_start|><18><695><146><852><|box_end|>, <|object_ref_start|>Watch<|object_ref_end|><|box_start|><342><315><352><341>,<639><496><651><532><|box_end|>", + "image": "cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg", + "source": "la_object365", + "image_sha256": "587cde59bf1006e91df2b1d47346ee4546efb1850a15b14b9d5d858b884314a9", + "difficulty": { + "score": 83.92, + "primitive_count": 28, + "label_count": 19, + "smallest_bbox_area_ratio": 7.82e-05, + "prompt_chars": 284 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "c6abef94a28290ca94e8dd043ba58e326cfcb22088b75f32274acc07af15950c" + }, + { + "id": "grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761", + "route": "grounding", + "route_title": "Open-vocabulary grounding", + "title": "Open-vocabulary grounding #3", + "prompt": "\nLocate all the instances that match the following categories: BookBottleChairComputer BoxCupDeskFolderGlassesHandbag/SatchelKeyboardMoniter/TVMousePen/PencilPersonPicture/FramePower outletStaplerTapeTelephoneTissueWatch.", + "expected": "<|object_ref_start|>Book<|object_ref_end|><|box_start|><778><246><872><571><|box_end|>, <|object_ref_start|>Bottle<|object_ref_end|><|box_start|><0><728><48><970><|box_end|>, <|object_ref_start|>Chair<|object_ref_end|><|box_start|><841><583><998><997><|box_end|>, <|object_ref_start|>Computer Box<|object_ref_end|><|box_start|><187><556><436><696><|box_end|>, <|object_ref_start|>Cup<|object_ref_end|><|box_start|><193><669><252><728><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><0><565><894><997><|box_end|>, <|object_ref_start|>Folder<|object_ref_end|><|box_start|><749><385><825><532><|box_end|>, <|object_ref_start|>Glasses<|object_ref_end|><|box_start|><601><359><693><396><|box_end|>, <|object_ref_start|>Handbag/Satchel<|object_ref_end|><|box_start|><100><706><499><911><|box_end|>, <|object_ref_start|>Keyboard<|object_ref_end|><|box_start|><367><610><577><741><|box_end|>, <|object_ref_start|>Moniter/TV<|object_ref_end|><|box_start|><240><264><433><620><|box_end|>, <|object_ref_start|>Mouse<|object_ref_end|><|box_start|><561><608><588><632><|box_end|>, <|object_ref_start|>Pen/Pencil<|object_ref_end|><|box_start|><294><778><322><792><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><332><217><370><266>,<489><273><904><997>,<930><439><943><482>,<930><509><952><563>,<949><520><974><577><|box_end|>, <|object_ref_start|>Picture/Frame<|object_ref_end|><|box_start|><7><398><163><708><|box_end|>, <|object_ref_start|>Power outlet<|object_ref_end|><|box_start|><195><395><237><424><|box_end|>, <|object_ref_start|>Stapler<|object_ref_end|><|box_start|><32><774><104><849><|box_end|>, <|object_ref_start|>Tape<|object_ref_end|><|box_start|><180><647><209><679><|box_end|>, <|object_ref_start|>Telephone<|object_ref_end|><|box_start|><607><385><658><509><|box_end|>, <|object_ref_start|>Tissue<|object_ref_end|><|box_start|><165><638><264><720><|box_end|>, <|object_ref_start|>Watch<|object_ref_end|><|box_start|><558><731><583><776><|box_end|>", + "image": "cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg", + "source": "la_object365", + "image_sha256": "c60cb8043d08a5311d87cc896ee777da450d7561a1cd8126d1e31f1a91ebccfd", + "difficulty": { + "score": 82.22, + "primitive_count": 25, + "label_count": 21, + "smallest_bbox_area_ratio": 0.0003928, + "prompt_chars": 308 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "ff9581327870a05ad8679c3e5891f27dfe55acc98ed713a8abf8d02e7604774b" + }, + { + "id": "dense-01-o365_bbox_gt50_00009110", + "route": "dense", + "route_title": "Dense scene grounding", + "title": "Dense scene grounding #1", + "prompt": "\nLocate all the instances that match the following categories: BananaGrapefruitAppleOrange/TangerineRed CabbageGreen VegetablesLemonPepperKiwi fruitCabbagePineapplePearCucumberPumpkinTelephoneMoniter/TVHatBootsLeather ShoesOther ShoesGlassesHandbag/SatchelBaksetSneakersGlovesBriefcaseBottleCupCabinet/shelfStorage boxPotted PlantDeskFlowerVasePerson.", + "expected": "<|object_ref_start|>Banana<|object_ref_end|><|box_start|><584><264><643><379><|box_end|>, <|object_ref_start|>Grapefruit<|object_ref_end|><|box_start|><675><255><698><299><|box_end|>, <|object_ref_start|>Apple<|object_ref_end|><|box_start|><485><103><629><132>,<571><226><661><251>,<648><254><672><298>,<658><106><726><133>,<698><248><740><365><|box_end|>, <|object_ref_start|>Orange/Tangerine<|object_ref_end|><|box_start|><665><223><701><247>,<922><216><941><231><|box_end|>, <|object_ref_start|>Red Cabbage<|object_ref_end|><|box_start|><601><144><649><191><|box_end|>, <|object_ref_start|>Green Vegetables<|object_ref_end|><|box_start|><547><147><588><190>,<635><137><769><191>,<791><108><809><135>,<806><165><847><207><|box_end|>, <|object_ref_start|>Lemon<|object_ref_end|><|box_start|><722><109><743><133><|box_end|>, <|object_ref_start|>Pepper<|object_ref_end|><|box_start|><636><64><714><99><|box_end|>, <|object_ref_start|>Kiwi fruit<|object_ref_end|><|box_start|><738><109><767><132><|box_end|>, <|object_ref_start|>Cabbage<|object_ref_end|><|box_start|><579><144><619><190><|box_end|>, <|object_ref_start|>Pineapple<|object_ref_end|><|box_start|><734><31><780><59><|box_end|>, <|object_ref_start|>Pear<|object_ref_end|><|box_start|><627><105><658><134><|box_end|>, <|object_ref_start|>Cucumber<|object_ref_end|><|box_start|><459><103><484><132>,<679><26><708><58><|box_end|>, <|object_ref_start|>Pumpkin<|object_ref_end|><|box_start|><628><275><649><372>,<733><305><764><339><|box_end|>, <|object_ref_start|>Telephone<|object_ref_end|><|box_start|><906><579><942><618><|box_end|>, <|object_ref_start|>Moniter/TV<|object_ref_end|><|box_start|><862><457><930><510>,<884><388><914><456><|box_end|>, <|object_ref_start|>Hat<|object_ref_end|><|box_start|><605><411><644><459>,<659><275><685><313>,<789><346><828><388>,<926><383><967><412><|box_end|>, <|object_ref_start|>Boots<|object_ref_end|><|box_start|><672><471><689><511>,<697><717><718><749>,<737><724><764><760><|box_end|>, <|object_ref_start|>Leather Shoes<|object_ref_end|><|box_start|><460><496><489><509><|box_end|>, <|object_ref_start|>Other Shoes<|object_ref_end|><|box_start|><397><465><420><479><|box_end|>, <|object_ref_start|>Glasses<|object_ref_end|><|box_start|><286><468><315><486>,<484><297><504><305>,<932><406><940><413><|box_end|>, <|object_ref_start|>Handbag/Satchel<|object_ref_end|><|box_start|><149><659><188><742>,<255><612><294><673><|box_end|>, <|object_ref_start|>Bakset<|object_ref_end|><|box_start|><8><426><66><492>,<48><395><101><450>,<513><408><586><497><|box_end|>, <|object_ref_start|>Sneakers<|object_ref_end|><|box_start|><638><392><656><415>,<661><399><678><423><|box_end|>, <|object_ref_start|>Gloves<|object_ref_end|><|box_start|><590><466><615><496>,<676><367><682><382><|box_end|>, <|object_ref_start|>Briefcase<|object_ref_end|><|box_start|><774><830><927><999><|box_end|>, <|object_ref_start|>Bottle<|object_ref_end|><|box_start|><0><149><214><208>,<69><0><343><16>,<75><26><127><59>,<100><68><171><101>,<127><29><164><59>,<164><23><205><59>,<171><67><202><99>,<204><23><267><58>,<211><146><344><199>,<212><105><343><138>,<214><66><301><99>,<267><23><308><54>,<302><65><344><98>,<309><22><344><54>,<371><65><446><95>,<372><0><413><16>,<372><22><451><55>,<373><105><432><137>,<373><144><434><193>,<766><937><848><999><|box_end|>, <|object_ref_start|>Cup<|object_ref_end|><|box_start|><0><70><67><105>,<65><73><78><86><|box_end|>, <|object_ref_start|>Cabinet/shelf<|object_ref_end|><|box_start|><0><18><810><271>,<129><346><258><664>,<145><734><340><998>,<258><394><376><607>,<275><280><400><602>,<338><800><520><999>,<500><666><659><999>,<502><494><688><881>,<815><112><911><202>,<865><210><964><364><|box_end|>, <|object_ref_start|>Storage box<|object_ref_end|><|box_start|><133><202><663><961>,<769><732><999><998>,<949><562><985><618><|box_end|>, <|object_ref_start|>Potted Plant<|object_ref_end|><|box_start|><726><360><781><469><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><848><327><932><442><|box_end|>, <|object_ref_start|>Flower<|object_ref_end|><|box_start|><805><164><849><209><|box_end|>, <|object_ref_start|>Vase<|object_ref_end|><|box_start|><817><204><836><220><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><169><478><245><712>,<262><463><343><667>,<381><237><436><480>,<460><274><528><515>,<526><293><596><539>,<563><411><663><585>,<601><926><682><999>,<637><279><726><512>,<686><420><783><760>,<760><347><853><551>,<907><383><976><571><|box_end|>", + "image": "cases/dense/dense-01-o365_bbox_gt50_00009110.jpg", + "source": "b_o365_bbox_gt50", + "image_sha256": "939ecbfc3eea0d7145fe86ad95838691824f5588fc1187d277968f9c73696f77", + "difficulty": { + "score": 201.55, + "primitive_count": 99, + "label_count": 35, + "smallest_bbox_area_ratio": 5.61e-05, + "prompt_chars": 494 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "398038106cbac731516dd01de25354fe4d61f3599df64baa611f1d5a99e0e8fb" + }, + { + "id": "dense-02-o365_bbox_gt50_00004676", + "route": "dense", + "route_title": "Dense scene grounding", + "title": "Dense scene grounding #2", + "prompt": "\nLocate all the instances that match the following categories: CarBusTraffic SignBicyclePickup TruckStreet LightsBeltGlassesSneakersOther ShoesHatHandbag/SatchelPersonBraceletTentBottleCupBarrel/bucketBowl/BasinPlateStorage boxChairDeskPotted PlantScaleBlackboard/WhiteboardKiwi fruitCannedCarrotTomatoGreen Vegetables.", + "expected": "<|object_ref_start|>Car<|object_ref_end|><|box_start|><89><514><117><529>,<119><527><169><554>,<143><530><215><559>,<198><528><216><539>,<216><529><238><546>,<371><546><458><591>,<703><544><721><556>,<720><545><741><555><|box_end|>, <|object_ref_start|>Bus<|object_ref_end|><|box_start|><531><512><669><589><|box_end|>, <|object_ref_start|>Traffic Sign<|object_ref_end|><|box_start|><507><489><524><501><|box_end|>, <|object_ref_start|>Bicycle<|object_ref_end|><|box_start|><229><551><281><621><|box_end|>, <|object_ref_start|>Pickup Truck<|object_ref_end|><|box_start|><11><515><120><556><|box_end|>, <|object_ref_start|>Street Lights<|object_ref_end|><|box_start|><0><425><4><515>,<174><351><182><392>,<356><379><367><413>,<730><475><740><601><|box_end|>, <|object_ref_start|>Belt<|object_ref_end|><|box_start|><139><609><158><618><|box_end|>, <|object_ref_start|>Glasses<|object_ref_end|><|box_start|><178><544><187><558>,<814><535><830><543><|box_end|>, <|object_ref_start|>Sneakers<|object_ref_end|><|box_start|><140><721><153><726>,<153><721><176><731>,<959><732><975><748><|box_end|>, <|object_ref_start|>Other Shoes<|object_ref_end|><|box_start|><330><717><341><725>,<787><707><797><717><|box_end|>, <|object_ref_start|>Hat<|object_ref_end|><|box_start|><415><543><422><551><|box_end|>, <|object_ref_start|>Handbag/Satchel<|object_ref_end|><|box_start|><959><736><998><786><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><132><533><192><731>,<222><529><268><590>,<324><520><377><728>,<387><537><425><610>,<459><544><474><607>,<534><532><554><601>,<593><536><609><598>,<773><508><826><725>,<812><520><837><607>,<846><541><867><583>,<872><549><881><608>,<896><495><940><704>,<936><558><958><623>,<944><506><999><746><|box_end|>, <|object_ref_start|>Bracelet<|object_ref_end|><|box_start|><948><593><952><601><|box_end|>, <|object_ref_start|>Tent<|object_ref_end|><|box_start|><5><377><246><629>,<60><364><463><753>,<319><505><451><603>,<442><472><530><609>,<479><476><593><603>,<635><273><998><837>,<733><482><804><604>,<784><486><906><544>,<785><513><901><581>,<879><487><999><583><|box_end|>, <|object_ref_start|>Bottle<|object_ref_end|><|box_start|><28><693><45><724>,<486><597><499><633>,<811><608><820><634>,<820><608><829><634>,<848><603><878><614>,<944><767><957><781><|box_end|>, <|object_ref_start|>Cup<|object_ref_end|><|box_start|><200><638><205><649>,<250><534><253><542>,<271><549><275><557>,<895><616><902><631><|box_end|>, <|object_ref_start|>Barrel/bucket<|object_ref_end|><|box_start|><207><638><219><656>,<218><639><234><661>,<283><538><298><556><|box_end|>, <|object_ref_start|>Bowl/Basin<|object_ref_end|><|box_start|><245><550><252><560>,<376><570><382><578>,<839><606><877><629><|box_end|>, <|object_ref_start|>Plate<|object_ref_end|><|box_start|><252><556><260><559>,<566><583><583><602><|box_end|>, <|object_ref_start|>Storage box<|object_ref_end|><|box_start|><0><646><60><723>,<103><718><288><882>,<234><630><313><679>,<350><722><407><780>,<437><572><500><578>,<503><591><518><605>,<545><641><574><666>,<796><642><864><779>,<840><583><872><593><|box_end|>, <|object_ref_start|>Chair<|object_ref_end|><|box_start|><23><613><140><763>,<847><621><879><731><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><125><623><430><804>,<227><555><305><597>,<375><578><500><606>,<511><576><591><599>,<541><597><632><657>,<691><626><930><746>,<840><592><875><605><|box_end|>, <|object_ref_start|>Potted Plant<|object_ref_end|><|box_start|><191><566><207><589>,<425><563><442><578>,<433><530><454><560>,<439><602><447><611>,<472><544><482><554><|box_end|>, <|object_ref_start|>Scale<|object_ref_end|><|box_start|><183><586><211><605><|box_end|>, <|object_ref_start|>Blackboard/Whiteboard<|object_ref_end|><|box_start|><638><585><666><649><|box_end|>, <|object_ref_start|>Kiwi fruit<|object_ref_end|><|box_start|><125><828><210><867><|box_end|>, <|object_ref_start|>Canned<|object_ref_end|><|box_start|><310><637><418><671><|box_end|>, <|object_ref_start|>Carrot<|object_ref_end|><|box_start|><207><769><245><792>,<210><624><220><637><|box_end|>, <|object_ref_start|>Tomato<|object_ref_end|><|box_start|><201><628><236><651>,<223><733><274><751><|box_end|>, <|object_ref_start|>Green Vegetables<|object_ref_end|><|box_start|><160><613><180><643><|box_end|>", + "image": "cases/dense/dense-02-o365_bbox_gt50_00004676.jpg", + "source": "b_o365_bbox_gt50", + "image_sha256": "465877ee9ef2698f5fa564d96ee0aeab6f72bf99c41a499087d09a0271d8aa51", + "difficulty": { + "score": 197.06, + "primitive_count": 101, + "label_count": 31, + "smallest_bbox_area_ratio": 2.4e-05, + "prompt_chars": 446 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "7ee3beb63bdfd50c183538bd56f9d7e079fa41bde78aad9d5fe0d22c041c2673" + }, + { + "id": "dense-03-o365_bbox_gt50_00011992", + "route": "dense", + "route_title": "Dense scene grounding", + "title": "Dense scene grounding #3", + "prompt": "\nLocate all the instances that match the following categories: ChairStoolCabinet/shelfStorage boxDeskCouchCarpetPillowPersonGlassesSneakersBlackboard/WhiteboardPlateComputer BoxMoniter/TVKeyboardBreadStuffed ToyBaksetBookGrapeStrawberryCookies.", + "expected": "<|object_ref_start|>Chair<|object_ref_end|><|box_start|><0><612><65><858>,<6><358><77><410>,<13><905><103><999>,<96><519><230><853>,<431><220><522><368>,<574><287><680><488>,<824><271><949><480><|box_end|>, <|object_ref_start|>Stool<|object_ref_end|><|box_start|><334><153><376><251>,<377><152><398><233><|box_end|>, <|object_ref_start|>Cabinet/shelf<|object_ref_end|><|box_start|><309><125><412><241>,<550><111><632><212>,<635><100><698><171>,<697><12><839><200>,<818><84><957><203><|box_end|>, <|object_ref_start|>Storage box<|object_ref_end|><|box_start|><419><341><501><381>,<421><355><518><405>,<421><355><533><425>,<424><328><500><381>,<432><378><542><473>,<526><100><540><112>,<541><97><561><114>,<562><95><585><112>,<584><93><607><111>,<607><90><630><108>,<630><88><651><107>,<651><85><677><103>,<675><82><699><101>,<708><90><725><115>,<724><94><750><119>,<750><95><775><121>,<783><99><809><123>,<826><124><862><153>,<837><57><860><82>,<858><60><892><86>,<889><65><937><88><|box_end|>, <|object_ref_start|>Desk<|object_ref_end|><|box_start|><42><168><105><263>,<307><365><454><682>,<426><137><551><209><|box_end|>, <|object_ref_start|>Couch<|object_ref_end|><|box_start|><76><123><316><269><|box_end|>, <|object_ref_start|>Carpet<|object_ref_end|><|box_start|><798><544><999><818><|box_end|>, <|object_ref_start|>Pillow<|object_ref_end|><|box_start|><149><201><226><238>,<222><203><240><231><|box_end|>, <|object_ref_start|>Person<|object_ref_end|><|box_start|><0><275><47><317>,<0><514><101><773>,<67><238><197><562>,<77><193><170><355>,<167><150><433><820>,<378><140><478><349>,<446><130><518><353>,<580><129><827><996>,<582><107><675><363>,<754><102><860><366>,<825><86><978><213>,<835><127><964><447><|box_end|>, <|object_ref_start|>Glasses<|object_ref_end|><|box_start|><660><287><732><329><|box_end|>, <|object_ref_start|>Sneakers<|object_ref_end|><|box_start|><32><711><100><769>,<819><346><835><364>,<843><377><879><433>,<908><391><951><445><|box_end|>, <|object_ref_start|>Blackboard/Whiteboard<|object_ref_end|><|box_start|><960><3><999><155><|box_end|>, <|object_ref_start|>Plate<|object_ref_end|><|box_start|><14><290><71><310>,<151><384><195><416>,<175><421><192><446>,<222><275><240><290>,<256><940><465><997>,<294><653><538><851>,<333><451><472><521>,<417><811><622><989>,<447><253><497><269>,<477><226><518><240>,<545><517><688><617>,<549><639><672><729>,<587><698><749><829>,<592><218><636><233>,<817><220><856><236>,<936><242><975><258>,<980><215><999><229><|box_end|>, <|object_ref_start|>Computer Box<|object_ref_end|><|box_start|><305><64><333><135>,<396><56><433><127><|box_end|>, <|object_ref_start|>Moniter/TV<|object_ref_end|><|box_start|><225><71><284><126>,<339><64><395><120><|box_end|>, <|object_ref_start|>Keyboard<|object_ref_end|><|box_start|><341><120><393><131><|box_end|>, <|object_ref_start|>Bread<|object_ref_end|><|box_start|><367><472><428><508>,<572><566><636><603><|box_end|>, <|object_ref_start|>Stuffed Toy<|object_ref_end|><|box_start|><361><271><429><358>,<510><156><554><233><|box_end|>, <|object_ref_start|>Bakset<|object_ref_end|><|box_start|><317><353><421><419>,<540><223><592><253>,<710><41><728><65>,<726><43><736><67>,<735><43><745><67>,<744><43><758><68>,<759><44><771><69>,<770><43><784><69>,<784><43><800><69>,<800><43><816><70>,<920><206><955><233><|box_end|>, <|object_ref_start|>Book<|object_ref_end|><|box_start|><443><102><545><148>,<713><6><832><43>,<713><76><759><118>,<764><79><814><126>,<850><21><942><86><|box_end|>, <|object_ref_start|>Grape<|object_ref_end|><|box_start|><150><810><308><910>,<438><667><530><755>,<599><711><665><803>,<674><718><719><740><|box_end|>, <|object_ref_start|>Strawberry<|object_ref_end|><|box_start|><427><746><497><806>,<626><768><681><811>,<689><749><733><804><|box_end|>, <|object_ref_start|>Cookies<|object_ref_end|><|box_start|><458><833><603><967><|box_end|>", + "image": "cases/dense/dense-03-o365_bbox_gt50_00011992.jpg", + "source": "b_o365_bbox_gt50", + "image_sha256": "40e1d0361270be26535b4762d756b99bbc3e2cca03c34d5a6dee5f8bc5bd100a", + "difficulty": { + "score": 189.32, + "primitive_count": 110, + "label_count": 23, + "smallest_bbox_area_ratio": 0.0001683, + "prompt_chars": 339 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "eb9331146b66a1af1e8c832a22043c6f1b45d5d3bb7231816f975ced2cd88e39" + }, + { + "id": "referring-01-humanref_nocot_lf2_00007963", + "route": "referring", + "route_title": "Compositional referring", + "title": "Compositional referring #1", + "prompt": "\nLocate the target referred to by the following description: All the people to the left of the person wearing a blue coat and holding a long white staff in the right hand.", + "expected": "<|object_ref_start|>All the people to the left of the person wearing a blue coat and holding a long white staff in the right hand<|object_ref_end|><|box_start|><0><546><100><912>,<0><558><29><706>,<12><542><45><627>,<24><500><199><999>,<265><411><439><916><|box_end|>", + "image": "cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg", + "source": "b_humanref_nocot", + "image_sha256": "cd5ee8e113374d10dfe7f4f33e978798c04198ad1d4e83d6e80c4bf3c5abfa74", + "difficulty": { + "score": 29.99, + "primitive_count": 5, + "label_count": 1, + "smallest_bbox_area_ratio": 0.0028106, + "prompt_chars": 178 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "4fac0cc45af121260bc7468aa63fbe7f6dfdcbc5a2f251c04a8a0e06212048df" + }, + { + "id": "referring-02-humanref_nocot_lf2_00004121", + "route": "referring", + "route_title": "Compositional referring", + "title": "Compositional referring #2", + "prompt": "\nLocate the target referred to by the following description: all the people with backpacks behind the person closest to the white pagoda in the distance.", + "expected": "<|object_ref_start|>all the people with backpacks behind the person closest to the white pagoda in the distance<|object_ref_end|><|box_start|><399><378><455><530>,<400><401><449><778>,<403><409><502><872>,<544><406><638><846>,<585><400><635><428><|box_end|>", + "image": "cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg", + "source": "b_humanref_nocot", + "image_sha256": "0234ff632745708fb4cb5e6907ac19a78c3d8973742fe6443e96e60711276646", + "difficulty": { + "score": 29.39, + "primitive_count": 5, + "label_count": 1, + "smallest_bbox_area_ratio": 0.0014028, + "prompt_chars": 160 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "9b7ec8dc3ad013a57fab9d1199ee0ce14a3104f8e56f60df908b8769d32e195d" + }, + { + "id": "referring-03-humanref_nocot_lf2_00011458", + "route": "referring", + "route_title": "Compositional referring", + "title": "Compositional referring #3", + "prompt": "\nLocate the target referred to by the following description: the people in all the photos behind the person to the left of the printer.", + "expected": "<|object_ref_start|>the people in all the photos behind the person to the left of the printer<|object_ref_end|><|box_start|><39><274><66><372>,<55><446><80><504>,<62><272><84><366>,<81><266><107><366>,<82><399><105><500><|box_end|>", + "image": "cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg", + "source": "b_humanref_nocot", + "image_sha256": "567007c126ab83173f112bc945b252d11e5097985b5ba8ef95de69eefbe1104a", + "difficulty": { + "score": 27.85, + "primitive_count": 5, + "label_count": 1, + "smallest_bbox_area_ratio": 0.0014529, + "prompt_chars": 142 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "44978de1893cdcf9c0c3ed7dd40df3d3f38b7c5334ba0929d2604a2a2fb5d561" + }, + { + "id": "dense_point-01-sensenova_sa1b_point_1067906__phrase_000", + "route": "dense_point", + "route_title": "Dense point localization", + "title": "Dense point localization #1", + "prompt": "\nPoint to: balloons.", + "expected": "<|object_ref_start|>balloons<|object_ref_end|><|box_start|><9><291>,<13><447>,<20><363>,<24><239>,<25><165>,<27><598>,<31><715>,<44><308>,<66><749>,<78><399>,<91><638>,<92><251>,<108><734>,<128><29>,<154><456>,<155><335>,<160><31>,<170><97>,<178><160>,<198><41>,<209><471>,<209><389>,<218><312>,<218><106>,<237><225>,<243><40>,<249><365>,<256><429>,<269><299>,<279><125>,<292><371>,<309><432>,<332><291>,<346><33>,<370><81>,<372><153>,<404><29>,<405><143>,<413><87>,<443><475>,<450><43>,<452><123>,<459><214>,<508><79>,<582><47>,<596><162>,<616><97>,<642><34>,<656><147>,<664><85>,<695><35>,<696><182>,<705><102>,<717><640>,<748><52>,<785><515>,<792><605>,<827><353>,<836><483>,<839><593>,<840><663>,<841><233>,<848><730>,<870><657>,<876><257>,<881><730>,<882><573>,<900><309>,<912><209>,<915><417>,<928><243>,<951><310>,<954><636>,<956><209>,<963><49>,<964><252>,<972><361>,<975><170>,<991><764>,<996><535><|box_end|>", + "image": "cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg", + "source": "a_sa1b_point_gt20", + "image_sha256": "6ec7346147b62fded0f584cfb4ba051fba7fbbe7b98f1c64a1d1cef2fbd1d30c", + "difficulty": { + "score": 98.0, + "primitive_count": 80, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 27 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "917975c9b31791290a2a660c91af8ae0653cfe258fa0c53539bcb868867aece2" + }, + { + "id": "dense_point-02-sensenova_sa1b_point_1445784__phrase_002", + "route": "dense_point", + "route_title": "Dense point localization", + "title": "Dense point localization #2", + "prompt": "\nPoint to: tree.", + "expected": "<|object_ref_start|>tree<|object_ref_end|><|box_start|><14><395>,<20><436>,<62><357>,<148><348>,<149><475>,<158><278>,<188><915>,<208><417>,<226><300>,<243><866>,<247><393>,<274><621>,<288><774>,<298><529>,<331><453>,<335><580>,<337><649>,<346><734>,<354><341>,<393><570>,<406><467>,<408><349>,<409><653>,<441><835>,<468><503>,<469><392>,<476><931>,<476><588>,<505><416>,<506><782>,<528><717>,<564><768>,<570><859>,<573><440>,<578><964>,<581><567>,<586><563>,<589><661>,<595><955>,<609><572>,<609><565>,<636><799>,<640><627>,<641><617>,<648><561>,<648><667>,<652><983>,<652><561>,<674><435>,<679><433>,<688><661>,<689><925>,<710><855>,<738><849>,<742><555>,<751><427>,<756><414>,<760><643>,<764><941>,<764><319>,<765><804>,<770><804>,<775><624>,<784><277>,<790><593>,<790><279>,<794><220>,<815><343>,<840><192>,<847><673>,<879><810>,<885><385>,<893><593>,<905><756>,<928><529>,<939><367>,<957><433>,<970><872>,<980><547>,<993><481><|box_end|>", + "image": "cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg", + "source": "a_sa1b_point_gt20", + "image_sha256": "c4ca87875ab1cf121936599074c42e0fc6bc7fcc6cd602eaf7d2eb308a36b153", + "difficulty": { + "score": 98.0, + "primitive_count": 80, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 23 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "0b9a2281fec580c02b9292d8b3f96b675a8659d721f4dd8a1ae16a1eadbaf4e9" + }, + { + "id": "dense_point-03-sensenova_sa1b_point_1451598__phrase_001", + "route": "dense_point", + "route_title": "Dense point localization", + "title": "Dense point localization #3", + "prompt": "\nPoint to: clothing.", + "expected": "<|object_ref_start|>clothing<|object_ref_end|><|box_start|><11><474>,<15><534>,<38><537>,<57><535>,<58><483>,<74><483>,<101><483>,<158><473>,<214><487>,<223><543>,<235><485>,<257><486>,<258><549>,<280><577>,<283><484>,<288><551>,<305><582>,<314><489>,<326><581>,<347><553>,<380><449>,<393><549>,<400><446>,<403><485>,<427><482>,<429><448>,<451><446>,<452><483>,<496><485>,<538><449>,<540><483>,<566><453>,<569><490>,<587><452>,<610><452>,<614><454>,<625><486>,<634><453>,<637><451>,<660><456>,<660><491>,<665><455>,<680><455>,<680><454>,<681><494>,<699><454>,<702><455>,<708><528>,<713><521>,<722><454>,<728><454>,<735><540>,<758><547>,<763><547>,<786><459>,<802><471>,<813><437>,<822><541>,<834><443>,<837><491>,<839><443>,<847><440>,<851><441>,<853><565>,<866><439>,<869><563>,<881><435>,<898><545>,<900><431>,<902><489>,<918><431>,<921><482>,<946><425>,<952><785>,<966><489>,<968><423>,<974><563>,<992><417>,<994><487>,<994><563><|box_end|>", + "image": "cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg", + "source": "a_sa1b_point_gt20", + "image_sha256": "367927c02501f4cc0cc52e0c548108d1d59002b7f26485aefe66103ebd456c9b", + "difficulty": { + "score": 98.0, + "primitive_count": 80, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 27 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "d2f0e070f49cc001ef6855964175c8c383358fcc2185d62abf29ba0de0d1be22" + }, + { + "id": "refer_point-01-roboafford_affordance_point_paco_491580_000", + "route": "refer_point", + "route_title": "Affordance referring point", + "title": "Affordance referring point #1", + "prompt": "\nPoint to the target referred to by the following description: What item can be worn to protect and provide comfort to your feet while walking?.", + "expected": "<|object_ref_start|>What item can be worn to protect and provide comfort to your feet while walking?<|object_ref_end|><|box_start|><27><261>,<103><259>,<225><90>,<506><740>,<512><301>,<528><727>,<579><301>,<620><266>,<636><269>,<686><25>,<802><252>,<830><253><|box_end|>", + "image": "cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg", + "source": "d_roboafford_affordance_point", + "image_sha256": "e6800f54649159f1ab50cef3a518d7f3c98f7191c9677eb9b3bd3eff41812d4d", + "difficulty": { + "score": 31.04, + "primitive_count": 12, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 151 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "e5233bcfadb4d6cb3be1a0ac75573183084494661dd31cc42e7282d21b6c3e13" + }, + { + "id": "refer_point-02-roboafford_affordance_point_paco_558444_002", + "route": "refer_point", + "route_title": "Affordance referring point", + "title": "Affordance referring point #2", + "prompt": "\nPoint to the target referred to by the following description: Which part of a cellular telephone protects the internal components and can often be removed or customized?.", + "expected": "<|object_ref_start|>Which part of a cellular telephone protects the internal components and can often be removed or customized?<|object_ref_end|><|box_start|><123><612>,<204><535>,<274><761>,<285><930>,<312><320>,<329><807>,<575><515>,<600><538>,<649><598>,<730><483>,<930><354><|box_end|>", + "image": "cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg", + "source": "d_roboafford_affordance_point", + "image_sha256": "6379ecd84f20a2e73ae93128e2710d567670330a52207a0cf7ddc6952fb0ed3e", + "difficulty": { + "score": 30.93, + "primitive_count": 11, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 178 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "df60dcc4812e93720202874e7b88cca122b25ff2615dd31e2bd697a552bce322" + }, + { + "id": "refer_point-03-roboafford_affordance_point_paco_311488_000", + "route": "refer_point", + "route_title": "Affordance referring point", + "title": "Affordance referring point #3", + "prompt": "\nPoint to the target referred to by the following description: What item can be opened and read to gain information or entertainment?.", + "expected": "<|object_ref_start|>What item can be opened and read to gain information or entertainment?<|object_ref_end|><|box_start|><79><227>,<100><241>,<182><225>,<345><186>,<505><111>,<873><75>,<909><249>,<918><249>,<950><110>,<972><112>,<994><0>,<998><251><|box_end|>", + "image": "cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg", + "source": "d_roboafford_affordance_point", + "image_sha256": "4144ca5d2d299034042d0ebcdceb0f19f55f48436bb648bcbeab6f9955ab0af4", + "difficulty": { + "score": 30.41, + "primitive_count": 12, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 141 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "e4fc006bbcb49c5e57c3b002a35e5866c15c898d6930117e0f89617121cd3928" + }, + { + "id": "visual_prompt-01-sensenova_sa1b_visual_1718306", + "route": "visual_prompt", + "route_title": "Visual-prompt retrieval", + "title": "Visual-prompt retrieval #1", + "prompt": "\nGiven reference boxes <|box_start|><154><663><168><694><|box_end|> indicating one or more objects, find all similar objects in the image and output their bounding boxes.", + "expected": "<|object_ref_start|>object<|object_ref_end|><|box_start|><0><772><1><794>,<17><727><37><769>,<48><714><66><753>,<69><700><89><739>,<101><690><117><724>,<116><679><132><715>,<138><670><153><701>,<154><663><168><694>,<173><656><187><684>,<183><650><196><676>,<188><577><206><638>,<190><649><204><674>,<199><595><218><666>,<203><587><222><662>,<213><593><228><659>,<220><592><235><651>,<226><591><241><648>,<238><594><257><646>,<248><589><264><642>,<259><582><277><636>,<269><584><282><634>,<279><590><298><635>,<290><583><308><630>,<307><581><325><628>,<323><889><354><967>,<328><580><344><627>,<335><827><361><890>,<343><585><360><626>,<347><792><370><846>,<349><758><369><818>,<351><710><368><817>,<352><704><370><798>,<357><681><371><770>,<363><585><380><625>,<365><661><377><702>,<379><588><396><627>,<412><586><427><624>,<444><611><453><629>,<455><585><469><623>,<560><669><575><698>,<574><678><589><711>,<586><604><605><649>,<596><585><609><644>,<596><693><612><731>,<597><583><613><647>,<598><583><615><643>,<600><585><617><649>,<614><706><632><749>,<633><726><653><766>,<664><601><695><680>,<665><740><686><783>,<687><760><709><808>,<720><781><742><828>,<759><809><784><861><|box_end|>", + "image": "cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg", + "source": "a_sa1b_visual_gt20", + "image_sha256": "3eb1d57b0e243792ce740d7933b1a1ad77efbdd5869e08e1f0ad98189cc5230e", + "difficulty": { + "score": 80.77, + "primitive_count": 54, + "label_count": 1, + "smallest_bbox_area_ratio": 2.2e-05, + "prompt_chars": 177 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "57104d07c82cfb97a72075ef479f7d8d1c00db82386aa5c38da0ef163a82dc2f" + }, + { + "id": "visual_prompt-02-sensenova_sa1b_visual_2475968", + "route": "visual_prompt", + "route_title": "Visual-prompt retrieval", + "title": "Visual-prompt retrieval #2", + "prompt": "\nGiven reference boxes <|box_start|><748><85><758><97><|box_end|> indicating one or more objects, find all similar objects in the image and output their bounding boxes.", + "expected": "<|object_ref_start|>object<|object_ref_end|><|box_start|><43><434><55><455>,<63><356><71><374>,<75><409><89><430>,<76><453><92><482>,<87><325><107><358>,<106><459><120><506>,<113><391><144><463>,<122><86><131><95>,<132><101><141><111>,<151><127><159><139>,<161><507><175><541>,<166><193><177><218>,<180><4><189><15>,<187><445><203><469>,<190><25><199><38>,<198><456><206><471>,<200><50><210><60>,<209><392><224><419>,<213><83><222><95>,<225><261><241><279>,<230><317><242><331>,<234><299><248><319>,<243><322><260><340>,<263><342><273><360>,<272><380><281><398>,<278><388><288><410>,<280><357><291><375>,<282><359><292><376>,<289><395><300><422>,<290><437><301><465>,<293><327><305><350>,<294><3><302><15>,<298><245><313><271>,<301><41><309><57>,<304><84><314><99>,<348><326><358><349>,<659><333><684><377>,<661><88><668><98>,<674><73><683><82>,<706><283><730><318>,<716><117><726><126>,<731><464><750><480>,<733><103><742><112>,<748><85><758><97>,<764><462><787><483>,<769><523><793><552>,<772><70><778><81>,<777><488><792><505>,<779><128><788><138>,<797><486><817><509>,<813><102><824><113>,<837><86><846><99>,<857><71><866><83>,<864><475><883><498>,<896><104><904><115><|box_end|>", + "image": "cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg", + "source": "a_sa1b_visual_gt20", + "image_sha256": "205a9ef80233924604d629da5e104ca29104ab998a7a824b51b377d932b46b82", + "difficulty": { + "score": 80.54, + "primitive_count": 55, + "label_count": 1, + "smallest_bbox_area_ratio": 6.61e-05, + "prompt_chars": 175 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "ba96beb1cc54682f56e34b1381fefc9b7b95905363cff917bbfdac886e265bac" + }, + { + "id": "visual_prompt-03-sensenova_sa1b_visual_1573415", + "route": "visual_prompt", + "route_title": "Visual-prompt retrieval", + "title": "Visual-prompt retrieval #3", + "prompt": "\nGiven reference boxes <|box_start|><499><742><541><810><|box_end|> indicating one or more objects, find all similar objects in the image and output their bounding boxes.", + "expected": "<|object_ref_start|>object<|object_ref_end|><|box_start|><0><684><34><728>,<0><686><6><729>,<1><683><33><719>,<2><680><27><718>,<3><657><25><716>,<29><655><48><719>,<46><663><66><690>,<50><628><60><665>,<80><698><105><730>,<82><693><107><726>,<115><676><148><712>,<118><674><149><710>,<119><677><144><750>,<120><670><151><708>,<147><711><176><754>,<153><706><183><752>,<168><672><182><722>,<185><746><258><786>,<208><715><257><753>,<229><652><238><689>,<262><651><281><698>,<305><740><337><790>,<331><673><348><717>,<340><758><379><785>,<342><669><362><700>,<367><716><401><784>,<389><668><414><692>,<413><709><426><762>,<424><707><437><748>,<445><681><461><703>,<467><675><480><710>,<481><744><549><814>,<499><742><541><810>,<501><667><512><697>,<506><743><538><806>,<546><778><597><815>,<551><674><565><695>,<562><671><574><696>,<579><741><589><776>,<584><653><607><678>,<585><726><603><774>,<585><727><600><777>,<586><726><602><775>,<587><728><604><776>,<619><668><636><694>,<644><679><664><705>,<678><787><701><817>,<714><779><728><805>,<767><670><783><691>,<819><666><846><688>,<835><789><865><825>,<861><794><888><827>,<897><660><914><684>,<991><599><999><627>,<994><659><999><674><|box_end|>", + "image": "cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg", + "source": "a_sa1b_visual_gt20", + "image_sha256": "6e65b33e404159b9c2117b27a21de5a897ebb73da1b95bdc3bec07e0d16b01be", + "difficulty": { + "score": 80.37, + "primitive_count": 55, + "label_count": 1, + "smallest_bbox_area_ratio": 7.52e-05, + "prompt_chars": 177 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "2593b4f81c4fbfd70e73df0710fb143af232126daa0a96bc86c72575713475a5" + }, + { + "id": "ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189", + "route": "ocr", + "route_title": "OCR grounding", + "title": "OCR grounding #1", + "prompt": "\nOCR task detect all the text in box format.", + "expected": "<|object_ref_start|>-mostro.sc1<|object_ref_end|><|box_start|><97><8><167><26><|box_end|>, <|object_ref_start|>0.05<|object_ref_end|><|box_start|><963><973><988><992><|box_end|>, <|object_ref_start|>1.02<|object_ref_end|><|box_start|><69><7><97><26><|box_end|>, <|object_ref_start|>525838<|object_ref_end|><|box_start|><12><927><53><943><|box_end|>, <|object_ref_start|>Airbrush<|object_ref_end|><|box_start|><171><43><218><59><|box_end|>, <|object_ref_start|>Alice<|object_ref_end|><|box_start|><548><973><572><990><|box_end|>, <|object_ref_start|>BRUSH<|object_ref_end|><|box_start|><476><47><513><64><|box_end|>, <|object_ref_start|>Detail<|object_ref_end|><|box_start|><403><64><440><82><|box_end|>, <|object_ref_start|>Enable<|object_ref_end|><|box_start|><482><141><516><156><|box_end|>, <|object_ref_start|>FriendF...<|object_ref_end|><|box_start|><465><973><512><991><|box_end|>, <|object_ref_start|>IT<<|object_ref_end|><|box_start|><880><974><907><991><|box_end|>, <|object_ref_start|>Invert<|object_ref_end|><|box_start|><271><43><309><61><|box_end|>, <|object_ref_start|>Lazy<|object_ref_end|><|box_start|><222><43><251><62><|box_end|>, <|object_ref_start|>M<|object_ref_end|><|box_start|><27><217><42><236><|box_end|>, <|object_ref_start|>MATERIAL<|object_ref_end|><|box_start|><535><47><592><65><|box_end|>, <|object_ref_start|>Mo...<|object_ref_end|><|box_start|><570><973><598><989><|box_end|>, <|object_ref_start|>OPTIONS<|object_ref_end|><|box_start|><379><116><422><133><|box_end|>, <|object_ref_start|>PAINT<|object_ref_end|><|box_start|><639><90><687><112><|box_end|>, <|object_ref_start|>PINCH<|object_ref_end|><|box_start|><136><124><184><145><|box_end|>, <|object_ref_start|>Ps<|object_ref_end|><|box_start|><163><970><177><989><|box_end|>, <|object_ref_start|>Sculptris<|object_ref_end|><|box_start|><18><7><69><27><|box_end|>, <|object_ref_start|>Sculptris...<|object_ref_end|><|box_start|><802><976><851><994><|box_end|>, <|object_ref_start|>Size<|object_ref_end|><|box_start|><349><64><377><82><|box_end|>, <|object_ref_start|>Strenght<|object_ref_end|><|box_start|><349><87><400><109><|box_end|>, <|object_ref_start|>W<|object_ref_end|><|box_start|><51><215><69><230><|box_end|>, <|object_ref_start|>Window...<|object_ref_end|><|box_start|><632><973><681><990><|box_end|>, <|object_ref_start|>X<|object_ref_end|><|box_start|><979><3><997><26><|box_end|>, <|object_ref_start|>[Q]<|object_ref_end|><|box_start|><439><62><461><85><|box_end|>, <|object_ref_start|>[x]<|object_ref_end|><|box_start|><310><43><330><65><|box_end|>, <|object_ref_start|>_<|object_ref_end|><|box_start|><939><14><952><26><|box_end|>, <|object_ref_start|>e<|object_ref_end|><|box_start|><101><969><119><994><|box_end|>, <|object_ref_start|>material5<|object_ref_end|><|box_start|><537><137><591><154><|box_end|>, <|object_ref_start|>sculptris<|object_ref_end|><|box_start|><717><973><754><992><|box_end|>, <|object_ref_start|>start<|object_ref_end|><|box_start|><28><970><66><992><|box_end|>, <|object_ref_start|>triangles<|object_ref_end|><|box_start|><53><926><101><948><|box_end|>", + "image": "cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg", + "source": "la_ocr_textocr", + "image_sha256": "084cf0562914bfea25769f2548257093c2b685444b3b3f366fa970183b07924e", + "difficulty": { + "score": 77.92, + "primitive_count": 35, + "label_count": 35, + "smallest_bbox_area_ratio": 0.0001563, + "prompt_chars": 51 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "4634583edfab147e8708c6119e726fb8f394744e0225c8319136bb5000ba5d8c" + }, + { + "id": "ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671", + "route": "ocr", + "route_title": "OCR grounding", + "title": "OCR grounding #2", + "prompt": "\nOCR task detect all the text in box format.", + "expected": "<|object_ref_start|>.<|object_ref_end|><|box_start|><198><856><311><920>,<788><146><799><156><|box_end|>, <|object_ref_start|>12<|object_ref_end|><|box_start|><803><193><815><206><|box_end|>, <|object_ref_start|>135012<|object_ref_end|><|box_start|><739><877><775><891><|box_end|>, <|object_ref_start|>14,<|object_ref_end|><|box_start|><793><68><807><82><|box_end|>, <|object_ref_start|>23<|object_ref_end|><|box_start|><363><348><388><374><|box_end|>, <|object_ref_start|>2·<|object_ref_end|><|box_start|><426><348><444><370><|box_end|>, <|object_ref_start|>50<|object_ref_end|><|box_start|><807><66><820><79><|box_end|>, <|object_ref_start|>A-dur·<|object_ref_end|><|box_start|><371><263><438><294><|box_end|>, <|object_ref_start|>AS-dur<|object_ref_end|><|box_start|><500><230><570><260><|box_end|>, <|object_ref_start|>Abegg-<|object_ref_end|><|box_start|><318><305><385><340><|box_end|>, <|object_ref_start|>As-dur<|object_ref_end|><|box_start|><618><267><689><299><|box_end|>, <|object_ref_start|>Deutsche<|object_ref_end|><|box_start|><729><121><767><133><|box_end|>, <|object_ref_start|>F-dur<|object_ref_end|><|box_start|><580><306><639><337><|box_end|>, <|object_ref_start|>Fis-moll<|object_ref_end|><|box_start|><529><342><603><378><|box_end|>, <|object_ref_start|>GOOD<|object_ref_end|><|box_start|><798><145><817><155><|box_end|>, <|object_ref_start|>Ges-dur·<|object_ref_end|><|box_start|><543><266><623><297><|box_end|>, <|object_ref_start|>Gesellschaft<|object_ref_end|><|box_start|><726><139><770><154><|box_end|>, <|object_ref_start|>Grammophon<|object_ref_end|><|box_start|><716><125><781><145><|box_end|>, <|object_ref_start|>Grand<|object_ref_end|><|box_start|><229><262><292><293><|box_end|>, <|object_ref_start|>Impromptus<|object_ref_end|><|box_start|><437><264><544><302><|box_end|>, <|object_ref_start|>KLAVIERMUSIK<|object_ref_end|><|box_start|><236><142><666><214><|box_end|>, <|object_ref_start|>Moment<|object_ref_end|><|box_start|><351><228><433><258><|box_end|>, <|object_ref_start|>Naschtstiick<|object_ref_end|><|box_start|><237><337><339><378><|box_end|>, <|object_ref_start|>Novellette<|object_ref_end|><|box_start|><442><340><533><380>,<489><305><580><346><|box_end|>, <|object_ref_start|>Nr·<|object_ref_end|><|box_start|><388><340><425><379><|box_end|>, <|object_ref_start|>P·<|object_ref_end|><|box_start|><338><346><363><376><|box_end|>, <|object_ref_start|>ROMANTISCHE<|object_ref_end|><|box_start|><167><60><601><132><|box_end|>, <|object_ref_start|>Rondeau<|object_ref_end|><|box_start|><289><263><372><303><|box_end|>, <|object_ref_start|>SCHUBERT:<|object_ref_end|><|box_start|><211><228><349><257><|box_end|>, <|object_ref_start|>SCHUMANN:<|object_ref_end|><|box_start|><172><302><321><335><|box_end|>, <|object_ref_start|>STEREO<|object_ref_end|><|box_start|><738><891><775><904><|box_end|>, <|object_ref_start|>Variationen·<|object_ref_end|><|box_start|><383><303><492><335><|box_end|>, <|object_ref_start|>musical<|object_ref_end|><|box_start|><432><229><502><259><|box_end|>", + "image": "cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg", + "source": "la_ocr_textocr", + "image_sha256": "0fe7ad3b5db7ef62e387a7dd49adf9e03408df83520854d63595274d1f69ea6d", + "difficulty": { + "score": 77.37, + "primitive_count": 35, + "label_count": 33, + "smallest_bbox_area_ratio": 0.0001102, + "prompt_chars": 51 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "8db936cadff524299c5b61b94992f3b70ec90e1dd3873f072b34d41692393bdd" + }, + { + "id": "ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130", + "route": "ocr", + "route_title": "OCR grounding", + "title": "OCR grounding #3", + "prompt": "\nOCR task detect all the text in box format.", + "expected": "<|object_ref_start|>.<|object_ref_end|><|box_start|><240><637><318><680>,<355><657><556><714><|box_end|>, <|object_ref_start|>0955075<|object_ref_end|><|box_start|><784><194><867><220><|box_end|>, <|object_ref_start|>15<|object_ref_end|><|box_start|><779><285><872><359><|box_end|>, <|object_ref_start|>2011.<|object_ref_end|><|box_start|><933><423><942><453><|box_end|>, <|object_ref_start|>49077<|object_ref_end|><|box_start|><132><238><163><253><|box_end|>, <|object_ref_start|>5168442<|object_ref_end|><|box_start|><793><247><878><272><|box_end|>, <|object_ref_start|>996.<|object_ref_end|><|box_start|><917><529><927><554><|box_end|>, <|object_ref_start|>A<|object_ref_end|><|box_start|><505><735><558><817><|box_end|>, <|object_ref_start|>AUG<|object_ref_end|><|box_start|><108><262><175><320><|box_end|>, <|object_ref_start|>BBC<|object_ref_end|><|box_start|><919><431><930><457><|box_end|>, <|object_ref_start|>Bang<|object_ref_end|><|box_start|><931><487><942><516><|box_end|>, <|object_ref_start|>Bil<|object_ref_end|><|box_start|><930><519><939><534><|box_end|>, <|object_ref_start|>CAR<|object_ref_end|><|box_start|><319><705><434><792><|box_end|>, <|object_ref_start|>CHINA<|object_ref_end|><|box_start|><933><380><943><421><|box_end|>, <|object_ref_start|>DCTWHO<|object_ref_end|><|box_start|><207><340><865><696><|box_end|>, <|object_ref_start|>DOCTOR<|object_ref_end|><|box_start|><230><176><477><268><|box_end|>, <|object_ref_start|>Doctor<|object_ref_end|><|box_start|><912><660><923><702><|box_end|>, <|object_ref_start|>IS<|object_ref_end|><|box_start|><444><724><496><802><|box_end|>, <|object_ref_start|>Licensed<|object_ref_end|><|box_start|><917><475><929><526><|box_end|>, <|object_ref_start|>Limited.<|object_ref_end|><|box_start|><922><326><933><368><|box_end|>, <|object_ref_start|>MY<|object_ref_end|><|box_start|><71><666><142><733><|box_end|>, <|object_ref_start|>OTHER<|object_ref_end|><|box_start|><144><677><311><769><|box_end|>, <|object_ref_start|>Pow|<|object_ref_end|><|box_start|><932><456><941><484><|box_end|>, <|object_ref_start|>TARDIS<|object_ref_end|><|box_start|><571><744><833><871><|box_end|>, <|object_ref_start|>VA<|object_ref_end|><|box_start|><112><240><130><259>,<759><243><786><276><|box_end|>, <|object_ref_start|>VIRGINIA<|object_ref_end|><|box_start|><264><259><653><322><|box_end|>, <|object_ref_start|>WHO<|object_ref_end|><|box_start|><495><161><673><251><|box_end|>, <|object_ref_start|>Who<|object_ref_end|><|box_start|><913><633><924><660><|box_end|>, <|object_ref_start|>Worldwide<|object_ref_end|><|box_start|><920><370><932><430><|box_end|>, <|object_ref_start|>bilbangpow.com<|object_ref_end|><|box_start|><927><550><940><644><|box_end|>, <|object_ref_start|>by<|object_ref_end|><|box_start|><919><460><932><474><|box_end|>, <|object_ref_start|>logo<|object_ref_end|><|box_start|><914><604><927><631><|box_end|>, <|object_ref_start|>©BBC<|object_ref_end|><|box_start|><915><563><926><604><|box_end|>", + "image": "cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg", + "source": "la_ocr_textocr", + "image_sha256": "49ac957ecd099dc726c9d6c34b3cda4a783788a86982b3abb614991901cdb22b", + "difficulty": { + "score": 77.11, + "primitive_count": 35, + "label_count": 33, + "smallest_bbox_area_ratio": 0.0001353, + "prompt_chars": 51 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "d959da84d676117701e6d3920bff692aab94d6075e5714e2a324df3b61f18cf8" + }, + { + "id": "layout-01-layout_doclaynet_train_16966", + "route": "layout", + "route_title": "Document layout grounding", + "title": "Document layout grounding #1", + "prompt": "\nDetect all document layout elements that match the following categories: Section-headerPage-footerTextList-itemPicturePage-header.", + "expected": "<|object_ref_start|>Section-header<|object_ref_end|><|box_start|><149><315><223><326>,<149><542><382><552>,<149><723><235><733>,<409><149><521><158>,<409><164><439><173>,<409><245><448><254>,<539><315><687><326>,<539><436><680><447>,<539><738><705><749>,<539><829><787><839>,<661><232><708><241>,<661><164><710><173><|box_end|>, <|object_ref_start|>Page-footer<|object_ref_end|><|box_start|><631><968><820><979><|box_end|>, <|object_ref_start|>Text<|object_ref_end|><|box_start|><149><739><507><869>,<149><558><513><703>,<149><331><513><522>,<539><754><891><809>,<539><845><867><900>,<539><452><881><507>,<539><528><902><598>,<539><618><902><718>,<539><331><890><416><|box_end|>, <|object_ref_start|>List-item<|object_ref_end|><|box_start|><409><177><502><187>,<409><190><530><200>,<409><203><558><213>,<409><217><500><226>,<409><258><533><268>,<661><177><782><187>,<661><190><754><200>,<661><203><813><213>,<661><245><785><255><|box_end|>, <|object_ref_start|>Picture<|object_ref_end|><|box_start|><149><145><380><278>,<831><964><899><980><|box_end|>, <|object_ref_start|>Page-header<|object_ref_end|><|box_start|><461><35><899><46>,<935><35><948><46><|box_end|>", + "image": "cases/layout/layout-01-layout_doclaynet_train_16966.jpg", + "source": "layout_doclaynet_train", + "image_sha256": "a0aa7586551498591fd1e73f1b6f202d9e7579032cd5c1b8bd41b504bf6108c8", + "difficulty": { + "score": 65.53, + "primitive_count": 35, + "label_count": 6, + "smallest_bbox_area_ratio": 0.0001433, + "prompt_chars": 158 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "8ba09e49907c5d7a3a31148a3fceaf2695bd04f35a017a62ef8c455b985f7218" + }, + { + "id": "layout-02-layout_doclaynet_train_20356", + "route": "layout", + "route_title": "Document layout grounding", + "title": "Document layout grounding #2", + "prompt": "\nDetect all document layout elements that match the following categories: Page-headerTextSection-headerList-itemTablePage-footer.", + "expected": "<|object_ref_start|>Page-header<|object_ref_end|><|box_start|><719><22><934><29><|box_end|>, <|object_ref_start|>Text<|object_ref_end|><|box_start|><120><783><516><865>,<120><870><505><893>,<141><161><516><228>,<141><233><506><300>,<141><494><518><561>,<141><624><516><734>,<157><349><507><372>,<157><392><225><401>,<157><407><484><416>,<538><783><904><807>,<538><812><930><893>,<559><175><925><257>,<559><305><641><314>,<559><363><641><372>,<559><421><936><459>,<559><509><923><538>,<559><624><928><676>,<559><711><929><734><|box_end|>, <|object_ref_start|>Section-header<|object_ref_end|><|box_start|><120><130><227><141>,<120><593><260><604>,<120><767><855><778>,<120><146><470><155>,<120><320><404><329>,<120><436><516><488>,<120><609><399><618>,<538><276><882><300>,<538><334><903><358>,<538><392><919><416>,<538><146><875><170>,<538><696><888><705><|box_end|>, <|object_ref_start|>List-item<|object_ref_end|><|box_start|><141><378><296><387>,<141><334><309><343><|box_end|>, <|object_ref_start|>Table<|object_ref_end|><|box_start|><558><464><855><503><|box_end|>, <|object_ref_start|>Page-footer<|object_ref_end|><|box_start|><916><954><933><964><|box_end|>", + "image": "cases/layout/layout-02-layout_doclaynet_train_20356.jpg", + "source": "layout_doclaynet_train", + "image_sha256": "08c9756fc09c342e284e880c2ecaefd0766996e299df223a5b944b62d7b4d477", + "difficulty": { + "score": 65.31, + "primitive_count": 35, + "label_count": 6, + "smallest_bbox_area_ratio": 0.0001703, + "prompt_chars": 156 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "5fbf03f82cc66566e4630547b53b7f51cd0ebd772a072c1d6f37f8c0bafdb646" + }, + { + "id": "layout-03-layout_doclaynet_train_3435", + "route": "layout", + "route_title": "Document layout grounding", + "title": "Document layout grounding #3", + "prompt": "\nDetect all document layout elements that match the following categories: Section-headerTextCaptionPicturePage-footerPage-header.", + "expected": "<|object_ref_start|>Section-header<|object_ref_end|><|box_start|><75><135><318><146>,<632><504><780><515><|box_end|>, <|object_ref_start|>Text<|object_ref_end|><|box_start|><75><153><314><288>,<75><294><320><358>,<75><364><305><376>,<75><382><311><411>,<75><417><314><464>,<75><470><316><499>,<75><505><299><535>,<75><541><319><728>,<75><734><316><922>,<353><135><586><252>,<353><258><598><481>,<353><487><597><816>,<353><839><583><921>,<369><822><601><833>,<632><135><861><234>,<632><240><869><305>,<632><311><867><358>,<632><364><875><428>,<632><434><877><481>,<632><522><875><622>,<632><628><876><692>,<632><716><721><727><|box_end|>, <|object_ref_start|>Caption<|object_ref_end|><|box_start|><632><786><736><816><|box_end|>, <|object_ref_start|>Picture<|object_ref_end|><|box_start|><633><739><871><781><|box_end|>, <|object_ref_start|>Page-footer<|object_ref_end|><|box_start|><33><965><41><974>,<75><953><483><961><|box_end|>, <|object_ref_start|>Page-header<|object_ref_end|><|box_start|><32><117><40><194>,<32><257><40><353>,<32><398><40><423>,<32><539><40><621>,<32><680><40><746>,<32><821><40><881><|box_end|>", + "image": "cases/layout/layout-03-layout_doclaynet_train_3435.jpg", + "source": "layout_doclaynet_train", + "image_sha256": "5dcc96a6ad6cdafeec656e05d8f7866c232ba9773ec2d05a180afd203490b356", + "difficulty": { + "score": 65.23, + "primitive_count": 34, + "label_count": 6, + "smallest_bbox_area_ratio": 7.21e-05, + "prompt_chars": 156 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "8e035b83d1ca53298816550d4891fd9f2d84f83b59bba178cafdf6bf8623a9fe" + }, + { + "id": "gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008", + "route": "gui", + "route_title": "GUI action grounding", + "title": "GUI action grounding #1", + "prompt": "\nPoint to the UI element to click for the following instruction: A horizontal row of special characters including accented letters, symbols, and diacritics such as 'À', 'Á', 'Â', 'Ä', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý'.", + "expected": "<|object_ref_start|>A horizontal row of special characters including accented letters, symbols, and diacritics such as 'À', 'Á', 'Â', 'Ä', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý'<|object_ref_end|><|box_start|><493><491><|box_end|>", + "image": "cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg", + "source": "la_groundcua", + "image_sha256": "1bd406dd0960bbdfdf5ff6980ba4e0e936826c79002f38321b4f3f7397beb811", + "difficulty": { + "score": 24.4, + "primitive_count": 1, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 310 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "c9c27a9df49bac1c9664eb74ecf1fe9967e20281add73fff1273437af06b743b" + }, + { + "id": "gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028", + "route": "gui", + "route_title": "GUI action grounding", + "title": "GUI action grounding #2", + "prompt": "\nPoint to the UI element to click for the following instruction: A vertical list of file names in the file explorer, including 'vlc-3.0.2...', 'FreeCAD...', 'QGIS-OS...', 'Element...', 'disciples...', 'SSS.pdf', 'THE BRA...', 'Rose Cov...', and 'New fold...'.", + "expected": "<|object_ref_start|>A vertical list of file names in the file explorer, including 'vlc-3.0.2...', 'FreeCAD...', 'QGIS-OS...', 'Element...', 'disciples...', 'SSS.pdf', 'THE BRA...', 'Rose Cov...', and 'New fold...'<|object_ref_end|><|box_start|><500><555><|box_end|>", + "image": "cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg", + "source": "la_groundcua", + "image_sha256": "e21623711f386c778799fd3a7a447d82be992c9078b0b3a7a291b134584f0fff", + "difficulty": { + "score": 22.64, + "primitive_count": 1, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 266 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "7ff12fde621319e2959b3112fa6c1fe4e6ef83b8943a6ee169d7fc2140f59e74" + }, + { + "id": "gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052", + "route": "gui", + "route_title": "GUI action grounding", + "title": "GUI action grounding #3", + "prompt": "\nPoint to the UI element to click for the following instruction: A table section displaying existing tasks with columns for ID, SUBJECT, TYPE, STATUS, ASSIGNEE, and PRIORITY, including entries like 'Organize open source conf...' and 'End of project'.", + "expected": "<|object_ref_start|>A table section displaying existing tasks with columns for ID, SUBJECT, TYPE, STATUS, ASSIGNEE, and PRIORITY, including entries like 'Organize open source conf...' and 'End of project'<|object_ref_end|><|box_start|><289><535><|box_end|>", + "image": "cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg", + "source": "la_groundcua", + "image_sha256": "08d3f95cdc3dc2fcc0572d2631ddec2ce9af1a0c77bd62619b06b05b81876d13", + "difficulty": { + "score": 22.28, + "primitive_count": 1, + "label_count": 1, + "smallest_bbox_area_ratio": null, + "prompt_chars": 257 + }, + "validation": { + "protocol": "PASS", + "coordinates": "PASS", + "media_decode": "PASS", + "selection": "hardness_ranked" + }, + "artifact_image_sha256": "8ba06f95a90cf6954aa7c8f7554b4f28d966afbfc8b8151c96e540e224139cf5" + } +] diff --git a/docs/HF_SPACE_DEPLOYMENT.md b/docs/HF_SPACE_DEPLOYMENT.md new file mode 100644 index 0000000000000000000000000000000000000000..3f74e0b2e6cdd696e45967a3f7baf0b6e248b75f --- /dev/null +++ b/docs/HF_SPACE_DEPLOYMENT.md @@ -0,0 +1,67 @@ +# Hugging Face deployment + +This guide describes a candidate deployment, not an already-created HF service. +The model repository belongs to XPENG-AI; this private Space is hosted under +FanLR. Both repository names and private deployment have been confirmed. + +## Two repositories + +- Model repository: contents of the sibling `model/` directory; proposed ID + `XPENG-AI/GroundingPI-4B`. +- Gradio Space: contents of this `demo/` directory; proposed ID + `FanLR/GroundingPI-4B`. + +The parent release workspace includes internal review material and must not be +uploaded. Uploading files privately is still a transfer to an external platform. + +## Private preview and hardware + +Create both repositories as **Private from the beginning**. Protected Spaces hide +source code but expose the running application, so Protected is not a confidential +preview mode. Organization access depends on its roles and grants; verify the +actual reader set rather than assuming Private means only the uploader. +[Visibility](https://huggingface.co/docs/hub/spaces-overview#space-visibility), +[organization access](https://huggingface.co/docs/hub/organizations-security). + +Choose Gradio and confirm available hardware before upload. According to current +official documentation, organization ZeroGPU hosting requires a Team/Enterprise +plan. Personal free-tier eligibility does not establish organization eligibility. +Do not enable paid hardware or change subscriptions without approval. +[ZeroGPU eligibility](https://huggingface.co/docs/hub/spaces-zerogpu). + +## Configuration + +| Location | Name | Value | +| --- | --- | --- | +| Variable | GROUNDING_BACKEND | zerogpu | +| Variable | GROUNDING_MODEL_REPO | Reviewed model repository ID | +| Variable | GROUNDING_MODEL_REVISION | Full 40-character commit SHA | +| Variable | GROUNDING_MAX_TOKENS | 1024 | +| Variable | GROUNDING_GPU_SECONDS | 120; tune only after measurement | +| Secret | HF_TOKEN | Read access limited to the private model | + +Do not set internal deployment variables or a local model path in HF. +The repository snapshot is downloaded using its pinned revision and then loaded +locally, because the custom processor opens local configuration files. +Never place a token in README, source, Variables, a URL or a screenshot. +[Secrets](https://huggingface.co/docs/hub/spaces-overview#managing-secrets-and-environment-variables). + +Keep the README SDK configuration: `app_file: space_app.py`, +Gradio 5.49.1 and Python 3.12.12. Use the supplied standard NVIDIA Torch dependency +pins, not a vendor PPU environment. The runtime imports spaces before loading +the model; GPU work alone runs through `@spaces.GPU`. + +## Acceptance before wider access + +1. Validate build dependencies, complete model loading and memory use. +2. Run every task family at least once; inspect actual pixels, raw tokens and EOS. +3. Record unsuccessful calls as well as successes. Curated training examples are + not an independent accuracy benchmark. +4. Verify first request, repeated requests, GPU lease release/reallocation, quota + exhaustion, timeout recovery and session isolation. +5. Confirm owner access and unauthorized-user denial for both repositories and + the running application. A logged-out access check is part of acceptance. +6. Pin and record model and Space revisions. Do not automatically make either public. + +No HF login, upload, repository creation, hardware purchase or publication is +performed by this document. Recheck platform policies when deploying. diff --git a/docs/UI_PAPER_R7.md b/docs/UI_PAPER_R7.md new file mode 100644 index 0000000000000000000000000000000000000000..8f3240ac1ada9e5b79802ca8884fb7fc8ebc16bb --- /dev/null +++ b/docs/UI_PAPER_R7.md @@ -0,0 +1,26 @@ +# Paper demo UI · r7 + +User-requested revision, 2026-09-15. The original reference layout is preserved; +purple/lime colors follow the supplied paper figure. The XPENG logo is unchanged. + +- English interface, task guides, runtime states, recovery messages and accessibility labels. +- Predictions appear directly on the main image. The original/model/reference view selector + and reference-answer UI endpoint have been removed. Example input boxes in the Visual + Prompt task remain input conditions, not reference answers. +- Overlays use unfilled outlines. A large late region can no longer erase smaller targets. + Class labels are laid out separately, clamped, and omitted if they would cover small + targets or another label. Dense classes remain available in the linked inspector. +- Geometry is not deduplicated, suppressed, merged, moved, or changed for presentation. +- The input image and prompt still form the entire model request. No ground truth is sent. +- Case counts and training-set counts are no longer presented as headline copy. +- The original release lock remains in `ui_lock.json`; `ui_paper_r7_lock.json` records + this explicitly authorized revision. Data, source examples, and model weights are unchanged. + +`validate_gradio.py` uses the new direct-overlay API result order: +image, metrics, targets, normalized JSON, raw tokens, status, desktop action, mobile action. +Historical API receipts remain unchanged. This revision is not a new accuracy evaluation. + +Verification: run `python -m unittest discover -s tests -v` and `python scripts/verify_ui.py`. +Browser verification must cover desktop/mobile layout, direct overlays, category/instance +focus, zoom/reset, upload and case transitions, and error recovery. The old reference-view +browser script is historical and does not match this UI contract. diff --git a/docs/VERIFICATION.md b/docs/VERIFICATION.md new file mode 100644 index 0000000000000000000000000000000000000000..6e949102fa1854d440d3ef6ca62c2354d6eb1ecf --- /dev/null +++ b/docs/VERIFICATION.md @@ -0,0 +1,44 @@ +# Verification and evidence boundaries + +## Existing service evidence — 2026-09-15 + +The native implementation was installed in a new isolated application environment +on a single PPU. The full model loaded and generated real outputs. A 27-example +Gradio regression completed uploads, generation with EOS and GAM parsing without +transport/format failures. This is not 100% semantic accuracy. + +The original serial PPU request window had median 5.069 s and P95 14.532 s +(nearest rank, 27 requests). These are historical observations for that hardware +and workload, not HF latency guarantees or paper benchmark measurements. + +The paper-r7 UI regression included 39 passing tests and browser verification of +direct prediction overlays, category focus, instance navigation, zoom, stale-state +clearing and responsive layout. Example live calls returned 27 boxes and 79 points; +counts are output observations, not verified recall. + +## This release candidate + +The presentation and inference implementation are copied from the paper-r7 release. +README and deployment materials have been rewritten for external publication. +The UI fingerprint and example contracts remain locked. Model weights, tokenizer +and image processing remain byte-identical to the source. The cleaned custom +code has canonical Oxygen class names and no unused Mage/StreamMind branches. +Strict loading has no missing, unexpected or mismatched keys. Before/after +Transformers regression matched all generated tokens for all 27 examples, with +identical preprocessing tensors. This is equivalence, not semantic accuracy. + +The parent release workspace contains the technical inspection report. Reported +tests must not be read as license approval, independent benchmark evaluation, or +approval to disclose model/data assets. + +## Still pending + +- Standard NVIDIA GPU and final HF ZeroGPU execution. +- GPU lease capture, allocation/release, quota and long-idle cold starts. +- Private organization access verification and external-upload authorization. +- Independent accuracy evaluation and any paper speedup claims. +- Final legal, model-card, example-image and branding review. + +The code does not run diffusion/parallel decoding just because a paper illustration +discusses it. Publish only results verified for the exact released checkpoint, +decoding method, hardware and evaluation protocol. diff --git a/docs/ZEROGPU_DEPLOYMENT.md b/docs/ZEROGPU_DEPLOYMENT.md new file mode 100644 index 0000000000000000000000000000000000000000..79c1352f00562983b4cae2ff78ee38473c0da9d6 --- /dev/null +++ b/docs/ZEROGPU_DEPLOYMENT.md @@ -0,0 +1,47 @@ +# Runtime and model contract + +## Initialization versus requests + +`space_app.py` installs the spaces CUDA hooks and initializes the model once at +process startup. In a ZeroGPU Space, the decorated generation function leases GPU +compute and returns CPU token IDs. It does not call from_pretrained per request. +The same code can run on a normal compatible GPU, where the decorator is effect-free. +[Official model-loading guidance](https://huggingface.co/docs/hub/spaces-zerogpu#model-loading). + +The default implementation is native Transformers, not a persistent vLLM or SGLang +server. An explicitly configured HTTP backend exists for approved deployments, but +no automatic backend fallback is used. + +## Frozen behavior + +- `oxygen_vl_v3` / `OxygenVLv3ForConditionalGeneration`; vision model type + `oxygen_k3_vision`. +- Download a reviewed, pinned snapshot; load the checkpoint's processor from a local + directory with `trust_remote_code=True`. +- Apply the original chat template to the current image and request. +- Preserve native image processing, image token/grid alignment and GAM vocabulary. +- BF16, SDPA, greedy generation and `use_cache=True`; native EOS from generation config. +- Preserve `skip_special_tokens=False` and `spaces_between_special_tokens=False`. +- Reject missing pixels/grid, context overflow, empty answers and missing EOS. +- Do not send annotations, reference counts or previous results to the model. +- Do not claim token-identical output or equal latency across hardware/backends. + +The model package contains optional StreamMind source for provenance; this demo does +not enable that branch or require mamba-ssm. Do not copy a training environment into +the Space or install vendor-specific Torch wheels. + +## Limits and failures + +Default 1,024 new tokens; supported UI/runtime range 1–2,048. Input plus requested +output must not exceed 8,192 tokens. GPU duration is a maximum lease, not a latency +promise. Queue waits and initialization must be distinguished from generation. + +Incomplete output is a failure, not a correct empty result. On exceptions, the UI +clears stale predictions, restores its controls and exposes a recoverable error. +The example annotations are never used as fallback predictions. + +## Deployment boundary + +PPU service verification does not validate NVIDIA CUDA, ZeroGPU capture/leases, +platform quotas or an organization's permissions. These are final-platform checks. +See [HF deployment](HF_SPACE_DEPLOYMENT.md) and [verification](VERIFICATION.md). diff --git a/docs/ui_lock.json b/docs/ui_lock.json new file mode 100644 index 0000000000000000000000000000000000000000..f8640091e721c87a01b359e54247f1ee0b28b912 --- /dev/null +++ b/docs/ui_lock.json @@ -0,0 +1,47 @@ +{ + "files": { + "app.py": "e4662437b3835915f690fcdc658994aa59c1f32818db151a1d6e6d0a04ec09f5", + "assets/Manrope-OFL.txt": "e01b637272e0cbdfb240184dd98ea5cc671556d9894dae2668d92ab2c906787c", + "assets/Manrope-variable.ttf": "d0639be45d0af36e798172419d7bd173c4bd4f29e2b76cbb69db1d11bf8b0a40", + "assets/SOURCES.md": "3cceb52136b55f86840e9585e3c37faed1adc762452b0fea50aecba696dac7fa", + "assets/console.js": "cb72bd437e702d2b9536f1a20a21ead38d81d0b8208854c5ec978adf41659365", + "assets/frosted.css": "393bf5f1c04a49a6e9b17e855e573646489b4add85bc7973eb6bb277686b5c80", + "assets/original.css": "ecee3334f0d1b5e58f31548939445b73cd31e9ad8c92accea7471c37369aaf2b", + "assets/paper.css": "0b9991dcf3c02b10f937b17b961f774844b9dcec3ff0a3effa41549c73453337", + "assets/xpeng-logo.png": "ff0db78ddf8f9a122eec74e8eb79581f8e5dbc46803dddeb780a06f5ae295750", + "cases/dense/dense-01-o365_bbox_gt50_00009110.jpg": "398038106cbac731516dd01de25354fe4d61f3599df64baa611f1d5a99e0e8fb", + "cases/dense/dense-02-o365_bbox_gt50_00004676.jpg": "7ee3beb63bdfd50c183538bd56f9d7e079fa41bde78aad9d5fe0d22c041c2673", + "cases/dense/dense-03-o365_bbox_gt50_00011992.jpg": "eb9331146b66a1af1e8c832a22043c6f1b45d5d3bb7231816f975ced2cd88e39", + "cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg": "917975c9b31791290a2a660c91af8ae0653cfe258fa0c53539bcb868867aece2", + "cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg": "0b9a2281fec580c02b9292d8b3f96b675a8659d721f4dd8a1ae16a1eadbaf4e9", + "cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg": "d2f0e070f49cc001ef6855964175c8c383358fcc2185d62abf29ba0de0d1be22", + "cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg": "2e3946eafcbdc2d2ac9e0b62343595e0b51e71b38eb15c3b0669fab46c78e9f6", + "cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg": "c6abef94a28290ca94e8dd043ba58e326cfcb22088b75f32274acc07af15950c", + "cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg": "ff9581327870a05ad8679c3e5891f27dfe55acc98ed713a8abf8d02e7604774b", + "cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg": "c9c27a9df49bac1c9664eb74ecf1fe9967e20281add73fff1273437af06b743b", + "cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg": "7ff12fde621319e2959b3112fa6c1fe4e6ef83b8943a6ee169d7fc2140f59e74", + "cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg": "8ba06f95a90cf6954aa7c8f7554b4f28d966afbfc8b8151c96e540e224139cf5", + "cases/layout/layout-01-layout_doclaynet_train_16966.jpg": "8ba09e49907c5d7a3a31148a3fceaf2695bd04f35a017a62ef8c455b985f7218", + "cases/layout/layout-02-layout_doclaynet_train_20356.jpg": "5fbf03f82cc66566e4630547b53b7f51cd0ebd772a072c1d6f37f8c0bafdb646", + "cases/layout/layout-03-layout_doclaynet_train_3435.jpg": "8e035b83d1ca53298816550d4891fd9f2d84f83b59bba178cafdf6bf8623a9fe", + "cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg": "4634583edfab147e8708c6119e726fb8f394744e0225c8319136bb5000ba5d8c", + "cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg": "8db936cadff524299c5b61b94992f3b70ec90e1dd3873f072b34d41692393bdd", + "cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg": "d959da84d676117701e6d3920bff692aab94d6075e5714e2a324df3b61f18cf8", + "cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg": "e5233bcfadb4d6cb3be1a0ac75573183084494661dd31cc42e7282d21b6c3e13", + "cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg": "df60dcc4812e93720202874e7b88cca122b25ff2615dd31e2bd697a552bce322", + "cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg": "e4fc006bbcb49c5e57c3b002a35e5866c15c898d6930117e0f89617121cd3928", + "cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg": "4fac0cc45af121260bc7468aa63fbe7f6dfdcbc5a2f251c04a8a0e06212048df", + "cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg": "9b7ec8dc3ad013a57fab9d1199ee0ce14a3104f8e56f60df908b8769d32e195d", + "cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg": "44978de1893cdcf9c0c3ed7dd40df3d3f38b7c5334ba0929d2604a2a2fb5d561", + "cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg": "57104d07c82cfb97a72075ef479f7d8d1c00db82386aa5c38da0ef163a82dc2f", + "cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg": "ba96beb1cc54682f56e34b1381fefc9b7b95905363cff917bbfdac886e265bac", + "cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg": "2593b4f81c4fbfd70e73df0710fb143af232126daa0a96bc86c72575713475a5", + "grounding_demo/catalog.py": "75e543fed7f0ca018fb41c4b528efc2901aa6a0f05232959297d6d40798f676f", + "grounding_demo/console.py": "72a8a3557aa2364b3ee40d077c22c72761e41b0e487dbad97e5f1bcada170699", + "grounding_demo/protocol.py": "c08ac104aae96759d5b3958cbb57751c695b8c4dcf55bd7f0fbd847fe34c1459", + "grounding_demo/render.py": "05e9ffadf7ab95d94e57c47dac4fb052c6e207204753bf88246419b7be32c1d1" + }, + "case_contract_sha256": "d00f2091dcb3c866e5e3a331f89537839640b2374c4bc32685960706d18b58b1", + "cases": 27, + "routes": 9 +} diff --git a/docs/ui_paper_r7_lock.json b/docs/ui_paper_r7_lock.json new file mode 100644 index 0000000000000000000000000000000000000000..4fa1499d26ff0c3bbb0ccf70081e5e58ca3a32a9 --- /dev/null +++ b/docs/ui_paper_r7_lock.json @@ -0,0 +1,47 @@ +{ + "files": { + "app.py": "48cce3fc447974dc837d949a064f14e96d99e996689bfdcdca0cdb7a5e62bc2a", + "assets/Manrope-OFL.txt": "e01b637272e0cbdfb240184dd98ea5cc671556d9894dae2668d92ab2c906787c", + "assets/Manrope-variable.ttf": "d0639be45d0af36e798172419d7bd173c4bd4f29e2b76cbb69db1d11bf8b0a40", + "assets/SOURCES.md": "3cceb52136b55f86840e9585e3c37faed1adc762452b0fea50aecba696dac7fa", + "assets/console.js": "dd7cd9c1934ee732830439e14aa5db24a09b8415cd45265b98f894d1e76676bd", + "assets/frosted.css": "393bf5f1c04a49a6e9b17e855e573646489b4add85bc7973eb6bb277686b5c80", + "assets/original.css": "7a244c7f65e40797850dcde7d6b6505b1b5de60aa24b129f44b33ae52291fd2e", + "assets/paper.css": "61fc60bf8c379a0894fbfe06574964ec2ed256791a23860fa4dbb872eb2869f9", + "assets/xpeng-logo.png": "ff0db78ddf8f9a122eec74e8eb79581f8e5dbc46803dddeb780a06f5ae295750", + "cases/dense/dense-01-o365_bbox_gt50_00009110.jpg": "398038106cbac731516dd01de25354fe4d61f3599df64baa611f1d5a99e0e8fb", + "cases/dense/dense-02-o365_bbox_gt50_00004676.jpg": "7ee3beb63bdfd50c183538bd56f9d7e079fa41bde78aad9d5fe0d22c041c2673", + "cases/dense/dense-03-o365_bbox_gt50_00011992.jpg": "eb9331146b66a1af1e8c832a22043c6f1b45d5d3bb7231816f975ced2cd88e39", + "cases/dense_point/dense_point-01-sensenova_sa1b_point_1067906__phrase_000.jpg": "917975c9b31791290a2a660c91af8ae0653cfe258fa0c53539bcb868867aece2", + "cases/dense_point/dense_point-02-sensenova_sa1b_point_1445784__phrase_002.jpg": "0b9a2281fec580c02b9292d8b3f96b675a8659d721f4dd8a1ae16a1eadbaf4e9", + "cases/dense_point/dense_point-03-sensenova_sa1b_point_1451598__phrase_001.jpg": "d2f0e070f49cc001ef6855964175c8c383358fcc2185d62abf29ba0de0d1be22", + "cases/grounding/grounding-01-object365-locate_anything_object365_object365-file-0027-row-000000119924.jpg": "2e3946eafcbdc2d2ac9e0b62343595e0b51e71b38eb15c3b0669fab46c78e9f6", + "cases/grounding/grounding-02-object365-locate_anything_object365_object365-file-0027-row-000001469030.jpg": "c6abef94a28290ca94e8dd043ba58e326cfcb22088b75f32274acc07af15950c", + "cases/grounding/grounding-03-object365-locate_anything_object365_object365-file-0027-row-000001076761.jpg": "ff9581327870a05ad8679c3e5891f27dfe55acc98ed713a8abf8d02e7604774b", + "cases/gui/gui-01-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000043686__gui_0008.jpg": "c9c27a9df49bac1c9664eb74ecf1fe9967e20281add73fff1273437af06b743b", + "cases/gui/gui-02-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000006009__gui_0028.jpg": "7ff12fde621319e2959b3112fa6c1fe4e6ef83b8943a6ee169d7fc2140f59e74", + "cases/gui/gui-03-groundcua-locate_anything_groundcua_groundcua-file-0014-row-000000041853__gui_0052.jpg": "8ba06f95a90cf6954aa7c8f7554b4f28d966afbfc8b8151c96e540e224139cf5", + "cases/layout/layout-01-layout_doclaynet_train_16966.jpg": "8ba09e49907c5d7a3a31148a3fceaf2695bd04f35a017a62ef8c455b985f7218", + "cases/layout/layout-02-layout_doclaynet_train_20356.jpg": "5fbf03f82cc66566e4630547b53b7f51cd0ebd772a072c1d6f37f8c0bafdb646", + "cases/layout/layout-03-layout_doclaynet_train_3435.jpg": "8e035b83d1ca53298816550d4891fd9f2d84f83b59bba178cafdf6bf8623a9fe", + "cases/ocr/ocr-01-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000019189.jpg": "4634583edfab147e8708c6119e726fb8f394744e0225c8319136bb5000ba5d8c", + "cases/ocr/ocr-02-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000018671.jpg": "8db936cadff524299c5b61b94992f3b70ec90e1dd3873f072b34d41692393bdd", + "cases/ocr/ocr-03-ocr_textocr-locate_anything_ocr_textocr_textocr-file-0042-row-000000021130.jpg": "d959da84d676117701e6d3920bff692aab94d6075e5714e2a324df3b61f18cf8", + "cases/refer_point/refer_point-01-roboafford_affordance_point_paco_491580_000.jpg": "e5233bcfadb4d6cb3be1a0ac75573183084494661dd31cc42e7282d21b6c3e13", + "cases/refer_point/refer_point-02-roboafford_affordance_point_paco_558444_002.jpg": "df60dcc4812e93720202874e7b88cca122b25ff2615dd31e2bd697a552bce322", + "cases/refer_point/refer_point-03-roboafford_affordance_point_paco_311488_000.jpg": "e4fc006bbcb49c5e57c3b002a35e5866c15c898d6930117e0f89617121cd3928", + "cases/referring/referring-01-humanref_nocot_lf2_00007963.jpg": "4fac0cc45af121260bc7468aa63fbe7f6dfdcbc5a2f251c04a8a0e06212048df", + "cases/referring/referring-02-humanref_nocot_lf2_00004121.jpg": "9b7ec8dc3ad013a57fab9d1199ee0ce14a3104f8e56f60df908b8769d32e195d", + "cases/referring/referring-03-humanref_nocot_lf2_00011458.jpg": "44978de1893cdcf9c0c3ed7dd40df3d3f38b7c5334ba0929d2604a2a2fb5d561", + "cases/visual_prompt/visual_prompt-01-sensenova_sa1b_visual_1718306.jpg": "57104d07c82cfb97a72075ef479f7d8d1c00db82386aa5c38da0ef163a82dc2f", + "cases/visual_prompt/visual_prompt-02-sensenova_sa1b_visual_2475968.jpg": "ba96beb1cc54682f56e34b1381fefc9b7b95905363cff917bbfdac886e265bac", + "cases/visual_prompt/visual_prompt-03-sensenova_sa1b_visual_1573415.jpg": "2593b4f81c4fbfd70e73df0710fb143af232126daa0a96bc86c72575713475a5", + "grounding_demo/catalog.py": "75e543fed7f0ca018fb41c4b528efc2901aa6a0f05232959297d6d40798f676f", + "grounding_demo/console.py": "dbc1a08c937f18d5c104d4ab18316937d21a2b0d2df9ba2cba296d9ae1e20f16", + "grounding_demo/protocol.py": "aa4e634070ab7a17c6bc477051e97cb02e772e9e37db89d5de9b6497312635b0", + "grounding_demo/render.py": "189e0dcb6ea4493c1ef2f930cabdf62362ba48b261c0df24f94898e7e9166ec5" + }, + "case_contract_sha256": "d00f2091dcb3c866e5e3a331f89537839640b2374c4bc32685960706d18b58b1", + "cases": 27, + "routes": 9 +} diff --git a/grounding_demo/__init__.py b/grounding_demo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..687f9d4dd796ce99901345a752a772ec4cfab583 --- /dev/null +++ b/grounding_demo/__init__.py @@ -0,0 +1,4 @@ +"""GroundingPI paper demo runtime.""" + +__all__ = ["__version__"] +__version__ = "0.1.0" diff --git a/grounding_demo/catalog.py b/grounding_demo/catalog.py new file mode 100644 index 0000000000000000000000000000000000000000..acbf8a76e119a91966b884853bb2e73a954fdbb7 --- /dev/null +++ b/grounding_demo/catalog.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +import json +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def load_cases(path: Path | None = None) -> list[dict]: + case_path = path or ROOT / "data" / "cases.json" + rows = json.loads(case_path.read_text(encoding="utf-8")) + required = {"id", "route", "title", "prompt", "expected", "image", "source"} + ids: set[str] = set() + for row in rows: + missing = required - row.keys() + if missing: + raise ValueError(f"case {row.get('id')} missing fields: {sorted(missing)}") + if row["id"] in ids: + raise ValueError(f"duplicate case id: {row['id']}") + ids.add(row["id"]) + image = ROOT / row["image"] + if not image.is_file(): + raise FileNotFoundError(image) + return rows diff --git a/grounding_demo/client.py b/grounding_demo/client.py new file mode 100644 index 0000000000000000000000000000000000000000..0af5d975167e532964cb613a02d978bf1462db67 --- /dev/null +++ b/grounding_demo/client.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +import base64 +import mimetypes +import os +import time +from pathlib import Path + +import httpx + + +ZEROGPU_NOT_CONFIGURED = ( + "ZeroGPU inference is not configured. You can explore examples, but live predictions are unavailable. " + "Set GROUNDING_MODEL_REPO and GROUNDING_MODEL_REVISION in the Space settings." +) + + +def zerogpu_configured() -> bool: + return bool(os.getenv("GROUNDING_MODEL_REPO", "").strip() or + os.getenv("GROUNDING_MODEL_PATH", "").strip()) + + +def _data_uri(image_path: str | Path) -> str: + path = Path(image_path) + mime = mimetypes.guess_type(path.name)[0] or "image/jpeg" + return f"data:{mime};base64,{base64.b64encode(path.read_bytes()).decode('ascii')}" + + +class GroundingClient: + def __init__(self) -> None: + self.backend = os.getenv("GROUNDING_BACKEND", "http").strip().lower() + if self.backend not in {"http", "zerogpu"}: + raise ValueError("GROUNDING_BACKEND must be http or zerogpu") + self.api_base = os.getenv("GROUNDING_API_BASE", "http://127.0.0.1:8000/v1").rstrip("/") + self.model = os.getenv("GROUNDING_MODEL", "grounding-pi-vlm") + self.api_key = os.getenv("GROUNDING_API_KEY", "EMPTY") + self.timeout = float(os.getenv("GROUNDING_TIMEOUT", "180")) + + def health(self) -> tuple[bool, str]: + if self.backend == "zerogpu": + if not zerogpu_configured(): + return False, ZEROGPU_NOT_CONFIGURED + from . import zerogpu_backend + + return zerogpu_backend.health() + try: + response = httpx.get( + f"{self.api_base}/models", + headers={"Authorization": f"Bearer {self.api_key}"}, + timeout=5, + ) + response.raise_for_status() + model_ids = [item.get("id") for item in response.json().get("data", [])] + return self.model in model_ids, f"models={model_ids}" + except Exception as exc: # user-facing service health + return False, f"{type(exc).__name__}: {exc}" + + def infer(self, image_path: str | Path, prompt: str) -> tuple[str, float, dict]: + if self.backend == "zerogpu": + if not zerogpu_configured(): + raise RuntimeError(ZEROGPU_NOT_CONFIGURED) + from . import zerogpu_backend + + return zerogpu_backend.infer(image_path, prompt) + payload = { + "model": self.model, + "messages": [ + { + "role": "user", + "content": [ + { + "type": "image_url", + "image_url": {"url": _data_uri(image_path)}, + }, + {"type": "text", "text": prompt.replace("", "").strip()}, + ], + } + ], + "temperature": 0.0, + "top_p": 1.0, + "max_tokens": int(os.getenv("GROUNDING_MAX_TOKENS", "1024")), + "seed": 42, + "skip_special_tokens": False, + "spaces_between_special_tokens": False, + } + started = time.perf_counter() + response = httpx.post( + f"{self.api_base}/chat/completions", + headers={"Authorization": f"Bearer {self.api_key}"}, + json=payload, + timeout=self.timeout, + ) + elapsed = time.perf_counter() - started + response.raise_for_status() + body = response.json() + text = body["choices"][0]["message"]["content"] + return text, elapsed, body.get("usage", {}) diff --git a/grounding_demo/console.py b/grounding_demo/console.py new file mode 100644 index 0000000000000000000000000000000000000000..38cc094f616ba70ea6723cee6139404a07ec5415 --- /dev/null +++ b/grounding_demo/console.py @@ -0,0 +1,158 @@ +"""Presentation helpers; expected answers never enter model requests.""" + +from __future__ import annotations + +import html +import json +from collections import Counter + +from .render import PALETTE + +PREFIXES = { + "grounding": "Locate all the instances that match the following categories: ", + "dense": "Locate all the instances that match the following categories: ", + "referring": "Locate the target referred to by the following description: ", + "dense_point": "Point to: ", + "refer_point": "Point to the target referred to by the following description: ", + "layout": "Detect all document layout elements that match the following categories: ", + "gui": "Point to the UI element to click for the following instruction: ", +} +CATEGORY_ROUTES = {"grounding", "dense", "layout"} + +# Presentation only: never alter the released model prompt or expected answer. +TASK_HELP = { + "grounding": [ + "Open-Vocabulary Grounding", + "Localize visual instances from category names, with spatial evidence for each prediction.", + "Separate categories with commas. Select a result to inspect its original pixels.", + "car, person" + ], + "dense": [ + "Dense Instance Grounding", + "Resolve multiple instances in crowded scenes, from small objects to partially occluded targets.", + "Enter object categories. Inspect overlapping predictions one instance at a time.", + "person, chair" + ], + "referring": [ + "Language-Guided Referring", + "Connect a natural-language description to the object it identifies.", + "Describe appearance, position, or relationships in a complete phrase.", + "The person standing beside the table" + ], + "dense_point": [ + "Dense Point Localization", + "Represent multiple visual targets as spatial points.", + "Describe the targets to locate. Points indicate positions, not object boundaries.", + "All visible people" + ], + "refer_point": [ + "Relational & Affordance Pointing", + "Ground relational descriptions and actionable object parts in image coordinates.", + "Describe an object, relationship, or interaction region. This demo predicts locations only.", + "The handle of the cup" + ], + "visual_prompt": [ + "Exemplar-Guided Grounding", + "Use spatial examples to identify visually related instances.", + "Green INPUT boxes come from your prompt, not model predictions. Coordinates use the 0–999 range.", + "Given reference boxes <|box_start|><100><100><200><200><|box_end|> ..." + ], + "ocr": [ + "Text as Spatial Evidence", + "Read visible text and associate each transcription with its image region.", + "Use an OCR instruction. Select a transcription to inspect the original pixels.", + "Read and locate the text in the image" + ], + "layout": [ + "Document Layout Understanding", + "Map document structure into localized semantic regions.", + "Separate region categories with commas. Regions do not imply a predicted reading order.", + "Title, Text, Table" + ], + "gui": [ + "Interface Grounding", + "Translate an interaction instruction into a precise interface location.", + "Describe the element to select. The demo predicts a point; it does not execute clicks.", + "Click the search button" + ] +} + + +def task_help_html(route): + title, description, hint, _ = TASK_HELP[route] + return ( + "
" + f"{html.escape(title)}

{html.escape(description)}

" + f"{html.escape(hint)}
" + ) + + +def query_from_prompt(prompt: str, route: str) -> str: + text = prompt.removeprefix("").strip() + prefix = PREFIXES.get(route, "") + if prefix and text.startswith(prefix): + text = text[len(prefix) :].removesuffix(".") + if route in CATEGORY_ROUTES: + text = text.replace("", ", ") + return text + + +def compile_query(query: str, route: str) -> str: + text = query.strip() + if route in CATEGORY_ROUTES: + text = "".join( + part.strip() for part in text.replace(",", ",").split(",") if part.strip() + ) + prefix = PREFIXES.get(route, "") + return "\n" + prefix + text + ("." if prefix else "") + + +def metrics_html(route, state="Ready", count=0, elapsed=None, usage=None): + rows = [ + ("Status", state), + ("Task", route), + ("Model", "grounding-pi-vlm"), + ("Detections", str(count)), + ("Latency", f"{elapsed:.2f} s" if elapsed is not None else "—"), + ("Output tokens", str((usage or {}).get("completion_tokens", "—"))), + ] + return ( + "
" + + "".join(f"
{html.escape(k)}
{html.escape(v)}
" for k, v in rows) + + "
" + ) + + +def targets_html(items, pending=False, image_source=""): + if not items: + title = "Awaiting visual evidence" if pending else "Explore a visual target" + hint = ( + "Your image stays visible while the model processes the request." + if pending + else "Choose an example, run grounding, then select a category to inspect." + ) + return ( + "
" + f"{title}{hint}
" + ) + counts = Counter(item["label"] for item in items) + chips = "".join( + "" + for idx, (label, count) in enumerate(counts.items()) + ) + caption = "Live model predictions · select a target or category to inspect" + return ( + (f"" if image_source else "") + + f"
{len(items)} {'target' if len(items) == 1 else 'targets'} {len(counts)} {'category' if len(counts) == 1 else 'categories'}
" + f"
{chips}
" + "
Inspect individual instances" + "
" + f"
{caption}
" + ) diff --git a/grounding_demo/native_runtime.py b/grounding_demo/native_runtime.py new file mode 100644 index 0000000000000000000000000000000000000000..66c30ceffff07961af1cf2e28c9f126bae4431f9 --- /dev/null +++ b/grounding_demo/native_runtime.py @@ -0,0 +1,185 @@ +"""Checkpoint-native inference. No case catalog, references, or HTTP fallback here. + +This module deliberately avoids importing torch at import time: spaces must install +its CUDA hooks first. The GPU boundary lives in zerogpu_backend, not in this module. +""" +from __future__ import annotations + +import hashlib +import json +import os +import re +from pathlib import Path + + +class ConfigurationError(RuntimeError): + pass + + +class IncompleteGeneration(RuntimeError): + pass + + +def resolve_snapshot() -> Path: + local = os.getenv("GROUNDING_MODEL_PATH", "").strip() + repo = os.getenv("GROUNDING_MODEL_REPO", "").strip() + if local and repo: + raise ConfigurationError("Configure either GROUNDING_MODEL_PATH or GROUNDING_MODEL_REPO, not both.") + if local: + return Path(local).expanduser().resolve(strict=True) + if not repo: + raise ConfigurationError("Configure GROUNDING_MODEL_REPO and GROUNDING_MODEL_REVISION first.") + revision = os.getenv("GROUNDING_MODEL_REVISION", "").strip() + if not re.fullmatch(r"[0-9a-fA-F]{40}", revision): + raise ConfigurationError("GROUNDING_MODEL_REVISION must be the full 40-character commit SHA of reviewed model code.") + from huggingface_hub import snapshot_download + + # The custom processor uses local open(). Download a pinned snapshot first; + # passing a Hub repo ID directly to this processor does not work. + return Path(snapshot_download( + repo_id=repo, revision=revision, token=os.getenv("HF_TOKEN") or None, + allow_patterns=["*.json", "*.py", "*.jinja", "*.txt", "*.safetensors"], + )) + + +def inspect_contract(root: Path, *, require_weights: bool = True) -> dict: + """Check the custom Kimi-K3-ViT package without importing its executable code.""" + required = [ + "config.json", "preprocessor_config.json", "generation_config.json", + "tokenizer.json", "tokenizer_config.json", "chat_template.jinja", + "configuration_oxygen_vl_v3.py", + "modeling_oxygen_vl_v3.py", "modeling_kimi_k3.py", + "processing_oxygen_vl_v3.py", "kimi_k3_vision_processing.py", "media_utils.py", + ] + missing = [name for name in required if not (root / name).is_file()] + if missing: + raise ConfigurationError(f"Model package is missing files: {', '.join(missing)}") + config = json.loads((root / "config.json").read_text()) + if config.get("model_type") != "oxygen_vl_v3": + raise ConfigurationError("This runtime requires the custom Oxygen-VL-v3 model, not standard Qwen3-VL weights.") + if config.get("vision_config", {}).get("model_type") != "oxygen_k3_vision": + raise ConfigurationError("The model does not use the expected Kimi-K3 ViT.") + if not config.get("auto_map", {}).get("AutoModelForImageTextToText"): + raise ConfigurationError("The model is missing the AutoModelForImageTextToText mapping.") + if not config.get("auto_map", {}).get("AutoProcessor"): + raise ConfigurationError("The model is missing its custom AutoProcessor mapping.") + tokenizer = json.loads((root / "tokenizer.json").read_text()) + vocab = dict(tokenizer.get("model", {}).get("vocab", {})) + vocab.update({item["content"]: item["id"] for item in tokenizer.get("added_tokens", [])}) + gam_tokens = [f"<{n}>" for n in range(1000)] + [ + "<|box_start|>", "<|box_end|>", "<|object_ref_start|>", "<|object_ref_end|>", + ] + if any(token not in vocab for token in gam_tokens): + raise ConfigurationError("The tokenizer is missing native GAM coordinate or grounding tokens.") + if vocab.get("<|image_pad|>") != config.get("image_token_id"): + raise ConfigurationError("The image token ID does not match the model configuration.") + generation = json.loads((root / "generation_config.json").read_text()) + eos = generation.get("eos_token_id") + eos = eos if isinstance(eos, list) else [eos] + if not eos or any(not isinstance(token, int) for token in eos): + raise ConfigurationError("generation_config has no valid end-of-sequence token.") + shards = [] + if require_weights: + index = root / "model.safetensors.index.json" + if index.is_file(): + shards = sorted(set(json.loads(index.read_text())["weight_map"].values())) + elif (root / "model.safetensors").is_file(): + shards = ["model.safetensors"] + if not shards or any( + Path(name).name != name or not name.endswith(".safetensors") + or not (root / name).is_file() or (root / name).stat().st_size == 0 + for name in shards + ): + raise ConfigurationError("Model weight shards are incomplete. Upload the weights as well as the tokenizer and configuration.") + prep = json.loads((root / "preprocessor_config.json").read_text()) + return { + "architecture": config["architectures"], "vision": "oxygen_k3_vision", + "config_sha256": hashlib.sha256((root / "config.json").read_bytes()).hexdigest(), + "processor_sha256": hashlib.sha256((root / "preprocessor_config.json").read_bytes()).hexdigest(), + "media_proc_cfg": prep.get("media_proc_cfg"), "gam_coordinate_tokens": 1000, + "eos_token_ids": eos, "weight_shards": shards, + "scope": "package_contract_only_not_gpu_inference", + } + + +def user_messages(prompt: str) -> list[dict]: + text = prompt.replace("", "").strip() + # Exactly one image. Do not let text inject another image placeholder or role. + forbidden = ["<|image_pad|>", "<|video_pad|>", "<|image_placeholder|>", + "<|vision_start|>", "<|vision_end|>", "<|im_start|>", "<|im_end|>"] + if not text or any(token in text for token in forbidden): + raise ValueError("The prompt is empty or contains reserved image/conversation control tokens.") + return [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": text}]}] + + +def decode_answer(processor, generated_ids: list[int], eos_ids: list[int], limit: int) -> str: + # Keep GAM coordinate tokens. skip_special_tokens=True would erase evidence. + if not generated_ids: + raise IncompleteGeneration("The model returned no answer.") + if generated_ids[-1] not in eos_ids: + raise IncompleteGeneration( + f"Generation did not reach EOS ({len(generated_ids)}/{limit} tokens). Truncated output is not accepted as a valid result." + ) + ids = list(generated_ids) + while ids and ids[-1] in eos_ids: + ids.pop() + text = processor.decode(ids, skip_special_tokens=False, spaces_between_special_tokens=False) + if not text.strip(): + raise IncompleteGeneration("The model returned EOS without a grounding result.") + return text + + +class NativeRuntime: + def __init__(self, model, processor, eos_ids: list[int]): + self.model, self.processor, self.eos_ids = model, processor, eos_ids + + @classmethod + def load(cls, root: Path) -> "NativeRuntime": + contract = inspect_contract(root) + import torch + from transformers import AutoModelForImageTextToText, AutoProcessor + + processor = AutoProcessor.from_pretrained(str(root), trust_remote_code=True) + model = AutoModelForImageTextToText.from_pretrained( + str(root), trust_remote_code=True, dtype=torch.bfloat16, + attn_implementation="sdpa", + ).eval().to("cuda") + return cls(model, processor, contract["eos_token_ids"]) + + def prepare(self, image_path: str | Path, prompt: str, limit: int): + from PIL import Image + + path = Path(image_path) + if path.stat().st_size > 30 * 1024 * 1024: + raise ValueError("Image exceeds 30 MiB. Reduce the file size and retry.") + if not 1 <= limit <= 2048: + raise ConfigurationError("GROUNDING_MAX_TOKENS must be between 1 and 2048.") + with Image.open(path) as source: + if source.width * source.height > 50_000_000: + raise ValueError("Image exceeds 50 megapixels. Reduce its dimensions and retry.") + # Preserve RGBA: the checkpoint applies its own alpha background policy. + image = source.copy() + rendered = self.processor.apply_chat_template( + user_messages(prompt), tokenize=False, add_generation_prompt=True, + ) + inputs = self.processor(text=[rendered], images=[image], return_tensors="pt") + prompt_tokens = int(inputs["input_ids"].shape[-1]) + if prompt_tokens + limit > 8192: + raise ValueError("Image and prompt exceed the 8192-token context budget. Shorten the prompt; inputs will not be silently truncated.") + if "pixel_values" not in inputs or "image_grid_thw" not in inputs: + raise ConfigurationError("The processor returned no image pixels or grid. Inference has been stopped.") + return inputs, prompt_tokens + + def generate_ids(self, inputs, limit: int) -> list[int]: + """Must run inside @spaces.GPU on ZeroGPU. No loading or HTTP here.""" + import torch + + device_inputs = {key: value.to("cuda") for key, value in inputs.items()} + with torch.inference_mode(): + output = self.model.generate( + **device_inputs, max_new_tokens=limit, do_sample=False, + use_cache=True, eos_token_id=self.eos_ids, + ) + start = inputs["input_ids"].shape[-1] + # No GPU tensor escapes the temporary GPU lease. + return output[0, start:].detach().cpu().tolist() diff --git a/grounding_demo/protocol.py b/grounding_demo/protocol.py new file mode 100644 index 0000000000000000000000000000000000000000..6f2ae2164c430c7830c30b450bd1cf829ebeded6 --- /dev/null +++ b/grounding_demo/protocol.py @@ -0,0 +1,87 @@ +from __future__ import annotations + +import re +from dataclasses import dataclass + +OBJECT_RE = re.compile( + r"<\|object_ref_start\|>(.*?)<\|object_ref_end\|>" + r"<\|box_start\|>(.*?)<\|box_end\|>", + re.DOTALL, +) +COORD_RE = re.compile(r"<([0-9]{1,3})>") +POINT_ROUTES = {"dense_point", "refer_point", "gui"} + + +@dataclass(frozen=True) +class Primitive: + label: str + coordinates: tuple[int, ...] + + +@dataclass(frozen=True) +class ParseResult: + primitives: tuple[Primitive, ...] + errors: tuple[str, ...] + + @property + def valid(self) -> bool: + return bool(self.primitives) and not self.errors + + +def parse_gam(text: str, route: str) -> ParseResult: + """Strictly parse canonical GAM special-token output. + + Reasoning before the first object block is ignored, but every detected + object block and every coordinate must satisfy the released GAM contract. + """ + + arity = 2 if route in POINT_ROUTES else 4 + primitives: list[Primitive] = [] + errors: list[str] = [] + matches = list(OBJECT_RE.finditer(text or "")) + if not matches: + return ParseResult((), ("Canonical GAM object/box wrapper not found",)) + + for block_index, match in enumerate(matches, start=1): + label = match.group(1).strip() + payload = match.group(2).strip() + if not label: + errors.append(f"Object {block_index} has an empty label") + tuples = [item.strip() for item in payload.split(",") if item.strip()] + if not tuples: + errors.append(f"Object {block_index} has no coordinates") + continue + for tuple_index, item in enumerate(tuples, start=1): + values = tuple(int(v) for v in COORD_RE.findall(item)) + rebuilt = "".join(f"<{v}>" for v in values) + if rebuilt != item: + errors.append(f"Coordinate {block_index}.{tuple_index} contains non-canonical content") + continue + if len(values) != arity: + errors.append( + f"Coordinate {block_index}.{tuple_index} has arity={len(values)}, expected {arity}" + ) + continue + if any(v < 0 or v > 999 for v in values): + errors.append(f"Coordinate {block_index}.{tuple_index} is outside 0..999") + continue + if arity == 4 and (values[0] >= values[2] or values[1] >= values[3]): + errors.append(f"Box {block_index}.{tuple_index} is degenerate or inverted") + continue + primitives.append(Primitive(label=label, coordinates=values)) + + return ParseResult(tuple(primitives), tuple(errors)) + + +def parse_reference_boxes(prompt: str) -> tuple[Primitive, ...]: + if "Given reference boxes" not in prompt: + return () + match = re.search(r"<\|box_start\|>(.*?)<\|box_end\|>", prompt, re.DOTALL) + if not match: + return () + result: list[Primitive] = [] + for item in match.group(1).split(","): + values = tuple(int(v) for v in COORD_RE.findall(item)) + if len(values) == 4 and values[0] < values[2] and values[1] < values[3]: + result.append(Primitive("reference", values)) + return tuple(result) diff --git a/grounding_demo/render.py b/grounding_demo/render.py new file mode 100644 index 0000000000000000000000000000000000000000..cab9637a551a89929b9265c183cf5ab0b7605d61 --- /dev/null +++ b/grounding_demo/render.py @@ -0,0 +1,138 @@ +from __future__ import annotations + +from collections import defaultdict +from collections.abc import Iterable +from pathlib import Path + +from PIL import Image, ImageDraw, ImageFont + +from .protocol import Primitive + +PURPLE = (120, 78, 188) +GREEN = (145, 195, 49) +PINK = (214, 120, 172) +CYAN = (55, 171, 183) +PALETTE = (PURPLE, GREEN, PINK, CYAN) + + +def _font(size: int) -> ImageFont.FreeTypeFont | ImageFont.ImageFont: + candidates = ( + str(Path(__file__).resolve().parents[1] / "assets/Manrope-variable.ttf"), + "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", + "/usr/share/fonts/truetype/liberation2/LiberationSans-Regular.ttf", + ) + for candidate in candidates: + if Path(candidate).is_file(): + return ImageFont.truetype(candidate, size=size) + return ImageFont.load_default() + + +def _xy(values: tuple[int, ...], width: int, height: int) -> tuple[int, ...]: + if len(values) == 2: + return round(values[0] * (width - 1) / 999), round(values[1] * (height - 1) / 999) + return ( + round(values[0] * (width - 1) / 999), + round(values[1] * (height - 1) / 999), + round(values[2] * (width - 1) / 999), + round(values[3] * (height - 1) / 999), + ) + + +def draw_primitives( + image: Image.Image, + primitives: Iterable[Primitive], + references: Iterable[Primitive] = (), + title: str | None = None, +) -> Image.Image: + canvas = image.convert("RGBA") + overlay = Image.new("RGBA", canvas.size, (0, 0, 0, 0)) + draw = ImageDraw.Draw(overlay) + width, height = canvas.size + line = max(2, round(min(width, height) / 260)) + radius = max(6, line * 3) + font = _font(max(13, round(min(width, height) / 42))) + label_colors: dict[str, tuple[int, int, int]] = {} + seen: defaultdict[str, int] = defaultdict(int) + + for ref in references: + if len(ref.coordinates) != 4: + continue + box = _xy(ref.coordinates, width, height) + draw.rectangle(box, outline=(*GREEN, 255), width=line * 2) + x1, y1, x2, y2 = box + dash = max(5, line * 3) + for x in range(x1, x2, dash * 2): + draw.line((x, y1, min(x + dash, x2), y1), fill=(*GREEN, 255), width=line) + draw.line((x, y2, min(x + dash, x2), y2), fill=(*GREEN, 255), width=line) + + primitives = list(primitives) + labels = [] + # Opaque RGBA writes replace earlier pixels in a Pillow layer. In particular, + # a later lake/cloud fill used to erase every small object drawn inside it. + # Keep region interiors untouched; geometry and labels are separate passes. + for primitive in primitives: + color = label_colors.setdefault(primitive.label, PALETTE[len(label_colors) % len(PALETTE)]) + seen[primitive.label] += 1 + coords = _xy(primitive.coordinates, width, height) + if len(coords) == 2: + x, y = coords + draw.ellipse( + (x - radius, y - radius, x + radius, y + radius), + outline=(*color, 255), + width=line, + ) + draw.line((x - radius * 2, y, x + radius * 2, y), fill=(*color, 255), width=line) + draw.line((x, y - radius * 2, x, y + radius * 2), fill=(*color, 255), width=line) + else: + x1, y1, x2, y2 = coords + draw.rectangle(coords, outline=(*color, 255), width=line) + if seen[primitive.label] == 1: + labels.append((primitive.label, color, coords)) + + # Dense scenes use the linked category inspector instead of a wall of text. + # Sparse labels are clamped to the canvas and never overlap one another or + # cover a small target. Exact predictions are never suppressed or merged. + occupied = [] + small_targets = [_xy(p.coordinates, width, height) for p in primitives + if len(p.coordinates) == 4 + and (p.coordinates[2] - p.coordinates[0]) * + (p.coordinates[3] - p.coordinates[1]) < 10000] + + def intersects(a, b): + return a[0] < b[2] and b[0] < a[2] and a[1] < b[3] and b[1] < a[3] + + for text, color, (x1, y1, x2, y2) in labels if len(labels) <= 12 else []: + text = text[:38] + tb = draw.textbbox((0, 0), text, font=font) + while tb[2] - tb[0] + line * 4 > width - 2 and text: + text = text[:-1] + tb = draw.textbbox((0, 0), text + "…", font=font) + if not text: + continue + tw, th = tb[2] - tb[0] + line * 4, tb[3] - tb[1] + line * 2 + candidates = [(x1, y1-th-line), (x1, y2+line), + (x2-tw, y1-th-line), (x1+line, y1+line)] + for tx, ty in candidates: + tx, ty = max(0, min(tx, width-tw-1)), max(0, min(ty, height-th-1)) + box = (tx, ty, tx+tw, ty+th) + if any(intersects(box, other) for other in occupied + small_targets): + continue + occupied.append(box) + light = tuple(round(c * .15 + 255 * .85) for c in color) + draw.rounded_rectangle(box, radius=line*2, fill=(*light, 250), + outline=(*color, 255), width=max(1, line//2)) + draw.text((tx+line*2-tb[0], ty+line-tb[1]), text, font=font, + fill=(47, 31, 65, 255)) + break + + if title: + tb = draw.textbbox((0, 0), title, font=font) + draw.rounded_rectangle( + (10, 10, min(width - 10, tb[2] + 28), tb[3] + 24), + radius=10, + fill=(255, 255, 255, 225), + outline=(*PURPLE, 255), + width=line, + ) + draw.text((18, 16), title, font=font, fill=(*PURPLE, 255)) + return Image.alpha_composite(canvas, overlay).convert("RGB") diff --git a/grounding_demo/zerogpu_backend.py b/grounding_demo/zerogpu_backend.py new file mode 100644 index 0000000000000000000000000000000000000000..04db0924ba5256e243f3337c55cee942a1c9adab --- /dev/null +++ b/grounding_demo/zerogpu_backend.py @@ -0,0 +1,61 @@ +"""ZeroGPU startup placement and GPU lease; imported before the Gradio app.""" +import spaces # MUST precede torch/transformers imports and model placement. + +import os +import time + +from .native_runtime import ConfigurationError, NativeRuntime, decode_answer, resolve_snapshot + + +RUNTIME = None +STARTUP_ERROR = None +try: + # Root-level placement lets ZeroGPU capture and reuse the CUDA model state. + # No lazy model loads inside the leased GPU function. + RUNTIME = NativeRuntime.load(resolve_snapshot()) +except Exception as exc: + # Keep the original page available with a truthful offline state. + STARTUP_ERROR = str(exc) if isinstance(exc, ConfigurationError) else ( + f"Model initialization failed ({type(exc).__name__}). Check the Space logs and model package." + ) + if not isinstance(exc, ConfigurationError): + import traceback + traceback.print_exc() + +GPU_SECONDS = int(os.getenv("GROUNDING_GPU_SECONDS", "120")) +if not 1 <= GPU_SECONDS <= 120: + raise ConfigurationError("GROUNDING_GPU_SECONDS must be between 1 and 120.") + + +@spaces.GPU(duration=GPU_SECONDS) +def generate_on_gpu(inputs, limit: int): + started = time.perf_counter() + if RUNTIME is None: + raise RuntimeError(STARTUP_ERROR or "The model is not loaded.") + token_ids = RUNTIME.generate_ids(inputs, limit) + return token_ids, time.perf_counter() - started + + +def health() -> tuple[bool, str]: + if RUNTIME is None: + return False, STARTUP_ERROR or "The model is not loaded." + if os.getenv("GROUNDING_RUNTIME_LABEL") == "fuyao-ppu-native": + return True, "Fuyao PPU · Native Transformers model loaded. Space-compatible code; HF GPU allocation is not validated here." + return True, "Model initialized. ZeroGPU allocation and quota are checked when inference starts." + + +def infer(image_path, prompt): + if RUNTIME is None: + raise RuntimeError(STARTUP_ERROR or "The model is not loaded.") + started = time.perf_counter() + limit = int(os.getenv("GROUNDING_MAX_TOKENS", "1024")) + inputs, prompt_tokens = RUNTIME.prepare(image_path, prompt, limit) + # Quota/queue/OOM errors propagate into the existing page's error state. + # There is deliberately no retry against an API, no stored-answer fallback. + ids, gpu_elapsed = generate_on_gpu(inputs, limit) + text = decode_answer(RUNTIME.processor, ids, RUNTIME.eos_ids, limit) + return text, time.perf_counter() - started, { + "prompt_tokens": prompt_tokens, "completion_tokens": len(ids), + "total_tokens": prompt_tokens + len(ids), "gpu_elapsed_seconds": gpu_elapsed, + "backend": os.getenv("GROUNDING_RUNTIME_LABEL", "zerogpu"), "finish_reason": "stop", + } diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..b979ef7c9dbed95254065277ca9a6ae9575fb8ab --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +-c constraints-app.txt +gradio==5.49.1 +httpx==0.28.1 +Pillow==11.3.0 +torch==2.10.0 +torchvision==0.25.0 +transformers==5.3.0 +huggingface-hub==1.4.1 +safetensors==0.6.2 +spaces==0.51.3 +numpy==1.26.0 diff --git a/scripts/build_bundle.py b/scripts/build_bundle.py new file mode 100644 index 0000000000000000000000000000000000000000..694e516751b994fc26012b1ec1d3e034caf51e92 --- /dev/null +++ b/scripts/build_bundle.py @@ -0,0 +1,58 @@ +"""Build an explicit allowlist archive; never upload it or include weights/secrets.""" +import argparse +import hashlib +import json +from pathlib import Path +from zipfile import ZIP_DEFLATED, ZipFile + +from verify_ui import fingerprint + +ROOT = Path(__file__).resolve().parents[1] + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("output", type=Path) + args = parser.parse_args() + if args.output.exists(): + raise SystemExit("Output already exists; choose a new archive path.") + args.output.parent.mkdir(parents=True, exist_ok=True) + lock = ROOT / "docs/ui_paper_r7_lock.json" + if not lock.exists(): + lock = ROOT / "docs/ui_lock.json" + if fingerprint(ROOT) != json.loads(lock.read_text()): + raise ValueError("Original UI/assets/case contract changed; inspect before packaging.") + rows = json.loads((ROOT / "data/cases.json").read_text()) + case_keys = {"id", "route", "route_title", "title", "prompt", "expected", "image", + "source", "image_sha256", "difficulty", "validation"} + public_rows = [{k: v for k, v in row.items() if k in case_keys} for row in rows] + top = ["app.py", "space_app.py", "README.md", "LICENSE_PENDING.md", "requirements.txt", "constraints-app.txt", ".gitignore", ".env.example", + "docs/ui_lock.json", "docs/HF_SPACE_DEPLOYMENT.md", "docs/ZEROGPU_DEPLOYMENT.md", + "docs/VERIFICATION.md", "scripts/start.sh", "scripts/verify_ui.py", + "scripts/preflight_model.py", "scripts/smoke_structure.py", "scripts/build_bundle.py", + "scripts/prepare_model_repo.py", "scripts/validate_gradio.py"] + paths = [ROOT / name for name in top] + paths.extend([lock, ROOT / "docs/UI_PAPER_R7.md"]) + for folder, suffixes in {"assets": {".css", ".js", ".png", ".ttf", ".txt", ".md"}, + "grounding_demo": {".py"}, "tests": {".py"}}.items(): + paths.extend(p for p in (ROOT / folder).rglob("*") if p.is_file() and p.suffix in suffixes) + for row, public_row in zip(rows, public_rows, strict=True): + path = (ROOT / row["image"]).resolve(strict=True) + if not path.is_relative_to((ROOT / "cases").resolve()): + raise ValueError("Case image escapes cases directory") + # Legacy image_sha256 hashes SOURCE bytes, before the original demo's + # JPEG re-encoding. Preserve that field and add a separate artifact hash. + public_row["artifact_image_sha256"] = hashlib.sha256(path.read_bytes()).hexdigest() + paths.append(path) + with ZipFile(args.output, "x", ZIP_DEFLATED) as archive: + for path in sorted(set(paths)): + if path.is_symlink() or not path.resolve().is_relative_to(ROOT.resolve()): + raise ValueError(f"Unexpected source path: {path.name}") + archive.write(path, path.relative_to(ROOT)) + archive.writestr("data/cases.json", json.dumps(public_rows, ensure_ascii=False, indent=2) + "\n") + print(json.dumps({"archive": str(args.output), "case_count": len(rows), + "sha256": hashlib.sha256(args.output.read_bytes()).hexdigest()}, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/scripts/preflight_model.py b/scripts/preflight_model.py new file mode 100644 index 0000000000000000000000000000000000000000..15ba405b404d1747b9f5a5579afe074bc3ceb4dd --- /dev/null +++ b/scripts/preflight_model.py @@ -0,0 +1,50 @@ +"""Read-only model package and optional native-processor checks. Never GPU inference.""" +import argparse +import json +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +from grounding_demo.native_runtime import NativeRuntime, inspect_contract + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("model_path", type=Path) + parser.add_argument("--metadata-only", action="store_true", help="Do not require weight shards") + parser.add_argument("--processor", action="store_true", help="Execute reviewed custom processor on all 27 cases (CPU)") + parser.add_argument("--report", type=Path, help="Write a new JSON report (refuse overwrite)") + args = parser.parse_args() + report = inspect_contract(args.model_path.resolve(), require_weights=not args.metadata_only) + if args.processor: + from transformers import AutoProcessor + from grounding_demo.catalog import load_cases + + processor = AutoProcessor.from_pretrained(str(args.model_path.resolve()), trust_remote_code=True) + runtime = NativeRuntime(None, processor, report["eos_token_ids"]) + report["cases"] = [] + for row in load_cases(): + inputs, count = runtime.prepare(ROOT / row["image"], row["prompt"], 1024) + image_tokens = int((inputs["input_ids"] == processor.image_token_id).sum()) + grid_tokens = int(inputs["image_grid_thw"].prod()) // processor.image_processor.merge_size ** 2 + expected_ids = processor.tokenizer.encode(row["expected"], add_special_tokens=False) + roundtrip = processor.decode(expected_ids, skip_special_tokens=False, + spaces_between_special_tokens=False) == row["expected"] + if image_tokens != grid_tokens or not roundtrip: + raise RuntimeError(f"Processor/tokenizer contract failed: {row['id']}") + report["cases"].append({ + "id": row["id"], "route": row["route"], "prompt_tokens": count, + "image_tokens": image_tokens, "reference_tokens": len(expected_ids), + "reference_roundtrip": roundtrip, + }) + report["scope"] = "native_processor_cpu_only_not_model_accuracy_or_gpu_inference" + rendered = json.dumps(report, indent=2, ensure_ascii=False) + if args.report: + with args.report.open("x", encoding="utf-8") as output: + output.write(rendered + "\n") + print(rendered) + + +if __name__ == "__main__": + main() diff --git a/scripts/prepare_model_repo.py b/scripts/prepare_model_repo.py new file mode 100644 index 0000000000000000000000000000000000000000..81c44b2034a26fb27aa8acecc8d9f043a69ac088 --- /dev/null +++ b/scripts/prepare_model_repo.py @@ -0,0 +1,78 @@ +"""Create a NEW, verified model upload directory. Never upload or modify source.""" +import argparse +import hashlib +import json +import shutil +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +from grounding_demo.native_runtime import inspect_contract + +METADATA = [ + "config.json", "generation_config.json", "preprocessor_config.json", + "tokenizer.json", "tokenizer_config.json", "chat_template.jinja", + "configuration_oxygen_vl_v3.py", "configuration_kimi_k3.py", + "modeling_oxygen_vl_v3.py", "modeling_kimi_k3.py", "processing_oxygen_vl_v3.py", + "kimi_k3_vision_processing.py", "media_utils.py", +] +OPTIONAL = ["model.safetensors.index.json", "added_tokens.json", "special_tokens_map.json", + "vocab.json", "merges.txt", "streammind_gate.py"] + + +def sha256(path): + digest = hashlib.sha256() + with path.open("rb") as stream: + for block in iter(lambda: stream.read(8 * 1024 * 1024), b""): + digest.update(block) + return digest.hexdigest() + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + p.add_argument("source", type=Path) + p.add_argument("output", type=Path) + args = p.parse_args() + source = args.source.resolve(strict=True) + output = args.output.resolve() + if output.exists() or output.is_relative_to(source): + raise SystemExit("Choose a NEW output directory outside the original model") + contract = inspect_contract(source) + names = METADATA + [n for n in OPTIONAL if (source / n).is_file()] + contract["weight_shards"] + output.parent.mkdir(parents=True, exist_ok=True) + required = sum((source / n).stat().st_size for n in names) + if shutil.disk_usage(output.parent).free < required + 1024 ** 3: + raise SystemExit("Insufficient free disk for independent model copy") + output.mkdir() + manifest = {} + for name in names: + original, copied = source / name, output / name + before = original.stat() + source_hash = sha256(original) + shutil.copy2(original, copied) + after = original.stat() + if (before.st_size, before.st_mtime_ns) != (after.st_size, after.st_mtime_ns): + raise RuntimeError(f"Source changed during copy: {name}") + if sha256(copied) != source_hash: + raise RuntimeError(f"Copy checksum failed: {name}") + manifest[name] = {"bytes": copied.stat().st_size, "sha256": source_hash} + print(f"Verified {name} {source_hash}", flush=True) + inspect_contract(output) + (output / "model_manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") + # No license is invented. The owner must add the approved model card/license. + (output / "README.md").write_text( + "# GroundingPI model upload preparation\n\n" + "Oxygen-VL-v3 with Kimi-K3 vision backbone and GAM tokens.\n\n" + "This is an internal preparation, not permission to publish. Before upload, " + "the owner must supply the approved model card, license, training-data " + "disclosure and visibility. Custom code requires review and a pinned commit.\n\n" + "Use Transformers 5.3.0, the bundled processor, BF16 and SDPA. " + "The grounding demo does not enable StreamMind or require mamba-ssm.\n" + ) + print(json.dumps({"status": "PASS", "files": len(names), "bytes": required, + "output": str(output), "uploaded": False})) + + +if __name__ == "__main__": + main() diff --git a/scripts/smoke_structure.py b/scripts/smoke_structure.py new file mode 100644 index 0000000000000000000000000000000000000000..4c39383ec9322844287ed68517aee62b329012c4 --- /dev/null +++ b/scripts/smoke_structure.py @@ -0,0 +1,58 @@ +"""Random tiny-model CPU test of custom generate/prefill. NOT a 4B accuracy test.""" +import argparse +import json +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from grounding_demo.native_runtime import inspect_contract, user_messages + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("model_path", type=Path, help="Reviewed native code/config/tokenizer directory") + args = parser.parse_args() + root = str(args.model_path.resolve()) + inspect_contract(Path(root), require_weights=False) + import torch + from PIL import Image + from transformers import AutoConfig, AutoProcessor + from transformers.dynamic_module_utils import get_class_from_dynamic_module + + c = AutoConfig.from_pretrained(root, trust_remote_code=True) + for key, value in dict(hidden_size=32, intermediate_size=64, num_hidden_layers=1, + num_attention_heads=4, num_key_value_heads=2, head_dim=8).items(): + setattr(c.text_config, key, value) + for key, value in dict(hidden_size=32, qkv_hidden_size=32, intermediate_size=64, + num_hidden_layers=1, num_attention_heads=4, out_hidden_size=32, + projector_hidden_size=64, init_pos_emb_height=2, + init_pos_emb_width=2).items(): + setattr(c.vision_config, key, value) + for config in [c, c.text_config, c.vision_config]: + config._attn_implementation = "sdpa" + model_class = get_class_from_dynamic_module(c.auto_map["AutoModelForImageTextToText"], root) + # Full float32 only for this CPU/random-weight structural test; production is BF16. + model = model_class(c).eval().float() + processor = AutoProcessor.from_pretrained(root, trust_remote_code=True) + rendered = processor.apply_chat_template(user_messages("Find the red square."), + tokenize=False, add_generation_prompt=True) + inputs = processor(text=[rendered], images=[Image.new("RGB", (28, 28), "red")], + return_tensors="pt") + calls = [] + hook = model.model.visual.register_forward_pre_hook(lambda *args: calls.append("vision")) + try: + with torch.inference_mode(): + output = model.generate(**inputs, max_new_tokens=3, do_sample=False, + use_cache=True, eos_token_id=[151645, 151643]) + finally: + hook.remove() + generated = int(output.shape[-1] - inputs["input_ids"].shape[-1]) + if len(calls) != 1 or generated < 1: + raise RuntimeError("Vision must execute exactly once during cached generate prefill.") + print(json.dumps({"scope": "RANDOM_TINY_MODEL_CPU_STRUCTURE_ONLY_NOT_4B_ACCURACY", + "vision_calls": len(calls), "new_tokens": generated, + "parameters": sum(p.numel() for p in model.parameters())}, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100644 index 0000000000000000000000000000000000000000..53295278dc54dc15ee0920a896b89e4335715565 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail +project_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$project_dir" +if [[ ! -x .venv/bin/python ]]; then + python3 -m venv .venv + .venv/bin/python -m pip install --upgrade pip + .venv/bin/python -m pip install -r requirements.txt +fi +exec .venv/bin/python space_app.py diff --git a/scripts/validate_gradio.py b/scripts/validate_gradio.py new file mode 100644 index 0000000000000000000000000000000000000000..76172999ea0b1a205b782767911a1dbebe130454 --- /dev/null +++ b/scripts/validate_gradio.py @@ -0,0 +1,67 @@ +"""Exercise actual Gradio session state, uploads, GPU generation and outputs.""" +import argparse +import hashlib +import json +import sys +import time +from pathlib import Path + +from gradio_client import Client, handle_file + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +from grounding_demo.catalog import load_cases +from grounding_demo.console import query_from_prompt +from grounding_demo.protocol import parse_gam + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + p.add_argument("url") + p.add_argument("--output", type=Path, required=True) + p.add_argument("--limit", type=int, default=0) + p.add_argument("--route") + args = p.parse_args() + if args.output.exists() or args.output.with_suffix(".jsonl").exists(): + raise SystemExit("Refusing to overwrite previous run") + client = Client(args.url, verbose=False, download_files=False, httpx_kwargs={"trust_env": False}) + health = client.predict(api_name="/service_status") + if "Inference offline" in health: + raise SystemExit(health) + rows = [r for r in load_cases() if not args.route or r["route"] == args.route] + if args.limit: + rows = rows[:args.limit] + results = [] + args.output.parent.mkdir(parents=True, exist_ok=True) + with args.output.with_suffix(".jsonl").open("x") as stream: + for row in rows: + rec = {"id": row["id"], "route": row["route"], "prompt": row["prompt"], + "image_sha256": hashlib.sha256((ROOT / row["image"]).read_bytes()).hexdigest()} + started = time.perf_counter() + try: + # Upload current image rather than rely on hidden server default state. + client.predict(handle_file(str(ROOT / row["image"])), row["route"], row["prompt"], api_name="/choose_upload") + result = client.predict(query_from_prompt(row["prompt"], row["route"]), row["route"], api_name="/run_console") + raw = result[4] + parsed = parse_gam(raw, row["route"]) + rec.update(status="PASS" if parsed.valid and "Complete ·" in result[5] else "FAIL", + response=raw, metrics=result[1], normalized=json.loads(result[3]), + output_image=result[0], errors=list(parsed.errors), view="direct_prediction_overlay") + except Exception as exc: + rec.update(status="ERROR", error=repr(exc)) + rec["elapsed_s"] = time.perf_counter() - started + results.append(rec) + stream.write(json.dumps(rec, ensure_ascii=False) + "\n") + stream.flush() + print(f"{rec['status']} {row['id']} {rec['elapsed_s']:.2f}s", flush=True) + failed = sum(r["status"] != "PASS" for r in results) + report = {"status": "PASS" if not failed else "FAIL", "total": len(results), "failed": failed, + "url": args.url, "health": health, "results": results, + "scope": "real_upload_session_generation_protocol_not_independent_accuracy"} + with args.output.open("x") as output: + json.dump(report, output, indent=2, ensure_ascii=False) + raise SystemExit(bool(failed)) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_ui.py b/scripts/verify_ui.py new file mode 100644 index 0000000000000000000000000000000000000000..1eff5aafc31037d84f58dc1414388af2bba75a83 --- /dev/null +++ b/scripts/verify_ui.py @@ -0,0 +1,49 @@ +"""Freeze/check the original UI bytes and visible case contract, excluding backend code.""" +import argparse +import hashlib +import json +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +CASE_KEYS = ["id", "route", "route_title", "title", "prompt", "expected", "image", "source", + "image_sha256", "difficulty", "validation"] + + +def fingerprint(root): + rows = json.loads((root / "data/cases.json").read_text()) + paths = ["app.py", "grounding_demo/console.py", "grounding_demo/catalog.py", + "grounding_demo/protocol.py", "grounding_demo/render.py"] + paths += [str(path.relative_to(root)) for path in (root / "assets").iterdir() if path.is_file()] + paths += [row["image"] for row in rows] + normalized = [{key: row.get(key) for key in CASE_KEYS} for row in rows] + return { + "files": {name: hashlib.sha256((root / name).read_bytes()).hexdigest() for name in sorted(paths)}, + "case_contract_sha256": hashlib.sha256(json.dumps(normalized, sort_keys=True, + ensure_ascii=False).encode()).hexdigest(), + "cases": len(rows), "routes": len({row["route"] for row in rows}), + } + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--reference", type=Path, help="Original project; compare then create lock without overwrite") + args = parser.parse_args() + current = fingerprint(ROOT) + lock = ROOT / "docs/ui_paper_r7_lock.json" + if not lock.exists(): + lock = ROOT / "docs/ui_lock.json" + if args.reference: + original = fingerprint(args.reference.resolve()) + if current != original: + raise SystemExit("FAIL: UI/assets/case contract differ from reference") + with lock.open("x", encoding="utf-8") as f: + json.dump(current, f, indent=2, ensure_ascii=False) + f.write("\n") + else: + if current != json.loads(lock.read_text()): + raise SystemExit("FAIL: UI/assets/case contract differ from selected release lock") + print(f"PASS: {len(current['files'])} locked UI/assets/images; {current['routes']} routes; {current['cases']} cases") + + +if __name__ == "__main__": + main() diff --git a/space_app.py b/space_app.py new file mode 100644 index 0000000000000000000000000000000000000000..09d3f70264f754b1cff62c92760b4e34ecde8f73 --- /dev/null +++ b/space_app.py @@ -0,0 +1,24 @@ +"""HF Gradio entrypoint. The original app.py and visual assets stay unchanged.""" +import os + +from grounding_demo.client import zerogpu_configured + +os.environ.setdefault("GROUNDING_BACKEND", "zerogpu") +os.environ["GROUNDING_BACKEND"] = os.environ["GROUNDING_BACKEND"].strip().lower() +os.environ.setdefault("GRADIO_ANALYTICS_ENABLED", "False") + +if os.environ["GROUNDING_BACKEND"] == "zerogpu" and zerogpu_configured(): + from grounding_demo import zerogpu_backend # noqa: F401 - install hooks and load model + +# Unconfigured CPU preview needs no spaces/torch import. Configured serving still +# places the model at startup, before Gradio, never lazily inside a GPU request. + +from app import demo + + +if __name__ == "__main__": + demo.queue(default_concurrency_limit=1, max_size=8).launch( + server_name="0.0.0.0", server_port=int(os.getenv("DEMO_PORT", "7860")), + root_path=os.getenv("DEMO_ROOT_PATH") or None, + max_file_size="30mb", show_error=True, + ) diff --git a/tests/test_bundle.py b/tests/test_bundle.py new file mode 100644 index 0000000000000000000000000000000000000000..f8a3bdf3d6187e8f053a769af7b7ee614074432c --- /dev/null +++ b/tests/test_bundle.py @@ -0,0 +1,35 @@ +import json +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path +from zipfile import ZipFile + +ROOT = Path(__file__).resolve().parents[1] + + +class BundleTests(unittest.TestCase): + def test_public_allowlist_and_ui_lock(self): + with tempfile.TemporaryDirectory() as temp: + target = Path(temp) / "space.zip" + subprocess.run([sys.executable, str(ROOT / "scripts/build_bundle.py"), str(target)], check=True, capture_output=True) + with ZipFile(target) as archive: + names = archive.namelist() + self.assertIn("space_app.py", names) + self.assertIn("docs/HF_SPACE_DEPLOYMENT.md", names) + self.assertFalse(any(n.startswith(("verification/", "logs/", ".runtime/", "deploy/")) for n in names)) + self.assertNotIn("docs/FUYAO_REPRODUCTION.md", names) + self.assertNotIn("scripts/service.py", names) + rows = json.loads(archive.read("data/cases.json")) + self.assertEqual(len(rows), 27) + self.assertTrue(all("artifact_image_sha256" in row for row in rows)) + payload = archive.read("data/cases.json").decode() + for marker in ["/dataset-", "/workspace/", "xiaopeng.com", "source_jsonl", "source_line"]: + self.assertNotIn(marker, payload) + archive.extractall(Path(temp) / "unpacked") + subprocess.run([sys.executable, "scripts/verify_ui.py"], cwd=Path(temp) / "unpacked", check=True, capture_output=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_console.py b/tests/test_console.py new file mode 100644 index 0000000000000000000000000000000000000000..378bc85ea4eb8727b6a150f08d9e3c0c561604d7 --- /dev/null +++ b/tests/test_console.py @@ -0,0 +1,163 @@ +import json +import html +import unittest +from html.parser import HTMLParser +from unittest.mock import patch + +import app +from grounding_demo.console import compile_query, query_from_prompt, targets_html + + +class ConsoleTest(unittest.TestCase): + def test_all_27_prompts_roundtrip_exactly(self): + for row in app.CASES: + with self.subTest(case=row["id"]): + query = query_from_prompt(row["prompt"], row["route"]) + self.assertEqual(compile_query(query, row["route"]), row["prompt"]) + + def test_category_separator(self): + self.assertIn("carperson.", compile_query("car, person", "grounding")) + + def test_case_switch_resets_prediction(self): + output = app.load_case(app.CASES[1]["id"]) + self.assertEqual(output[8], "[]") + self.assertIn("Image ready", output[10]) + + def test_upload_cannot_reveal_unrelated_gt(self): + row = app.CASES[0] + path = str(app.ROOT / row["image"]) + uploaded = app.upload_image(path, row["route"], row["prompt"]) + self.assertIsNone(uploaded[1]) + self.assertEqual(uploaded[2], path) + self.assertEqual(uploaded[8], "[]") + self.assertFalse(hasattr(app, "switch_view")) + self.assertFalse(any(c.get("props", {}).get("elem_id") == "view-toggle" + for c in app.demo.config["components"])) + + def test_invalid_protocol_is_not_shown_as_valid_overlay(self): + row = app.CASES[0] + valid = "<|object_ref_start|>car<|object_ref_end|><|box_start|><1><2><30><40><|box_end|>" + invalid = "<|object_ref_start|>car<|object_ref_end|><|box_start|><1><2><3><|box_end|>" + result = app.result_bundle( + str(app.ROOT / row["image"]), row["prompt"], row["route"], valid + invalid + ) + self.assertEqual(result["normalized"], "[]") + self.assertIn("Protocol error", result["metrics"]) + + def test_actual_request_uses_latest_query_without_reference(self): + row = app.CASES[0] + path = str(app.ROOT / row["image"]) + response = "<|object_ref_start|>car<|object_ref_end|><|box_start|><1><2><30><40><|box_end|>" + with patch.object(app.GroundingClient, "infer", return_value=(response, 1.2, {})) as infer: + output = app.run_inference(path, "car", row["route"]) + infer.assert_called_once_with(path, compile_query("car", row["route"])) + self.assertIsInstance(output[0], app.Image.Image) + self.assertEqual(len(output), 6) + self.assertIn("1 visual targets", output[-1]) + + def test_labels_are_html_escaped(self): + self.assertIn( + "<script>", targets_html([{"label": "