Spaces:
Running on Zero
Running on Zero
Deploy provenance-first OpenComic-Continue research UI
Browse files
app.py
CHANGED
|
@@ -54,9 +54,14 @@ def analyze(files: list[str] | None, reading_direction: str):
|
|
| 54 |
result = response.json()
|
| 55 |
summary = (
|
| 56 |
f"Analyzed {result['pages']} pages and {result['panels']} panels. "
|
| 57 |
-
"
|
| 58 |
)
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def _data_url_to_image(value: str) -> Image.Image:
|
|
@@ -65,7 +70,7 @@ def _data_url_to_image(value: str) -> Image.Image:
|
|
| 65 |
|
| 66 |
|
| 67 |
def generate(
|
| 68 |
-
|
| 69 |
pages: int,
|
| 70 |
creativity: float,
|
| 71 |
dialogue_density: float,
|
|
@@ -74,10 +79,13 @@ def generate(
|
|
| 74 |
reading_direction: str,
|
| 75 |
research_mode: bool,
|
| 76 |
):
|
| 77 |
-
if not
|
| 78 |
raise gr.Error("Analyze a comic before requesting a continuation.")
|
|
|
|
|
|
|
| 79 |
request = {
|
| 80 |
"memory": memory,
|
|
|
|
| 81 |
"settings": {
|
| 82 |
"pages": int(pages),
|
| 83 |
"creativity": creativity,
|
|
@@ -102,8 +110,20 @@ def generate(
|
|
| 102 |
"renderer": result.get(
|
| 103 |
"renderer", {"status": "RENDERER NOT RUN (visible placeholder panels)"}
|
| 104 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def record_preference(choice: str, notes: str) -> str:
|
|
@@ -140,9 +160,11 @@ with gr.Blocks(title="OpenComic-Continue") as demo:
|
|
| 140 |
)
|
| 141 |
with gr.Tab("Continue"):
|
| 142 |
with gr.Row():
|
| 143 |
-
page_count = gr.Slider(
|
|
|
|
|
|
|
| 144 |
creativity = gr.Slider(0, 1, value=0.5, label="Creativity")
|
| 145 |
-
dialogue = gr.Slider(0, 1, value=0.
|
| 146 |
with gr.Row():
|
| 147 |
style = gr.Slider(0, 1, value=0.8, label="Style fidelity")
|
| 148 |
character = gr.Slider(0, 1, value=0.9, label="Character fidelity")
|
|
@@ -167,7 +189,7 @@ with gr.Blocks(title="OpenComic-Continue") as demo:
|
|
| 167 |
generation_direction,
|
| 168 |
research_mode,
|
| 169 |
],
|
| 170 |
-
[gallery, scripts, updated_memory, research_json],
|
| 171 |
)
|
| 172 |
with gr.Tab("Pairwise evaluation"):
|
| 173 |
gr.Markdown(
|
|
|
|
| 54 |
result = response.json()
|
| 55 |
summary = (
|
| 56 |
f"Analyzed {result['pages']} pages and {result['panels']} panels. "
|
| 57 |
+
"Qwen semantic analysis built a concrete cast, event chain, setting, and unresolved thread."
|
| 58 |
)
|
| 59 |
+
session = {
|
| 60 |
+
"memory": result["memory"],
|
| 61 |
+
"reference_images": result.get("reference_images", []),
|
| 62 |
+
"semantic_analysis": result.get("semantic_analysis", {}),
|
| 63 |
+
}
|
| 64 |
+
return session, result["memory"], summary
|
| 65 |
|
| 66 |
|
| 67 |
def _data_url_to_image(value: str) -> Image.Image:
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
def generate(
|
| 73 |
+
session: dict | None,
|
| 74 |
pages: int,
|
| 75 |
creativity: float,
|
| 76 |
dialogue_density: float,
|
|
|
|
| 79 |
reading_direction: str,
|
| 80 |
research_mode: bool,
|
| 81 |
):
|
| 82 |
+
if not session:
|
| 83 |
raise gr.Error("Analyze a comic before requesting a continuation.")
|
| 84 |
+
memory = session.get("memory", session)
|
| 85 |
+
reference_images = session.get("reference_images", [])
|
| 86 |
request = {
|
| 87 |
"memory": memory,
|
| 88 |
+
"reference_images": reference_images,
|
| 89 |
"settings": {
|
| 90 |
"pages": int(pages),
|
| 91 |
"creativity": creativity,
|
|
|
|
| 110 |
"renderer": result.get(
|
| 111 |
"renderer", {"status": "RENDERER NOT RUN (visible placeholder panels)"}
|
| 112 |
),
|
| 113 |
+
"planner": result.get("planner", {}),
|
| 114 |
+
}
|
| 115 |
+
updated_session = {
|
| 116 |
+
"memory": result.get("memory"),
|
| 117 |
+
"reference_images": result.get("next_reference_images", reference_images),
|
| 118 |
+
"semantic_analysis": session.get("semantic_analysis", {}),
|
| 119 |
}
|
| 120 |
+
return (
|
| 121 |
+
images,
|
| 122 |
+
result.get("scripts", []),
|
| 123 |
+
updated_session,
|
| 124 |
+
result.get("memory"),
|
| 125 |
+
research,
|
| 126 |
+
)
|
| 127 |
|
| 128 |
|
| 129 |
def record_preference(choice: str, notes: str) -> str:
|
|
|
|
| 160 |
)
|
| 161 |
with gr.Tab("Continue"):
|
| 162 |
with gr.Row():
|
| 163 |
+
page_count = gr.Slider(
|
| 164 |
+
1, 1, value=1, step=1, label="Quality pages per run", interactive=False
|
| 165 |
+
)
|
| 166 |
creativity = gr.Slider(0, 1, value=0.5, label="Creativity")
|
| 167 |
+
dialogue = gr.Slider(0, 1, value=0.2, label="Dialogue density")
|
| 168 |
with gr.Row():
|
| 169 |
style = gr.Slider(0, 1, value=0.8, label="Style fidelity")
|
| 170 |
character = gr.Slider(0, 1, value=0.9, label="Character fidelity")
|
|
|
|
| 189 |
generation_direction,
|
| 190 |
research_mode,
|
| 191 |
],
|
| 192 |
+
[gallery, scripts, memory_state, updated_memory, research_json],
|
| 193 |
)
|
| 194 |
with gr.Tab("Pairwise evaluation"):
|
| 195 |
gr.Markdown(
|