Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
data/
output/
checkpoints/

# Byte-compiled / optimized / DLL files
Expand Down
2 changes: 2 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
else:
weights_path = "naver/" + args.model_name
model = AsymmetricCroCo3DStereo.from_pretrained(weights_path).to(args.device)

print(f"Hosting on {server_name}:{args.server_port}")

# dust3r will write the 3D model inside tmpdirname
with tempfile.TemporaryDirectory(suffix='dust3r_gradio_demo') as tmpdirname:
Expand Down
6 changes: 5 additions & 1 deletion docker/docker-compose-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ services:
environment:
- DEVICE=cuda
- MODEL=${MODEL:-DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth}
- PYTHONPATH=/dust3r # <--- ADD THIS LINE
volumes:
- ./files/checkpoints:/dust3r/checkpoints
- ./files/checkpoints:/checkpoints
- ./files/data:/data
- ./files/output:/output
- ../:/dust3r
cap_add:
- IPC_LOCK
- SYS_RESOURCE
Expand Down
2 changes: 2 additions & 0 deletions docker/files/cuda.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RUN pip install opencv-python==4.8.0.74
WORKDIR /dust3r/croco/models/curope/
RUN python setup.py build_ext --inplace

RUN pip install boto3 zstandard

WORKDIR /dust3r
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand Down
3 changes: 2 additions & 1 deletion docker/files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ set -eux
DEVICE=${DEVICE:-cuda}
MODEL=${MODEL:-DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth}

exec python3 demo.py --weights "checkpoints/$MODEL" --device "$DEVICE" --local_network "$@"
# Keep the container running for debugging
tail -f /dev/null
6 changes: 4 additions & 2 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ set_dcomp() {
run_docker() {
export MODEL=${model_name}
if [ "$with_cuda" -eq 1 ]; then
$dcomp -f docker-compose-cuda.yml up --build
$dcomp -f docker-compose-cuda.yml up --build -d
else
$dcomp -f docker-compose-cpu.yml up --build
$dcomp -f docker-compose-cpu.yml up --build -d
fi
echo "Docker container started in detached mode."
echo "To attach to the container, run: $dcomp exec dust3r-demo /bin/bash"
}

with_cuda=0
Expand Down
67 changes: 67 additions & 0 deletions dust3r/analysis_scale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import pandas as pd
import matplotlib.pyplot as plt
import argparse

def plot_scale_statistics(results_path):
"""Plot scale statistics from benchmark results.

Args:
results_path: Path to the CSV file containing benchmark results
"""
# Read the results
df = pd.read_csv(results_path)

# Create figure with subplots
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 10))

# Plot 1: Scale factors over items
ax1.plot(df['item_id'], df['optimal_scale'], 'b.', alpha=0.5, label='Scale factors')
ax1.axhline(y=df['optimal_scale'].mean(), color='r', linestyle='--', label=f'Mean: {df["optimal_scale"].mean():.2f}')
ax1.set_xlabel('Item ID')
ax1.set_ylabel('Optimal Scale')
ax1.set_title('Scale Factors Distribution')
ax1.legend()
ax1.grid(True)

# Plot 2: Histogram of scale factors
ax2.hist(df['optimal_scale'], bins=30, alpha=0.7, color='b')
ax2.axvline(x=df['optimal_scale'].mean(), color='r', linestyle='--',
label=f'Mean: {df["optimal_scale"].mean():.2f}')
ax2.axvline(x=df['optimal_scale'].median(), color='g', linestyle='--',
label=f'Median: {df["optimal_scale"].median():.2f}')
ax2.set_xlabel('Scale Factor')
ax2.set_ylabel('Frequency')
ax2.set_title('Histogram of Scale Factors')
ax2.legend()
ax2.grid(True)

plt.tight_layout()
output_path = os.path.join(os.path.dirname(results_path), 'scale_statistics.png')
plt.savefig(output_path)
plt.close()

# Print statistics
print("\nScale Factor Statistics:")
print(f"Mean: {df['optimal_scale'].mean():.3f}")
print(f"Median: {df['optimal_scale'].median():.3f}")
print(f"Std: {df['optimal_scale'].std():.3f}")
print(f"Min: {df['optimal_scale'].min():.3f}")
print(f"Max: {df['optimal_scale'].max():.3f}")
print(f"25th percentile: {df['optimal_scale'].quantile(0.25):.3f}")
print(f"75th percentile: {df['optimal_scale'].quantile(0.75):.3f}")

def main():
parser = argparse.ArgumentParser(description="Analyze scale factors from DUSt3R benchmark results.")
parser.add_argument('--results', type=str, required=True, help='Path to the benchmark results CSV file.')

args = parser.parse_args()

if not os.path.exists(args.results):
print(f"Results file not found at {args.results}")
return

plot_scale_statistics(args.results)

if __name__ == "__main__":
main()
Loading