Initial publish: SamGeo3 multi-prompt segmentation lab.

Scripts, prompt JSON tiers, usage docs, and README. Input images
(data/) and segmentation outputs (output/) are gitignored.
This commit is contained in:
minsung
2026-07-15 16:11:59 +09:00
commit 34a885bcf8
16 changed files with 4586 additions and 0 deletions
+212
View File
@@ -0,0 +1,212 @@
# Multi-object prompts (Grok + Gemini)
비전 분석 결과를 합친 SAM 3.1 / SamGeo3 텍스트 프롬프트 세트입니다.
| 파일 | 설명 |
|------|------|
| `dji_20260306_0016.json` | DJI 드론 정사 철도·산업 장면 (Grok+Gemini 병합) |
| `dji_20260306_0044.json` | **0016 확장** (`extends`) + scene_delta (철로+도로+열차) |
## tier
| tier | 내용 |
|------|------|
| `compact` | 1차 실험용 19개 (기본) |
| `gap` | **누락 보강 12개** (Gemini 재검토: road, dense forest, covered truck 등) |
| `gap2` | 합본 빈 영역 보강 (다수 프롬프트) |
| `gap2_core` | gap2 중 실측 성공 프롬프트만 (재실행 권장) |
| `improved` | compact + gap 병합 (~31개) |
| `A_high` | 1차 고확률 |
| `B_facility` | 시설·구조 |
| `C_detail` | 야적·지면·지붕색 |
| `D_rail_domain` | 철도 특화 (편차 큼) |
| `E_missed` | gap 확장판 (동의어 포함) |
| `all` | A→E 전부 (중복 제거) |
## 기대 난이도 (정사 드론 기준)
| 프롬프트 | 기대 | 튜닝 팁 |
|----------|------|---------|
| `building`, `solar panel`, `tree`, `car`, `truck` | 높음 | 기본 객체. 낮은 confidence에서도 비교적 잘 잡힘 |
| `railway track`, `fence`, `parking lot`, `blue tarp` | 중~높음 | 선형·구획. context에 따라 변동 |
| `utility pole`, `container`, `material pile` | 중 | 작거나 밀집. `--min-size`로 노이즈 제거 |
| `rail`, `ballast`, `railroad sleeper`, `catenary` | 낮~중 | 도메인 용어·가는 객체. confidence 튜닝 필수 |
권장: **confidence 0.25~0.35** 로 시작.
## 단일 프롬프트 (`text_segment.py`)
```powershell
cd D:\MYCLAUDE_PROJECT\samgeo3-lab
.\.venv\Scripts\Activate.ps1
$img = "data\DJI_20260306100802_0016.JPG"
# 또는: $img = "D:\MYCLAUDE_PROJECT\segment-geospatial\sample\DJI_20260306100802_0016.JPG"
$out = "output\dji_0016_analysis"
python scripts\text_segment.py `
--image $img `
--prompt "solar panel" `
--confidence 0.3 `
--output-dir $out
python scripts\text_segment.py `
--image $img `
--prompt "building" `
--confidence 0.3 `
--output-dir $out
python scripts\text_segment.py `
--image $img `
--prompt "railway track" `
--confidence 0.3 `
--output-dir $out
```
결과 예: `output\dji_0016_analysis\DJI_..._solar_panel_mask.png`
## 멀티 프롬프트 일괄 (`multi_prompt_segment.py`) — 이미 포함됨
모델·이미지를 **1회 로드** 후 프롬프트 루프. 결과는
`output\<stem>_<tier>\{stem}_{prompt}_mask.png` 등 + `summary.json`.
```powershell
cd D:\MYCLAUDE_PROJECT\samgeo3-lab
.\.venv\Scripts\Activate.ps1
# 프롬프트 목록만
python scripts\multi_prompt_segment.py --list-only --tier compact
# compact 19개 일괄 (권장 1차)
python scripts\multi_prompt_segment.py `
--image "data\DJI_20260306100802_0016.JPG" `
--tier compact `
--confidence 0.3 `
--output-dir "output\dji_0016_compact"
# 누락 보강 (Gemini gap) — confidence 약간 낮게, 같은 폴더에 추가하면 merge에 포함
python scripts\multi_prompt_segment.py `
--image "data\DJI_20260306100802_0016.JPG" `
--tier gap `
--confidence 0.25 `
--output-dir "output\dji_0016_compact"
# 1차+보강 한 번에
python scripts\multi_prompt_segment.py --tier improved --confidence 0.28
# 1차 고확률만
python scripts\multi_prompt_segment.py --tier A_high --confidence 0.3
# 전체 tier
python scripts\multi_prompt_segment.py --tier all --confidence 0.25
# 직접 지정
python scripts\multi_prompt_segment.py `
--prompts "solar panel,building,railway track,tree,car,truck" `
--confidence 0.3 `
--output-dir "output\dji_0016_analysis"
```
## DJI_0044 = 이미지 1번(0016) 확장 (별도 체계 아님)
```text
0016 base (compact/gap/gap2) + scene_delta(열차·도로·야적) → 0044
```
```powershell
# 상속 확인
python scripts\multi_prompt_segment.py --prompts-json prompts\dji_20260306_0044.json --list-only --tier compact
python scripts\multi_prompt_segment.py --prompts-json prompts\dji_20260306_0044.json --list-only --tier delta
# 0016과 동일한 파이프라인
python scripts\multi_prompt_segment.py `
--prompts-json prompts\dji_20260306_0044.json `
--image data\DJI_20260306100928_0044.JPG `
--tier compact --confidence 0.3 `
--output-dir output\dji_0044_compact
python scripts\multi_prompt_segment.py `
--prompts-json prompts\dji_20260306_0044.json `
--tier gap --confidence 0.25 `
--output-dir output\dji_0044_compact
python scripts\merge_multi_results.py `
--result-dir output\dji_0044_compact `
--image data\DJI_20260306100928_0044.JPG
```
HTML: `docs/dji_0044_prompts.html`
## 예시: DJI_0100 전체 파이프라인 (compact → gap → gap2_core → merge)
0044 프롬프트 JSON(0016 상속 + 도로/열차 delta)을 **0100 이미지**에 적용하는
권장 end-to-end 예입니다. gap / gap2_core 단계는 선택입니다.
```powershell
cd D:\MYCLAUDE_PROJECT\samgeo3-lab
.\.venv\Scripts\Activate.ps1
$img = "data\DJI_20260306101434_0100.JPG"
$out = "output\dji_0100_compact"
$json = "prompts\dji_20260306_0044.json"
# (선택) 프롬프트 목록 확인
python scripts\multi_prompt_segment.py --prompts-json $json --list-only --tier compact
# 1) 세그 — compact (0016 상속 + 도로/열차 delta)
python scripts\multi_prompt_segment.py `
--prompts-json $json `
--image $img `
--tier compact `
--confidence 0.3 `
--output-dir $out
# 2) (선택) gap 보강
python scripts\multi_prompt_segment.py `
--prompts-json $json `
--image $img `
--tier gap `
--confidence 0.25 `
--output-dir $out
# 3) (선택) gap2_core 보강
python scripts\multi_prompt_segment.py `
--prompts-json $json `
--image $img `
--tier gap2_core `
--confidence 0.22 `
--output-dir $out
# 4) 합치기 + interactive index.html
python scripts\merge_multi_results.py `
--result-dir $out `
--image $img `
--max-side 2048
# 5) 결과 열기
start "$out\merged\index.html"
```
권장 confidence: compact `0.3` → gap `0.25` → gap2_core `0.22`.
같은 `$out` 폴더에 단계별로 마스크를 쌓은 뒤 merge하면 한 HTML에서 전부 볼 수 있습니다.
## 결과 합치기 (overlay + grid + HTML)
`multi_prompt_segment` 실행 후:
```powershell
python scripts\merge_multi_results.py `
--result-dir "output\dji_0016_compact" `
--image "data\DJI_20260306100802_0016.JPG" `
--max-side 2560
```
출력 (`output\dji_0016_compact\merged\`):
| 파일 | 내용 |
|------|------|
| `combined_overlay.png` | 전 클래스 색상 오버레이 |
| `combined_with_legend.png` | 오버레이 + 범례 |
| `per_class_grid.png` | 클래스별 썸네일 격자 |
| `index.html` | 브라우저로 한눈에 보기 |
| `merge_summary.json` | 클래스·픽셀 통계 |
+385
View File
@@ -0,0 +1,385 @@
{
"id": "dji_20260306_0016",
"image": "data/DJI_20260306100802_0016.JPG",
"image_abs_hint": "D:/MYCLAUDE_PROJECT/segment-geospatial/sample/DJI_20260306100802_0016.JPG",
"sources": ["grok-vision", "gemini-vision", "gemini-missed-review"],
"scene_notes_ko": {
"center": "복선 철로, 침목, 자갈 도상(발라스트), 전차선 전주(폴)",
"above_track": "나대지/낙엽 경사면, 검은 덮개막, 파란 타프",
"below_track": "녹색 방음벽/펜스 라인",
"top_left": "낙엽 수목 지역",
"top_right": "대형 창고·차양, 주차장, 흰 승용차, 덮개 화물차, 녹색 지붕 소형 건물, 파란 컨테이너, 노란 안전구역, 가로등/전주",
"bottom": "태양광 패널 지붕, 흰/회색 지붕, 파란/녹색 지붕, 자재 야적(철재·파이프), 녹색 방수시트, 드럼통 더미",
"missed_review_ko": "범례에 가려진 우측 숲·철로 연속부; parking lot만 되고 road 누락; covered truck; street light; drainage; debris"
},
"tiers": {
"A_high": {
"description": "잘 잡힐 가능성 높음 — 강력한 기본 객체",
"prompts": [
"railway track",
"train track",
"railroad",
"building",
"roof",
"solar panel",
"tree",
"car",
"truck",
"fence"
]
},
"B_facility": {
"description": "구체적 시설·구조",
"prompts": [
"warehouse",
"factory building",
"parking lot",
"container",
"utility pole",
"electric pole",
"catenary pole",
"sound barrier",
"retaining wall",
"drainage ditch",
"canopy",
"awning"
]
},
"C_detail": {
"description": "세부·야적·지면·지붕 색",
"prompts": [
"solar farm",
"photovoltaic panel",
"cargo truck",
"covered truck",
"material pile",
"pipe stack",
"steel pile",
"steel pipe",
"bare ground",
"dirt road",
"paved road",
"shed",
"small building",
"blue tarp",
"black tarp",
"green tarp",
"construction tarp",
"green roof",
"blue roof",
"white roof",
"parking space"
]
},
"D_rail_domain": {
"description": "철도 특화 — 성공 편차 큼, confidence/min_size 튜닝 필요",
"prompts": [
"rail",
"ballast",
"railroad sleeper",
"overhead line",
"railway catenary",
"railway embankment",
"noise barrier wall"
]
},
"E_missed": {
"description": "Gemini 재검토: 1차 compact에서 놓치거나 가려진 영역 보강",
"review_notes_ko": [
"범례로 가려진 우측: dense forest / tree 연속부",
"철로·도상 연속: railway 보강은 D와 중복 가능, gravel path 추가",
"parking lot 연결 아스팔트 road 누락",
"covered truck / cargo vehicle 누락",
"street light / lamp post, drainage ditch",
"debris / rubbish / industrial waste"
],
"prompts": [
"road",
"asphalt pavement",
"asphalt road",
"paved road",
"gravel path",
"dense forest",
"forest",
"covered truck",
"cargo vehicle",
"blue covered truck",
"street light",
"lamp post",
"street lamp",
"light pole",
"drainage ditch",
"drainage channel",
"debris",
"rubbish",
"industrial waste",
"scrap metal",
"scrap pile"
],
"recommended_confidence": 0.25
}
},
"compact": {
"description": "1차 실험용 압축 세트",
"prompts": [
"railway track",
"railroad",
"fence",
"utility pole",
"building",
"warehouse",
"solar panel",
"green roof",
"blue roof",
"white roof",
"car",
"truck",
"blue tarp",
"black tarp",
"container",
"material pile",
"tree",
"bare ground",
"parking lot"
]
},
"gap": {
"description": "누락 보강 전용 — Gemini 추천 + 실측 성공 동의어",
"prompts": [
"road",
"asphalt pavement",
"gravel path",
"dense forest",
"covered truck",
"cargo vehicle",
"street light",
"lamp post",
"light pole",
"drainage ditch",
"debris",
"rubbish",
"industrial waste",
"scrap pile"
],
"recommended_confidence": 0.25,
"notes_ko": {
"worked": ["road", "asphalt pavement", "gravel path", "dense forest", "covered truck", "cargo vehicle", "debris", "rubbish", "light pole", "scrap pile"],
"hard_at_0.25": ["street light", "lamp post", "drainage ditch", "industrial waste"],
"tip": "가로등은 light pole@0.2, 배수로는 정사에서 거의 안 잡힘, rubbish/scrap pile은 노이즈 많을 수 있음"
}
},
"improved": {
"description": "compact + gap 병합 (1차+누락 보강, 중복 제거)",
"prompts": [
"railway track",
"railroad",
"fence",
"utility pole",
"building",
"warehouse",
"solar panel",
"green roof",
"blue roof",
"white roof",
"car",
"truck",
"blue tarp",
"black tarp",
"container",
"material pile",
"tree",
"bare ground",
"parking lot",
"road",
"asphalt pavement",
"gravel path",
"dense forest",
"covered truck",
"cargo vehicle",
"street light",
"lamp post",
"light pole",
"drainage ditch",
"debris",
"rubbish",
"industrial waste",
"scrap pile"
],
"recommended_confidence": 0.28
},
"gap2": {
"description": "combined_with_legend 재검토: 아직 원본이 비어 보이는 영역 보강",
"source": "visual review of final merged overlay (Downloads/combined_with_legend.png)",
"gaps_ko": [
"선로 상·하 갈색 성토/제방·마른 초지(scrub) — railway 노란 밴드 바깥",
"검은 타프 주변 갈색 흙더미·절토면",
"주차장·창고 사이 미포장 공터·콘크리트 슬라브",
"하측 야적장 녹생 방수시트/덮개(green tarp) 일부 미채움",
"소형 부스·shed·담장·차양",
"금속/골판 지붕 중 색 라벨에 안 걸린 부분",
"전차선·가느다란 전선/폴 잔여",
"건물 벽면·그림자 밴드",
"선로 침목·도상(ballast) 세부"
],
"prompts": [
"embankment",
"railway embankment",
"dirt embankment",
"soil pile",
"dirt pile",
"earth mound",
"dry grass",
"scrub",
"bushes",
"grass",
"vegetation",
"dormant vegetation",
"brown field",
"open ground",
"concrete",
"concrete pad",
"concrete pavement",
"industrial yard",
"paved yard",
"green tarp",
"green plastic sheet",
"plastic cover",
"shed",
"small shed",
"booth",
"kiosk",
"metal roof",
"corrugated roof",
"gray roof",
"wall",
"building wall",
"fence wall",
"barrier",
"retaining wall",
"canopy",
"awning",
"ballast",
"track bed",
"railway ballast",
"power line",
"overhead wire",
"shadow",
"sidewalk",
"walkway"
],
"recommended_confidence": 0.22,
"worked_at_0.22": [
"dirt embankment",
"dirt pile",
"dry grass",
"bushes",
"grass",
"vegetation",
"brown field",
"open ground",
"concrete",
"concrete pad",
"concrete pavement",
"industrial yard",
"paved yard",
"green tarp",
"green plastic sheet",
"plastic cover",
"shed",
"small shed",
"metal roof",
"corrugated roof",
"gray roof",
"wall",
"building wall",
"fence wall",
"barrier",
"canopy",
"awning",
"sidewalk"
],
"failed_at_0.22": [
"embankment",
"railway embankment",
"soil pile",
"earth mound",
"scrub",
"dormant vegetation",
"booth",
"kiosk",
"retaining wall",
"ballast",
"track bed",
"railway ballast",
"power line",
"overhead wire",
"shadow",
"walkway"
]
},
"gap2_core": {
"description": "gap2 중 실측 성공 프롬프트만 (재실행 권장 세트)",
"prompts": [
"dirt embankment",
"dirt pile",
"dry grass",
"bushes",
"vegetation",
"brown field",
"open ground",
"concrete",
"industrial yard",
"green tarp",
"plastic cover",
"shed",
"metal roof",
"corrugated roof",
"gray roof",
"building wall",
"barrier",
"awning"
],
"recommended_confidence": 0.22
},
"recommended": {
"model_id": "facebook/sam3.1",
"backend": "meta",
"confidence": 0.3,
"confidence_range": [0.25, 0.35],
"gap_confidence": 0.25,
"min_size": 0,
"note": "1차는 compact@0.3, 누락 보강은 gap@0.25 후 merge. 작은 폴/자재는 --min-size."
},
"expected_difficulty": [
{
"prompts": ["building", "solar panel", "tree", "car", "truck"],
"level": "high",
"level_ko": "높음",
"tip_ko": "기본 객체. 낮은 confidence에서도 비교적 잘 잡힘."
},
{
"prompts": ["railway track", "fence", "parking lot", "blue tarp"],
"level": "medium_high",
"level_ko": "중~높음",
"tip_ko": "선형·구획 객체. 장면 context에 따라 성능 변동."
},
{
"prompts": ["road", "asphalt pavement", "dense forest", "covered truck"],
"level": "medium",
"level_ko": "중 (gap 보강)",
"tip_ko": "1차에서 자주 누락. gap tier로 재실행. confidence 0.25 권장."
},
{
"prompts": ["utility pole", "container", "material pile", "street light", "lamp post"],
"level": "medium",
"level_ko": "중",
"tip_ko": "작거나 밀집. --min-size로 노이즈 제거 권장."
},
{
"prompts": ["rail", "ballast", "railroad sleeper", "railway catenary", "debris", "rubbish"],
"level": "low_medium",
"level_ko": "낮~중",
"tip_ko": "도메인·가는 객체·잔해. confidence 튜닝 필수."
}
]
}
+157
View File
@@ -0,0 +1,157 @@
{
"id": "dji_20260306_0044",
"extends": "prompts/dji_20260306_0016.json",
"extends_note_ko": "1번 이미지(DJI_0016) 프롬프트·tier·gap/gap2 워크플로를 그대로 상속. 이 파일은 장면 전용 객체만 추가 확장. 별도 체계 아님.",
"image": "data/DJI_20260306100928_0044.JPG",
"image_abs_hint": "D:/MYCLAUDE_PROJECT/segment-geospatial/sample/DJI_20260306100928_0044.JPG",
"sources": ["extends:dji_20260306_0016", "gemini-vision", "grok-vision"],
"scene_notes_ko": {
"extends": "0016 = 철로+산업단지 베이스. 0044 = 동일 파이프라인 + 도로·열차·야적 강화",
"top": "다차로 도로·교차로·횡단보도·주행 차량·가로수·밀집 건물·태양광",
"middle": "야적장·파이프·백색 자루·목재·철재·파란 타프·철조망 펜스",
"bottom": "복선 철로·열차(객차/화차)·전차선 폴·나대지"
},
"scene_delta": {
"description": "0016 베이스에 없는(또는 이 장면에서 핵심인) 추가 객체 — Gemini+Grok",
"prompts": [
"train",
"locomotive",
"passenger train",
"freight car",
"container car",
"highway",
"pedestrian crossing",
"crosswalk",
"road marking",
"chain-link fence",
"pipe stack",
"pipe pile",
"pipes",
"industrial pipes",
"bag pile",
"bulk bag",
"white sack pile",
"wooden pile",
"lumber pile",
"wood stack",
"tarp",
"gravel",
"gravel ground",
"paved ground",
"dirt ground",
"shrub",
"sleeper",
"trackbed",
"catenary",
"boxcar",
"construction material",
"industrial material",
"debris pile",
"red roof"
],
"recommended_confidence": 0.28
},
"tiers": {
"A_high": {
"description": "0016 A_high + 도로/열차 핵심 추가",
"prompts": [
"road",
"highway",
"train",
"freight car",
"container car",
"car",
"truck"
]
},
"B_facility": {
"description": "0016 B + 횡단보도·도로시설",
"prompts": [
"pedestrian crossing",
"crosswalk",
"road marking",
"chain-link fence",
"street light",
"light pole"
]
},
"C_detail": {
"description": "0016 C + 야적 자재 세분",
"prompts": [
"pipe pile",
"pipes",
"bag pile",
"wooden pile",
"wood stack",
"tarp",
"gravel",
"dirt ground"
]
},
"D_rail_domain": {
"description": "0016 D + 열차 관련",
"prompts": [
"train",
"freight car",
"container car",
"sleeper",
"trackbed",
"catenary"
]
}
},
"compact": {
"description": "0016 compact 상속 + scene_delta(핵심만 필터하지 않고 전체 병합; 실행 시 길면 --tier delta)",
"include_scene_delta": true,
"prompts": [
"train",
"freight car",
"container car",
"highway",
"pedestrian crossing",
"pipe pile",
"wooden pile",
"wood stack"
],
"recommended_confidence": 0.3
},
"recommended": {
"model_id": "facebook/sam3.1",
"backend": "meta",
"confidence": 0.3,
"confidence_range": [0.25, 0.35],
"workflow_ko": [
"1) 0016과 동일: compact → gap → gap2_core (상속된 tier)",
"2) 0044 전용만: --tier delta",
"3) 합본: base compact+delta = --tier compact",
"4) merge_multi_results.py"
],
"note": "별도 체계 아님. 1번 이미지 확장."
},
"expected_difficulty": [
{
"prompts": ["building", "train", "car", "truck", "tree", "road"],
"level": "high",
"level_ko": "높음",
"tip_ko": "0016과 동일 orthophoto 기본 객체 + 열차"
},
{
"prompts": ["railway track", "highway", "fence", "material pile", "pedestrian crossing"],
"level": "medium_high",
"level_ko": "중~높음",
"tip_ko": "선형·구획"
},
{
"prompts": ["pipe pile", "bag pile", "wooden pile", "street light"],
"level": "medium",
"level_ko": "중",
"tip_ko": "밀집 자재 — min_size / conf 0.22~0.28"
},
{
"prompts": ["rail", "ballast", "sleeper", "catenary", "locomotive"],
"level": "low_medium",
"level_ko": "낮~중",
"tip_ko": "도메인·세분 용어 — 0016 gap2와 동일 한계"
}
]
}