carpelan commited on
Commit
b7d87d9
·
2 Parent(s): f965f30 8fd3b0d

Merge branch 'main' of https://github.com/AI-Riksarkivet/htrflow_app

Browse files
app/gradio_config.py CHANGED
@@ -21,6 +21,17 @@ css = """
21
 
22
  .transcription {
23
  font-size: large;
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  /* style of textline svg elements */
@@ -59,6 +70,13 @@ hr.region-divider {
59
  color: var(--block-info-text-color);
60
  }
61
 
 
 
 
 
 
 
 
62
  .pipeline-help a {
63
  color: var(--secondary-400);
64
  }
 
21
 
22
  .transcription {
23
  font-size: large;
24
+ position: sticky;
25
+ top: 20px;
26
+ }
27
+
28
+ .transcription-column {
29
+ height: 100vh;
30
+ }
31
+
32
+ /* this is needed in order to make the transcription sticky */
33
+ .app {
34
+ overflow: visible;
35
  }
36
 
37
  /* style of textline svg elements */
 
70
  color: var(--block-info-text-color);
71
  }
72
 
73
+ .pipeline-info {
74
+ padding: 0 0 0 2px;
75
+ font-weight: var(--block-info-text-weight);
76
+ font-size: var(--block-info-text-size);
77
+ color: var(--block-info-text-color);
78
+ }
79
+
80
  .pipeline-help a {
81
  color: var(--secondary-400);
82
  }
app/tabs/submit.py CHANGED
@@ -44,6 +44,7 @@ GRADIO_CACHE = ".gradio_cache"
44
  EXAMPLES_DIRECTORY = os.path.join(GRADIO_CACHE, "examples")
45
 
46
  if os.environ.get("GRADIO_CACHE_DIR", GRADIO_CACHE) != GRADIO_CACHE:
 
47
  logger.warning("Setting GRADIO_CACHE_DIR to '%s' (overriding a previous value).")
48
 
49
 
@@ -174,13 +175,7 @@ def get_selected_example_pipeline(event: gr.SelectData) -> str | None:
174
 
175
  with gr.Blocks() as submit:
176
  gr.Markdown("# Upload")
177
- gr.Markdown("Start Here! ")
178
- gr.Markdown(
179
- "First you upload upload 1 image or multiple images (max 5 images). You can also use directly the Image ID from the National Archives of Sweden to request an image"
180
- )
181
- gr.Markdown(
182
- "Afterward, choice a template from the examples based on your material. This will configure a certain pipeline that fits your image."
183
- )
184
 
185
  collection_submit_state = gr.State()
186
  with gr.Group():
@@ -192,7 +187,6 @@ with gr.Blocks() as submit:
192
  interactive=True,
193
  object_fit="scale-down",
194
  scale=3,
195
- preview=True,
196
  )
197
 
198
  with gr.Column(scale=2):
@@ -213,6 +207,9 @@ with gr.Blocks() as submit:
213
 
214
  iiif_image_placeholder = gr.Image(visible=False)
215
 
 
 
 
216
  with gr.Column(variant="panel", elem_classes="pipeline-panel"):
217
  gr.HTML("Pipeline", elem_classes="pipeline-header", padding=False)
218
 
@@ -225,35 +222,33 @@ with gr.Blocks() as submit:
225
  scale=0,
226
  elem_classes="pipeline-dropdown",
227
  )
228
- with gr.Column():
229
- with gr.Row():
230
- pipeline_description = gr.HTML(
231
- value=get_pipeline_description,
232
- inputs=pipeline_dropdown,
233
- elem_classes="pipeline-description",
234
- padding=False,
235
- )
236
- help_button = gr.Button(
237
- "Edit Pipeline",
238
- scale=0,
239
- )
240
 
241
- with Modal(visible=False) as help_modal:
242
- custom_template_yaml = gr.Code(
243
- value=get_yaml,
244
- inputs=pipeline_dropdown,
245
- language="yaml",
246
- container=False,
247
- )
248
- url = "https://ai-riksarkivet.github.io/htrflow/latest/getting_started/pipeline.html#example-pipelines"
249
- gr.HTML(
250
- f'See the <a href="{url}">documentation</a> for a detailed description on how to customize HTRflow pipelines.',
251
- padding=False,
252
- elem_classes="pipeline-help",
253
- )
 
 
 
 
 
 
 
 
 
 
254
 
255
  with gr.Row():
256
- run_button = gr.Button("Submit", variant="primary", scale=0, min_width=200)
257
  progess_bar = gr.Textbox(visible=False, show_label=False)
258
 
259
  @batch_image_gallery.upload(
 
44
  EXAMPLES_DIRECTORY = os.path.join(GRADIO_CACHE, "examples")
45
 
46
  if os.environ.get("GRADIO_CACHE_DIR", GRADIO_CACHE) != GRADIO_CACHE:
47
+ os.environ["GRADIO_CACHE_DIR"] = GRADIO_CACHE
48
  logger.warning("Setting GRADIO_CACHE_DIR to '%s' (overriding a previous value).")
49
 
50
 
 
175
 
176
  with gr.Blocks() as submit:
177
  gr.Markdown("# Upload")
178
+ gr.Markdown("Select or upload the image you want to transcribe. You can upload up to five images at a time.")
 
 
 
 
 
 
179
 
180
  collection_submit_state = gr.State()
181
  with gr.Group():
 
187
  interactive=True,
188
  object_fit="scale-down",
189
  scale=3,
 
190
  )
191
 
192
  with gr.Column(scale=2):
 
207
 
208
  iiif_image_placeholder = gr.Image(visible=False)
209
 
210
+ gr.Markdown("## Settings")
211
+ gr.Markdown("Select a pipeline that suits your image. You can edit the pipeline if you need to customize it further.")
212
+
213
  with gr.Column(variant="panel", elem_classes="pipeline-panel"):
214
  gr.HTML("Pipeline", elem_classes="pipeline-header", padding=False)
215
 
 
222
  scale=0,
223
  elem_classes="pipeline-dropdown",
224
  )
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
+ with gr.Column():
227
+ help_button = gr.Button("Edit", scale=0)
228
+
229
+ pipeline_description = gr.HTML(
230
+ value=get_pipeline_description,
231
+ inputs=pipeline_dropdown,
232
+ elem_classes="pipeline-info",
233
+ padding=False,
234
+ )
235
+
236
+ with Modal(visible=False) as help_modal:
237
+ custom_template_yaml = gr.Code(
238
+ value=get_yaml,
239
+ inputs=pipeline_dropdown,
240
+ language="yaml",
241
+ container=False,
242
+ )
243
+ url = "https://ai-riksarkivet.github.io/htrflow/latest/getting_started/pipeline.html#example-pipelines"
244
+ gr.HTML(
245
+ f'See the <a href="{url}">documentation</a> for a detailed description on how to customize HTRflow pipelines.',
246
+ padding=False,
247
+ elem_classes="pipeline-help",
248
+ )
249
 
250
  with gr.Row():
251
+ run_button = gr.Button("Transcribe", variant="primary", scale=0, min_width=200)
252
  progess_bar = gr.Textbox(visible=False, show_label=False)
253
 
254
  @batch_image_gallery.upload(
app/tabs/visualizer.py CHANGED
@@ -65,7 +65,7 @@ with gr.Blocks() as visualizer:
65
  right = gr.Button("Next →", visible=False, scale=0)
66
 
67
  # Transcription panel
68
- with gr.Column(scale=1):
69
  gr.Markdown("## Transcription")
70
  transcription = gr.HTML(elem_classes="transcription", container=True, max_height="60vh")
71
 
 
65
  right = gr.Button("Next →", visible=False, scale=0)
66
 
67
  # Transcription panel
68
+ with gr.Column(scale=1, elem_classes="transcription-column"):
69
  gr.Markdown("## Transcription")
70
  transcription = gr.HTML(elem_classes="transcription", container=True, max_height="60vh")
71