How mahaqj/scene-manipulation works
This repository is a command-line scene-manipulation prototype: a user supplies an image and natural-language relocation instruction, and the pipeline parses the instruction, detects and segments the target, removes and relocates it, then displays the result. README documents DETR detection and Stable Diffusion inpainting; relighting is explicitly not implemented. The graph includes SAM’s principal inference layers and automatic-mask path. Scene-pipeline links rely on README documentation; internal links are limited to shown calls or SOURCE INDEX references.
Main entry points: scene_manip.py Scene CLI · build_sam.py SAM builder · sam.py SAM model core · predictor.py SAM predictor
Components 23
Scene workflow
- Scene CLI
segment-anything/scene_manip.py - Instruction parsing
segment-anything/scene_manip.py - Object detection
segment-anything/scene_manip.py - SAM segmentation
segment-anything/segment_anything/predictor.py - Object cutout
segment-anything/scene_manip.py - Scene inpainting
segment-anything/scene_manip.py - Object relocation
segment-anything/scene_manip.py - Relighting (planned)
segment-anything/scene_manip.py - Result display
segment-anything/scene_manip.py
SAM runtime
- SAM builder
segment-anything/segment_anything/build_sam.py - SAM predictor
segment-anything/segment_anything/predictor.py - Automatic masks
segment-anything/segment_anything/automatic_mask_generator.py
SAM model
- SAM model core
segment-anything/segment_anything/modeling/sam.py - Image encoder
segment-anything/segment_anything/modeling/image_encoder.py - Prompt encoder
segment-anything/segment_anything/modeling/prompt_encoder.py - Mask decoder
segment-anything/segment_anything/modeling/mask_decoder.py - Two-way transformer
segment-anything/segment_anything/modeling/transformer.py
SAM support
- Mask utilities
segment-anything/segment_anything/utils/amg.py - Image transforms
segment-anything/segment_anything/utils/transforms.py - Model layers
segment-anything/segment_anything/modeling/common.py
Other components
- User
- DETR
- Stable Diffusion
Connections 28
- User → Scene CLI: provides inputs
README.md - Scene CLI → Instruction parsing: parses instruction
README.md - Scene CLI → Object detection: requests detection
README.md - Object detection → DETR: detects object
README.md - Scene CLI → SAM segmentation: requests mask
README.md - SAM segmentation → SAM predictor: uses predictor
segment-anything/segment_anything/__init__.py - SAM predictor → SAM model core: runs inference
- Scene CLI → Object cutout: cuts out object
README.md - Scene CLI → Scene inpainting: inpaints region
README.md - Scene inpainting → Stable Diffusion: uses inpainting
README.md - Scene CLI → Object relocation: repositions object
README.md - Scene CLI → Result display: displays results
README.md - Scene CLI → Relighting (planned): leaves unimplemented
README.md - SAM builder → Image encoder: constructs
segment-anything/segment_anything/build_sam.py - SAM builder → Prompt encoder: constructs
segment-anything/segment_anything/build_sam.py - SAM builder → Mask decoder: constructs
segment-anything/segment_anything/build_sam.py - SAM builder → Two-way transformer: constructs
segment-anything/segment_anything/build_sam.py - SAM model core → Image encoder: encodes image
segment-anything/segment_anything/modeling/sam.py - SAM model core → Prompt encoder: encodes prompts
segment-anything/segment_anything/modeling/sam.py - SAM model core → Mask decoder: predicts masks
segment-anything/segment_anything/modeling/sam.py - Mask decoder → Two-way transformer: uses transformer
- Image encoder → Model layers: uses layers
segment-anything/segment_anything/modeling/image_encoder.py - Prompt encoder → Model layers: uses layers
segment-anything/segment_anything/modeling/prompt_encoder.py - Mask decoder → Model layers: uses layers
segment-anything/segment_anything/modeling/mask_decoder.py - Two-way transformer → Model layers: uses layers
segment-anything/segment_anything/modeling/transformer.py - Automatic masks → SAM predictor: uses predictor
segment-anything/segment_anything/automatic_mask_generator.py - Automatic masks → Mask utilities: uses utilities
segment-anything/segment_anything/automatic_mask_generator.py - SAM predictor → Image transforms: uses transforms
segment-anything/segment_anything/predictor.py