ginnyxxxxxxx commited on
Commit
510cf41
Β·
1 Parent(s): c942daf
Files changed (1) hide show
  1. app.py +81 -23
app.py CHANGED
@@ -174,16 +174,16 @@ CHAIN_CSS = """
174
  }
175
  .hct-num {
176
  font-family: 'DM Mono', monospace;
177
- font-size: 10px;
178
- font-weight: 500;
179
  letter-spacing: 0.12em;
180
- padding: 2px 7px;
181
  border-radius: 4px;
182
  }
183
  .hct-title {
184
- font-size: 11px;
185
- font-weight: 600;
186
- letter-spacing: 0.04em;
187
  text-transform: uppercase;
188
  flex: 1;
189
  }
@@ -263,10 +263,10 @@ CHAIN_CSS = """
263
  }
264
  .hct-arrow-line { flex: 1; height: 1px; background: #d8d4ce; }
265
  .hct-arrow-label {
266
- font-family: 'DM Mono', monospace; font-size: 9px;
267
- color: #b0a898; letter-spacing: 0.08em; text-transform: uppercase;
268
- white-space: nowrap; background: white;
269
- padding: 2px 8px; border: 1px solid #e0dbd4; border-radius: 20px;
270
  }
271
 
272
  /* ── Stage 1: Location table ── */
@@ -376,6 +376,38 @@ CHAIN_CSS = """
376
  .hct-s2 .hct-dot { background: #c08040; }
377
  .hct-s3 .hct-dot { background: #d4453a; }
378
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  /* ── Prompt collapsible ── */
380
  details.hct-prompt-details { padding: 0 14px 10px; }
381
  details.hct-prompt-details summary {
@@ -547,20 +579,23 @@ def _parse_s3(text):
547
  PROMPT_BULLETS = {
548
  1: [
549
  "Extract objective factual features from the agent's mobility trajectory <b>without any interpretation</b>",
550
- "Location inventory: list all visited POIs...",
551
- "Temporal patterns: time-of-day distribution, weekday vs. weekend split...",
552
- "Spatial characteristics: activity radius...",
553
- "Sequence observations: common location transitions...",
554
  ],
555
  2: [
556
  "Perform behavioral abstraction across four dimensions based on Step 1 features",
557
- "Routine &amp; Schedule: infer work schedule type (fixed hours, flexible, shift work, etc.)...",
558
- "Economic Behavior: assess spending tier from venue choices...",
559
- "Social &amp; Lifestyle: identify social engagement patterns, leisure activities...",
560
- "Routine Stability: evaluate consistency and regularity of movement patterns...",
561
  ],
562
  3: [
563
- "Synthesize factual features (Step 1) and behavioral patterns (Step 2) to infer household income bracket...",
 
 
 
564
  "Output: <code>INCOME_REASONING</code> β€” evidence-grounded justification referencing specific mobility observations",
565
  ],
566
  }
@@ -692,7 +727,30 @@ def render_chain(s1_text, s2_text, s3_text, status="idle",
692
  f'<div class="hct-arrow-label">{label}</div>'
693
  f'<div class="hct-arrow-line"></div></div>')
694
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
695
  html = CHAIN_CSS + '<div class="hct-root">'
 
696
  html += stage('s1', 'Stage 01', 'Feature Extraction', s1_body, s1_on, 1)
697
  html += arrow('behavioral abstraction', s2_on)
698
  html += stage('s2', 'Stage 02', 'Behavioral Analysis', s2_body, s2_on, 2)
@@ -866,8 +924,8 @@ with gr.Blocks(title="HiCoTraj Demo") as app:
866
  gr.Markdown("## HiCoTraj β€” Trajectory Visualization & Hierarchical CoT Demo")
867
  gr.Markdown("*Zero-Shot Demographic Reasoning via Hierarchical Chain-of-Thought Prompting from Trajectory* Β· ACM SIGSPATIAL GeoGenAgent 2025")
868
  gr.Markdown("""
869
- **Dataset:** NUMOSIM[1]
870
- > [1]Stanford C, Adari S, Liao X, et al. *NUMoSim: A Synthetic Mobility Dataset with Anomaly Detection Benchmarks.* ACM SIGSPATIAL Workshop on Geospatial Anomaly Detection, 2024.
871
  """)
872
 
873
  gr.Markdown("### Select Agent")
@@ -884,7 +942,7 @@ with gr.Blocks(title="HiCoTraj Demo") as app:
884
  with gr.Column(scale=1):
885
  gr.Markdown("### Trajectory Map")
886
  map_out = gr.HTML()
887
- gr.Markdown("### Rule-based Processed Data")
888
  with gr.Tabs():
889
  with gr.Tab("Summary"):
890
  summary_out = gr.Textbox(lines=10, interactive=False, label="", show_label=False)
@@ -940,4 +998,4 @@ with gr.Blocks(title="HiCoTraj Demo") as app:
940
  outputs=[raw_out, show_all_btn]
941
  )
942
 
943
- app.launch(show_error=True, share=True, theme=gr.themes.Soft())
 
174
  }
175
  .hct-num {
176
  font-family: 'DM Mono', monospace;
177
+ font-size: 12px;
178
+ font-weight: 600;
179
  letter-spacing: 0.12em;
180
+ padding: 3px 9px;
181
  border-radius: 4px;
182
  }
183
  .hct-title {
184
+ font-size: 13px;
185
+ font-weight: 700;
186
+ letter-spacing: 0.05em;
187
  text-transform: uppercase;
188
  flex: 1;
189
  }
 
263
  }
264
  .hct-arrow-line { flex: 1; height: 1px; background: #d8d4ce; }
265
  .hct-arrow-label {
266
+ font-family: 'DM Mono', monospace; font-size: 11px;
267
+ color: #6a6258; letter-spacing: 0.06em; text-transform: uppercase;
268
+ white-space: nowrap; background: white; font-weight: 500;
269
+ padding: 3px 12px; border: 1px solid #ccc8c0; border-radius: 20px;
270
  }
271
 
272
  /* ── Stage 1: Location table ── */
 
376
  .hct-s2 .hct-dot { background: #c08040; }
377
  .hct-s3 .hct-dot { background: #d4453a; }
378
 
379
+ /* ── Data flow banner ── */
380
+ .hct-flow-banner {
381
+ background: #f8f9fc; border: 1px solid #dde0ee;
382
+ border-radius: 10px; padding: 10px 14px; margin-bottom: 10px;
383
+ font-size: 11.5px; color: #445;
384
+ }
385
+ .hct-flow-banner-title {
386
+ font-family: 'DM Mono', monospace; font-size: 9.5px; font-weight: 600;
387
+ letter-spacing: 0.1em; text-transform: uppercase;
388
+ color: #7080a0; margin-bottom: 7px;
389
+ }
390
+ .hct-flow-steps {
391
+ display: flex; align-items: center; gap: 0; flex-wrap: nowrap;
392
+ }
393
+ .hct-flow-step {
394
+ flex: 1; background: white; border: 1px solid #d4daf0;
395
+ border-radius: 7px; padding: 6px 8px; text-align: center;
396
+ min-width: 0;
397
+ }
398
+ .hct-flow-step-label {
399
+ font-family: 'DM Mono', monospace; font-size: 8.5px;
400
+ color: #8090b0; letter-spacing: 0.08em; text-transform: uppercase;
401
+ margin-bottom: 3px;
402
+ }
403
+ .hct-flow-step-desc {
404
+ font-size: 10.5px; color: #334; line-height: 1.4;
405
+ }
406
+ .hct-flow-arrow {
407
+ font-size: 14px; color: #a0aac0; padding: 0 5px;
408
+ flex-shrink: 0;
409
+ }
410
+
411
  /* ── Prompt collapsible ── */
412
  details.hct-prompt-details { padding: 0 14px 10px; }
413
  details.hct-prompt-details summary {
 
579
  PROMPT_BULLETS = {
580
  1: [
581
  "Extract objective factual features from the agent's mobility trajectory <b>without any interpretation</b>",
582
+ "Location inventory: list all visited POIs with visit counts and apparent price tier (budget / mid-range / high-end)",
583
+ "Temporal patterns: time-of-day distribution, weekday vs. weekend split, and regularity of routines",
584
+ "Spatial characteristics: activity radius, average movement distance between locations",
585
+ "Sequence observations: common location transitions and typical daily activity chains",
586
  ],
587
  2: [
588
  "Perform behavioral abstraction across four dimensions based on Step 1 features",
589
+ "Routine &amp; Schedule: infer work schedule type (fixed hours, flexible, shift work, etc.) and daily structure",
590
+ "Economic Behavior: assess spending tier from venue choices, transportation costs, and lifestyle signals",
591
+ "Social &amp; Lifestyle: identify social engagement patterns, leisure activities, and community involvement",
592
+ "Routine Stability: evaluate consistency and regularity of movement patterns over the observation period",
593
  ],
594
  3: [
595
+ "Synthesize factual features (Step 1) and behavioral patterns (Step 2) to infer household income bracket",
596
+ "Score location economic indicators: luxury / mid-range / budget venue distribution",
597
+ "Consider transportation mode signals, activity diversity, and temporal flexibility as income proxies",
598
+ "Output: <code>INCOME_PREDICTION</code> β€” a single income range with confidence rating (1–5)",
599
  "Output: <code>INCOME_REASONING</code> β€” evidence-grounded justification referencing specific mobility observations",
600
  ],
601
  }
 
727
  f'<div class="hct-arrow-label">{label}</div>'
728
  f'<div class="hct-arrow-line"></div></div>')
729
 
730
+ flow_banner = (
731
+ '<div class="hct-flow-banner">'
732
+ '<div class="hct-flow-banner-title">Data Pipeline</div>'
733
+ '<div class="hct-flow-steps">'
734
+ '<div class="hct-flow-step">'
735
+ '<div class="hct-flow-step-label">Raw Data</div>'
736
+ '<div class="hct-flow-step-desc">Stay points + POI metadata<br><span style="color:#8090b0;font-size:10px">timestamps Β· venue names Β· activity types</span></div>'
737
+ '</div>'
738
+ '<div class="hct-flow-arrow">β†’</div>'
739
+ '<div class="hct-flow-step">'
740
+ '<div class="hct-flow-step-label">Processed</div>'
741
+ '<div class="hct-flow-step-desc">Detailed Activity Chronicles<br><span style="color:#8090b0;font-size:10px">weekly narratives Β· visit summaries</span></div>'
742
+ '</div>'
743
+ '<div class="hct-flow-arrow">β†’</div>'
744
+ '<div class="hct-flow-step" style="border-color:#b0bce8;background:#f4f6fb;">'
745
+ '<div class="hct-flow-step-label" style="color:#5060a0;">Prompt 1</div>'
746
+ '<div class="hct-flow-step-desc" style="color:#3a4a80;">Factual feature extraction<br><span style="color:#8090b0;font-size:10px">no interpretation Β· pattern identification</span></div>'
747
+ '</div>'
748
+ '</div>'
749
+ '</div>'
750
+ )
751
+
752
  html = CHAIN_CSS + '<div class="hct-root">'
753
+ html += flow_banner
754
  html += stage('s1', 'Stage 01', 'Feature Extraction', s1_body, s1_on, 1)
755
  html += arrow('behavioral abstraction', s2_on)
756
  html += stage('s2', 'Stage 02', 'Behavioral Analysis', s2_body, s2_on, 2)
 
924
  gr.Markdown("## HiCoTraj β€” Trajectory Visualization & Hierarchical CoT Demo")
925
  gr.Markdown("*Zero-Shot Demographic Reasoning via Hierarchical Chain-of-Thought Prompting from Trajectory* Β· ACM SIGSPATIAL GeoGenAgent 2025")
926
  gr.Markdown("""
927
+ **Dataset:** NUMOSIM β€” a synthetic mobility dataset with realistic activity patterns across 6,000 agents.
928
+ > Stanford C, Adari S, Liao X, et al. *NUMoSim: A Synthetic Mobility Dataset with Anomaly Detection Benchmarks.* ACM SIGSPATIAL Workshop on Geospatial Anomaly Detection, 2024.
929
  """)
930
 
931
  gr.Markdown("### Select Agent")
 
942
  with gr.Column(scale=1):
943
  gr.Markdown("### Trajectory Map")
944
  map_out = gr.HTML()
945
+ gr.Markdown("### NUMOSIM Raw Data")
946
  with gr.Tabs():
947
  with gr.Tab("Summary"):
948
  summary_out = gr.Textbox(lines=10, interactive=False, label="", show_label=False)
 
998
  outputs=[raw_out, show_all_btn]
999
  )
1000
 
1001
+ app.launch(show_error=True, theme=gr.themes.Soft(), share=True)