Georg commited on
Commit
74ae2d1
·
1 Parent(s): 09ba3b6

Prepare job build context

Browse files
Files changed (3) hide show
  1. app.py +1 -52
  2. deploy.sh +21 -29
  3. download_weights.py +3 -1
app.py CHANGED
@@ -536,58 +536,7 @@ with gr.Blocks(title="FoundationPose Inference", theme=gr.themes.Soft()) as demo
536
  outputs=cad_init_output
537
  )
538
 
539
- # Sub-tab 1.2: Model-Free Init
540
- with gr.Tab("Model-Free (Reference-Based)"):
541
- gr.Markdown("""
542
- **Model-Free Mode**: ⚠️ Coming Soon
543
-
544
- This mode would reconstruct a 3D model from reference images using photogrammetry,
545
- but is not yet implemented.
546
-
547
- **Alternative**: Use photogrammetry software to create a mesh first:
548
- - [Meshroom](https://alicevision.org/#meshroom) (free, open-source)
549
- - [COLMAP](https://colmap.github.io/) (free, open-source)
550
- - [RealityCapture](https://www.capturingreality.com/) (commercial)
551
-
552
- Then use the CAD-Based tab with your generated mesh.
553
- """)
554
-
555
- with gr.Row():
556
- with gr.Column():
557
- free_object_id = gr.Textbox(
558
- label="Object ID",
559
- placeholder="e.g., target_cube",
560
- value="target_cube"
561
- )
562
-
563
- free_ref_files = gr.File(
564
- label="Reference Images (16-24 recommended)",
565
- file_count="multiple",
566
- file_types=["image"]
567
- )
568
-
569
- gr.Markdown("### Camera Intrinsics")
570
- with gr.Row():
571
- free_fx = gr.Number(label="fx", value=500.0)
572
- free_fy = gr.Number(label="fy", value=500.0)
573
- with gr.Row():
574
- free_cx = gr.Number(label="cx", value=320.0)
575
- free_cy = gr.Number(label="cy", value=240.0)
576
-
577
- free_init_button = gr.Button("Initialize Model-Free", variant="primary")
578
-
579
- with gr.Column():
580
- free_init_output = gr.Textbox(
581
- label="Initialization Result",
582
- lines=5,
583
- interactive=False
584
- )
585
-
586
- free_init_button.click(
587
- fn=gradio_initialize_model_free,
588
- inputs=[free_object_id, free_ref_files, free_fx, free_fy, free_cx, free_cy],
589
- outputs=free_init_output
590
- )
591
 
592
  # Tab 2: Estimate Pose
593
  with gr.Tab("Estimate Pose"):
 
536
  outputs=cad_init_output
537
  )
538
 
539
+ # Sub-tab 1.2: Model-Free Init (disabled)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
 
541
  # Tab 2: Estimate Pose
542
  with gr.Tab("Estimate Pose"):
deploy.sh CHANGED
@@ -67,7 +67,7 @@ PY
67
  mkdir -p .deploy
68
 
69
  L1_INPUTS=(Dockerfile.base)
70
- L2_INPUTS=(Dockerfile.base)
71
 
72
  L1_HASH=$(hash_files "${L1_INPUTS[@]}")
73
  L2_HASH=$(hash_files "${L2_INPUTS[@]}")
@@ -187,20 +187,16 @@ if [ -n "${JOB_ID}" ] && [ -x "${HF_BIN}" ]; then
187
  for i in $(seq 1 40); do
188
  JOB_STAGE=$("${HF_BIN}" jobs inspect "${JOB_ID}" | python3 -c "import sys, json; data=json.load(sys.stdin)[0]; print(data.get('status', {}).get('stage', 'UNKNOWN'))" 2>/dev/null || echo "UNKNOWN")
189
  echo " Job stage: ${JOB_STAGE}"
190
- case "${JOB_STAGE}" in
191
- SUCCESS|SUCCEEDED|COMPLETED|DONE)
192
- echo " L1 image build job completed"
193
- echo "${L1_HASH}" > "${LAST_L1_HASH_FILE}"
194
- break
195
- ;;
196
- FAILED|ERROR|CANCELED|CANCELLED)
197
- echo "✗ Image build job failed: ${JOB_STAGE}"
198
- exit 1
199
- ;;
200
- *)
201
- sleep 30
202
- ;;
203
- esac
204
  done
205
  fi
206
  fi
@@ -272,20 +268,16 @@ if [ -n "${JOB_ID_L2}" ] && [ -x "${HF_BIN}" ]; then
272
  for i in $(seq 1 60); do
273
  JOB_STAGE=$("${HF_BIN}" jobs inspect "${JOB_ID_L2}" | python3 -c "import sys, json; data=json.load(sys.stdin)[0]; print(data.get('status', {}).get('stage', 'UNKNOWN'))" 2>/dev/null || echo "UNKNOWN")
274
  echo " Job stage: ${JOB_STAGE}"
275
- case "${JOB_STAGE}" in
276
- SUCCESS|SUCCEEDED|COMPLETED|DONE)
277
- echo " L2 image build job completed"
278
- echo "${L2_HASH}" > "${LAST_L2_HASH_FILE}"
279
- break
280
- ;;
281
- FAILED|ERROR|CANCELED|CANCELLED)
282
- echo "✗ L2 image build job failed: ${JOB_STAGE}"
283
- exit 1
284
- ;;
285
- *)
286
- sleep 30
287
- ;;
288
- esac
289
  done
290
  fi
291
  fi
 
67
  mkdir -p .deploy
68
 
69
  L1_INPUTS=(Dockerfile.base)
70
+ L2_INPUTS=(Dockerfile.base Dockerfile download_weights.py)
71
 
72
  L1_HASH=$(hash_files "${L1_INPUTS[@]}")
73
  L2_HASH=$(hash_files "${L2_INPUTS[@]}")
 
187
  for i in $(seq 1 40); do
188
  JOB_STAGE=$("${HF_BIN}" jobs inspect "${JOB_ID}" | python3 -c "import sys, json; data=json.load(sys.stdin)[0]; print(data.get('status', {}).get('stage', 'UNKNOWN'))" 2>/dev/null || echo "UNKNOWN")
189
  echo " Job stage: ${JOB_STAGE}"
190
+ if [[ "${JOB_STAGE}" =~ ^(SUCCESS|SUCCEEDED|COMPLETED|DONE)$ ]]; then
191
+ echo "✓ L1 image build job completed"
192
+ echo "${L1_HASH}" > "${LAST_L1_HASH_FILE}"
193
+ break
194
+ elif [[ "${JOB_STAGE}" =~ ^(FAILED|ERROR|CANCELED|CANCELLED)$ ]]; then
195
+ echo "✗ Image build job failed: ${JOB_STAGE}"
196
+ exit 1
197
+ else
198
+ sleep 30
199
+ fi
 
 
 
 
200
  done
201
  fi
202
  fi
 
268
  for i in $(seq 1 60); do
269
  JOB_STAGE=$("${HF_BIN}" jobs inspect "${JOB_ID_L2}" | python3 -c "import sys, json; data=json.load(sys.stdin)[0]; print(data.get('status', {}).get('stage', 'UNKNOWN'))" 2>/dev/null || echo "UNKNOWN")
270
  echo " Job stage: ${JOB_STAGE}"
271
+ if [[ "${JOB_STAGE}" =~ ^(SUCCESS|SUCCEEDED|COMPLETED|DONE)$ ]]; then
272
+ echo "✓ L2 image build job completed"
273
+ echo "${L2_HASH}" > "${LAST_L2_HASH_FILE}"
274
+ break
275
+ elif [[ "${JOB_STAGE}" =~ ^(FAILED|ERROR|CANCELED|CANCELLED)$ ]]; then
276
+ echo "✗ L2 image build job failed: ${JOB_STAGE}"
277
+ exit 1
278
+ else
279
+ sleep 30
280
+ fi
 
 
 
 
281
  done
282
  fi
283
  fi
download_weights.py CHANGED
@@ -7,15 +7,17 @@ from pathlib import Path
7
  # Always download weights from model repository
8
  repo = os.environ.get('FOUNDATIONPOSE_MODEL_REPO', 'gpue/foundationpose-weights')
9
  token = os.environ.get('HF_TOKEN')
 
10
 
11
  print(f'Downloading weights from {repo}...')
12
 
13
  try:
14
  from huggingface_hub import snapshot_download
15
 
 
16
  snapshot_download(
17
  repo_id=repo,
18
- local_dir='weights',
19
  token=token,
20
  repo_type='model'
21
  )
 
7
  # Always download weights from model repository
8
  repo = os.environ.get('FOUNDATIONPOSE_MODEL_REPO', 'gpue/foundationpose-weights')
9
  token = os.environ.get('HF_TOKEN')
10
+ weights_dir = os.environ.get('FOUNDATIONPOSE_WEIGHTS_DIR', '/app/FoundationPose/weights')
11
 
12
  print(f'Downloading weights from {repo}...')
13
 
14
  try:
15
  from huggingface_hub import snapshot_download
16
 
17
+ Path(weights_dir).mkdir(parents=True, exist_ok=True)
18
  snapshot_download(
19
  repo_id=repo,
20
+ local_dir=weights_dir,
21
  token=token,
22
  repo_type='model'
23
  )