Spaces:
Running on Zero
Running on Zero
Deploy provenance-first OpenComic-Continue research UI
Browse files
app.py
CHANGED
|
@@ -98,14 +98,32 @@ def generate(
|
|
| 98 |
},
|
| 99 |
}
|
| 100 |
with httpx.Client(timeout=900) as client:
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
images = [_data_url_to_image(item) for item in result.get("page_data_urls", [])]
|
| 106 |
research = {
|
| 107 |
"model_variant": [item.get("model_variant") for item in result.get("scripts", [])],
|
| 108 |
-
"routing": result.get("routing", []),
|
| 109 |
"job_id": result.get("job_id"),
|
| 110 |
"renderer": result.get(
|
| 111 |
"renderer", {"status": "RENDERER NOT RUN (visible placeholder panels)"}
|
|
@@ -136,22 +154,6 @@ def record_preference(choice: str, notes: str) -> str:
|
|
| 136 |
return "Anonymous preference recorded for this research session."
|
| 137 |
|
| 138 |
|
| 139 |
-
def one_click_quality(files: list[str] | None, reading_direction: str):
|
| 140 |
-
session, memory, summary = analyze(files, reading_direction)
|
| 141 |
-
generated = generate(
|
| 142 |
-
session,
|
| 143 |
-
pages=1,
|
| 144 |
-
creativity=0.35,
|
| 145 |
-
dialogue_density=0.0,
|
| 146 |
-
style_fidelity=0.95,
|
| 147 |
-
character_fidelity=0.95,
|
| 148 |
-
reading_direction=reading_direction,
|
| 149 |
-
research_mode=True,
|
| 150 |
-
)
|
| 151 |
-
images, scripts, updated_session, updated_memory, research = generated
|
| 152 |
-
return images, scripts, updated_session, updated_memory, research, summary
|
| 153 |
-
|
| 154 |
-
|
| 155 |
with gr.Blocks(title="OpenComic-Continue") as demo:
|
| 156 |
gr.Markdown(
|
| 157 |
"# OpenComic-Continue\n"
|
|
@@ -167,13 +169,13 @@ with gr.Blocks(title="OpenComic-Continue") as demo:
|
|
| 167 |
)
|
| 168 |
direction = gr.Radio(["ltr", "rtl"], value="ltr", label="Reading direction")
|
| 169 |
analyze_button = gr.Button("Analyze comic", variant="primary")
|
| 170 |
-
one_click_button = gr.Button("Analyze + generate one quality page")
|
| 171 |
analysis_summary = gr.Markdown()
|
| 172 |
memory_json = gr.JSON(label="StoryMemory")
|
| 173 |
analyze_button.click(
|
| 174 |
analyze,
|
| 175 |
[uploads, direction],
|
| 176 |
[memory_state, memory_json, analysis_summary],
|
|
|
|
| 177 |
)
|
| 178 |
with gr.Tab("Continue"):
|
| 179 |
with gr.Row():
|
|
@@ -207,18 +209,7 @@ with gr.Blocks(title="OpenComic-Continue") as demo:
|
|
| 207 |
research_mode,
|
| 208 |
],
|
| 209 |
[gallery, scripts, memory_state, updated_memory, research_json],
|
| 210 |
-
|
| 211 |
-
one_click_button.click(
|
| 212 |
-
one_click_quality,
|
| 213 |
-
[uploads, direction],
|
| 214 |
-
[
|
| 215 |
-
gallery,
|
| 216 |
-
scripts,
|
| 217 |
-
memory_state,
|
| 218 |
-
updated_memory,
|
| 219 |
-
research_json,
|
| 220 |
-
analysis_summary,
|
| 221 |
-
],
|
| 222 |
)
|
| 223 |
with gr.Tab("Pairwise evaluation"):
|
| 224 |
gr.Markdown(
|
|
|
|
| 98 |
},
|
| 99 |
}
|
| 100 |
with httpx.Client(timeout=900) as client:
|
| 101 |
+
planned_response = client.post(
|
| 102 |
+
f"{API_URL}/plan-continuation", headers=_headers(), json=request
|
| 103 |
+
)
|
| 104 |
+
if planned_response.is_error:
|
| 105 |
+
raise gr.Error(
|
| 106 |
+
f"Planning failed ({planned_response.status_code}): "
|
| 107 |
+
f"{planned_response.text[:500]}"
|
| 108 |
+
)
|
| 109 |
+
planned = planned_response.json()
|
| 110 |
+
render_request = {
|
| 111 |
+
**request,
|
| 112 |
+
"script": planned["script"],
|
| 113 |
+
"planner_metadata": planned.get("planner", {}),
|
| 114 |
+
}
|
| 115 |
+
response = client.post(
|
| 116 |
+
f"{API_URL}/render-script", headers=_headers(), json=render_request
|
| 117 |
+
)
|
| 118 |
+
if response.is_error:
|
| 119 |
+
raise gr.Error(
|
| 120 |
+
f"Rendering failed ({response.status_code}): {response.text[:500]}"
|
| 121 |
+
)
|
| 122 |
+
result = response.json()
|
| 123 |
images = [_data_url_to_image(item) for item in result.get("page_data_urls", [])]
|
| 124 |
research = {
|
| 125 |
"model_variant": [item.get("model_variant") for item in result.get("scripts", [])],
|
| 126 |
+
"routing": planned.get("routing", result.get("routing", [])),
|
| 127 |
"job_id": result.get("job_id"),
|
| 128 |
"renderer": result.get(
|
| 129 |
"renderer", {"status": "RENDERER NOT RUN (visible placeholder panels)"}
|
|
|
|
| 154 |
return "Anonymous preference recorded for this research session."
|
| 155 |
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
with gr.Blocks(title="OpenComic-Continue") as demo:
|
| 158 |
gr.Markdown(
|
| 159 |
"# OpenComic-Continue\n"
|
|
|
|
| 169 |
)
|
| 170 |
direction = gr.Radio(["ltr", "rtl"], value="ltr", label="Reading direction")
|
| 171 |
analyze_button = gr.Button("Analyze comic", variant="primary")
|
|
|
|
| 172 |
analysis_summary = gr.Markdown()
|
| 173 |
memory_json = gr.JSON(label="StoryMemory")
|
| 174 |
analyze_button.click(
|
| 175 |
analyze,
|
| 176 |
[uploads, direction],
|
| 177 |
[memory_state, memory_json, analysis_summary],
|
| 178 |
+
api_name="analyze_quality",
|
| 179 |
)
|
| 180 |
with gr.Tab("Continue"):
|
| 181 |
with gr.Row():
|
|
|
|
| 209 |
research_mode,
|
| 210 |
],
|
| 211 |
[gallery, scripts, memory_state, updated_memory, research_json],
|
| 212 |
+
api_name="generate_quality",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
)
|
| 214 |
with gr.Tab("Pairwise evaluation"):
|
| 215 |
gr.Markdown(
|