Skip to content

Commit 5a7ab34

Browse files
committed
renamed main to demo and updated script
1 parent d7a7125 commit 5a7ab34

4 files changed

Lines changed: 56 additions & 58 deletions

File tree

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ For installing deep-image-matching, we recommend using [uv](https://docs.astral.
7070
curl -LsSf https://astral.sh/uv/install.sh | sh
7171

7272
# Create and activate a virtual environment
73-
uv venv deep-image-matching --python 3.9
73+
uv venv --python 3.9
7474
source .venv/bin/activate # On Windows: .venv\Scripts\activate
7575
```
7676

7777
Then, you can install deep-image-matching using uv:
7878

7979
```bash
80-
uv pip install deep-image-matching
80+
uv pip install -e .
8181
```
8282

83+
This command will install the package in editable mode, allowing you to modify the source code and see changes immediately without needing to reinstall. If you want to use deep-image-matching as a non-editable library, you can also install it without the `-e` flag.
84+
8385
If there is any issue with the installation, you can also install the package from the source code.
8486
Clone the repository and install deep-image-matching in development mode:
8587

@@ -97,12 +99,18 @@ uv pip install pycolmap==0.6.1
9799

98100
Pycolmap is optional to run reconstruction directly in DIM. If pycolmap is not available, matches will be written both in a h5 and colmap database for later processing with COLMAP GUI or API, or other processing.
99101

100-
Try to run the tests to check if deep-image-matching is correctly installed, try to import the package in a Python shell:
102+
To verify that deep-image-matching is correctly installed, you can try to import the package in a Python shell:
101103

102104
```python
103105
import deep_image_matching as dim
104106
```
105107

108+
To test most of the functionality, run the tests to check if deep-image-matching is correctly installed, run:
109+
110+
```bash
111+
uv pytest tests
112+
```
113+
106114
For more information, check the [documentation](https://3dom-fbk.github.io/deep-image-matching/installation/).
107115

108116
### Why uv?
@@ -129,7 +137,7 @@ pip install deep-image-matching
129137

130138
If you prefer using Docker, first, build the image:
131139

132-
```
140+
```bash
133141
docker build --tag deep-image-matching .
134142
```
135143

@@ -138,13 +146,13 @@ Note that the first time you run the command, it will take a while to download t
138146
Once the image is built, you can run it with the following commands.
139147
On Linux:
140148

141-
```
149+
```bash
142150
docker run --name run-deep-image-matching --mount type=bind,source=/home/username/data,target=/workspace/data --gpus all -it deep-image-matching
143151
```
144152

145153
On Windows (please use Powershell):
146154

147-
```
155+
```powershell
148156
docker run --name run-deep-image-matching --mount type=bind,source=D:\data,target=/workspace/data --gpus all -it deep-image-matching
149157
```
150158

demo.ipynb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"name": "stdout",
2424
"output_type": "stream",
2525
"text": [
26-
"Deep Image Matching loaded in 10.390 seconds.\n"
26+
"Deep Image Matching loaded in 4.188 seconds.\n",
27+
"\u001b[1;33m2025-07-02 17:09:13 | [WARNING ] assets/example_cyprus/results_superpoint+lightglue_matching_lowres_quality_medium already exists, but the '--force' option is used. Deleting the folder.\u001b[0m\n"
2728
]
2829
}
2930
],
@@ -46,12 +47,12 @@
4647
"cell_type": "markdown",
4748
"metadata": {},
4849
"source": [
49-
"Run feature extraction and matching"
50+
"Run feature extraction and matching\n"
5051
]
5152
},
5253
{
5354
"cell_type": "code",
54-
"execution_count": 2,
55+
"execution_count": null,
5556
"metadata": {},
5657
"outputs": [
5758
{
@@ -235,12 +236,12 @@
235236
"cell_type": "markdown",
236237
"metadata": {},
237238
"source": [
238-
"Export matches to COLMAP format"
239+
"Export matches to COLMAP format\n"
239240
]
240241
},
241242
{
242243
"cell_type": "code",
243-
"execution_count": 3,
244+
"execution_count": null,
244245
"metadata": {},
245246
"outputs": [
246247
{
@@ -275,12 +276,12 @@
275276
"cell_type": "markdown",
276277
"metadata": {},
277278
"source": [
278-
"Run reconstruction with pycolmap"
279+
"Run reconstruction with pycolmap\n"
279280
]
280281
},
281282
{
282283
"cell_type": "code",
283-
"execution_count": 4,
284+
"execution_count": null,
284285
"metadata": {},
285286
"outputs": [
286287
{
@@ -373,7 +374,7 @@
373374
],
374375
"metadata": {
375376
"kernelspec": {
376-
"display_name": "Python 3",
377+
"display_name": "deep-image-matching (3.9.23)",
377378
"language": "python",
378379
"name": "python3"
379380
},

demo.py

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,38 @@
5151
except ImportError:
5252
logger.error("pyvis is not available. Unable to visualize view graph.")
5353

54-
# If --skip_reconstruction is not specified, run reconstruction
54+
# If --skip_reconstruction is not specified, run reconstruction with pycolmap
55+
if not config.general["skip_reconstruction"]:
56+
from deep_image_matching.reconstruction import pycolmap_reconstruction
57+
58+
# Optional - You can specify some reconstruction configuration
59+
# reconst_opts = (
60+
# {
61+
# "ba_refine_focal_length": True,
62+
# "ba_refine_principal_point": False,
63+
# "ba_refine_extra_params": False,
64+
# },
65+
# )
66+
reconst_opts = {}
67+
refine_intrinsics = config.general.get("refine_intrinsics", True)
68+
69+
# Run reconstruction
70+
model = pycolmap_reconstruction(
71+
database_path=output_dir / "database.db",
72+
sfm_dir=output_dir,
73+
image_dir=imgs_dir,
74+
options=reconst_opts,
75+
verbose=config.general["verbose"],
76+
refine_intrinsics=refine_intrinsics,
77+
)
78+
5579
# Export in openMVG format
5680
if config.general["openmvg_conf"]:
5781
with open(config.general["openmvg_conf"]) as file:
5882
openmvgcfg = yaml.safe_load(file)
5983
openmvg_sfm_bin = openmvgcfg["general"]["path_to_binaries"]
6084
openmvg_database = openmvgcfg["general"]["openmvg_database"]
6185
openmvg_out_path = output_dir / "openmvg"
62-
6386
dim.io.export_to_openmvg(
6487
img_dir=imgs_dir,
6588
feature_path=feature_path,
@@ -70,46 +93,12 @@
7093
camera_config_path=config.general["camera_options"],
7194
)
7295

73-
# Reconstruction with OpenMVG
74-
reconstruction = import_module("deep_image_matching.openmvg_reconstruction")
75-
reconstruction.main(
76-
openmvg_out_path=openmvg_out_path,
77-
skip_reconstruction=config.general["skip_reconstruction"],
78-
openmvg_sfm_bin=openmvg_sfm_bin,
79-
)
96+
# If skip_reconstruction is not specified, run OpenMVG reconstruction
97+
if not config.general["skip_reconstruction"]:
98+
from deep_image_matching.openmvg import openmvg_reconstruction
8099

81-
# Reconstruction with pycolmap
82-
if not config.general["skip_reconstruction"]:
83-
use_pycolmap = True
84-
try:
85-
# To be sure, check if pycolmap is available, otherwise skip reconstruction
86-
pycolmap = import_module("pycolmap")
87-
logger.info(f"Using pycolmap version {pycolmap.__version__}")
88-
except ImportError:
89-
logger.error("Pycomlap is not available.")
90-
use_pycolmap = False
91-
92-
if use_pycolmap:
93-
# import reconstruction module
94-
reconstruction = import_module("deep_image_matching.reconstruction")
95-
96-
# Optional - You can specify some reconstruction configuration
97-
# reconst_opts = (
98-
# {
99-
# "ba_refine_focal_length": True,
100-
# "ba_refine_principal_point": False,
101-
# "ba_refine_extra_params": False,
102-
# },
103-
# )
104-
reconst_opts = {}
105-
refine_intrinsics = config.general.get("refine_intrinsics", True)
106-
107-
# Run reconstruction
108-
model = reconstruction.pycolmap_reconstruction(
109-
database_path=output_dir / "database.db",
110-
sfm_dir=output_dir,
111-
image_dir=imgs_dir,
112-
options=reconst_opts,
113-
verbose=config.general["verbose"],
114-
refine_intrinsics=refine_intrinsics,
100+
openmvg_reconstruction(
101+
openmvg_out_path=openmvg_out_path,
102+
skip_reconstruction=config.general["skip_reconstruction"],
103+
openmvg_sfm_bin=openmvg_sfm_bin,
115104
)

src/deep_image_matching/openmvg_reconstruction.py renamed to src/deep_image_matching/openmvg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .constants import logger
88

99

10-
def main(
10+
def openmvg_reconstruction(
1111
openmvg_out_path: Path,
1212
skip_reconstruction: bool,
1313
openmvg_sfm_bin: Path = None,

0 commit comments

Comments
 (0)