arithescientist commited on
Commit
25d2b8d
Β·
verified Β·
1 Parent(s): 3e4a61c

Upload 7 files

Browse files
Files changed (4) hide show
  1. Dockerfile +10 -8
  2. app.py +14 -10
  3. quick-deploy.sh +24 -41
  4. requirements.txt +2 -4
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM nvidia/cuda:12.4.0-devel-ubuntu22.04
2
 
3
  # Basic deps
4
  ENV DEBIAN_FRONTEND=noninteractive
@@ -7,22 +7,24 @@ RUN apt-get update && apt-get install -y \
7
  colmap \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # Create venv and install nerfstudio + api deps
11
  RUN python3.10 -m venv /opt/venv
12
  ENV PATH="/opt/venv/bin:$PATH"
13
  RUN pip install --upgrade pip wheel
14
 
15
- # Install requirements
16
- COPY requirements.txt /tmp/requirements.txt
17
- RUN pip install -r /tmp/requirements.txt
18
 
19
- # Workdir
 
20
  WORKDIR /app
21
- COPY . /app
22
 
23
  # For GPU
24
  ENV NVIDIA_VISIBLE_DEVICES=all
25
  ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
26
 
 
27
  EXPOSE 8000 7860
28
- CMD ["python", "app.py"]
 
 
 
1
+ FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
2
 
3
  # Basic deps
4
  ENV DEBIAN_FRONTEND=noninteractive
 
7
  colmap \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Create venv and install minimal deps
11
  RUN python3.10 -m venv /opt/venv
12
  ENV PATH="/opt/venv/bin:$PATH"
13
  RUN pip install --upgrade pip wheel
14
 
15
+ # Install only essential packages first
16
+ RUN pip install fastapi uvicorn python-multipart gradio
 
17
 
18
+ # Copy app
19
+ COPY app.py /app/app.py
20
  WORKDIR /app
 
21
 
22
  # For GPU
23
  ENV NVIDIA_VISIBLE_DEVICES=all
24
  ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
25
 
26
+ # Expose ports
27
  EXPOSE 8000 7860
28
+
29
+ # Start command
30
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -39,6 +39,12 @@ async def upload(file: UploadFile = File(...)):
39
  if has_transforms:
40
  shutil.copytree(raw_dir, proc_dir, dirs_exist_ok=True)
41
  else:
 
 
 
 
 
 
42
  run([
43
  "ns-process-data", "images",
44
  "--data", str(raw_dir / "images"),
@@ -81,7 +87,7 @@ async def upload(file: UploadFile = File(...)):
81
  files = [str(p.name) for p in exp_dir.glob("*.ply")]
82
  return {"job_id": job_id, "status": "done", "files": files}
83
 
84
- # Gradio interface for Hugging Face Spaces
85
  def process_dataset(uploaded_file):
86
  if uploaded_file is None:
87
  return "Please upload a dataset zip file"
@@ -93,7 +99,7 @@ def process_dataset(uploaded_file):
93
  except Exception as e:
94
  return f"Error: {str(e)}"
95
 
96
- # Create Gradio interface
97
  with gr.Blocks(title="Intercept 2.0 - 3D Gaussian Splatting") as demo:
98
  gr.Markdown("# πŸš€ Intercept 2.0 - 3D Gaussian Splatting")
99
  gr.Markdown("Upload your dataset zip file to train a 3D Gaussian Splat")
@@ -112,14 +118,12 @@ with gr.Blocks(title="Intercept 2.0 - 3D Gaussian Splatting") as demo:
112
  outputs=[output]
113
  )
114
 
115
- # Run both FastAPI and Gradio
 
 
 
 
116
  if __name__ == "__main__":
117
  import threading
118
-
119
- # Start FastAPI in background
120
- def run_fastapi():
121
- uvicorn.run(app, host="0.0.0.0", port=8000)
122
-
123
- # Start Gradio
124
  threading.Thread(target=run_fastapi, daemon=True).start()
125
- demo.launch(server_port=7860, share=True)
 
39
  if has_transforms:
40
  shutil.copytree(raw_dir, proc_dir, dirs_exist_ok=True)
41
  else:
42
+ # Install nerfstudio on demand
43
+ try:
44
+ run(["pip", "install", "nerfstudio>=1.0.0"])
45
+ except:
46
+ pass
47
+
48
  run([
49
  "ns-process-data", "images",
50
  "--data", str(raw_dir / "images"),
 
87
  files = [str(p.name) for p in exp_dir.glob("*.ply")]
88
  return {"job_id": job_id, "status": "done", "files": files}
89
 
90
+ # Simple Gradio interface for Hugging Face Spaces
91
  def process_dataset(uploaded_file):
92
  if uploaded_file is None:
93
  return "Please upload a dataset zip file"
 
99
  except Exception as e:
100
  return f"Error: {str(e)}"
101
 
102
+ # Create simple Gradio interface
103
  with gr.Blocks(title="Intercept 2.0 - 3D Gaussian Splatting") as demo:
104
  gr.Markdown("# πŸš€ Intercept 2.0 - 3D Gaussian Splatting")
105
  gr.Markdown("Upload your dataset zip file to train a 3D Gaussian Splat")
 
118
  outputs=[output]
119
  )
120
 
121
+ # Start FastAPI in background
122
+ def run_fastapi():
123
+ uvicorn.run(app, host="0.0.0.0", port=8000)
124
+
125
+ # Start both services
126
  if __name__ == "__main__":
127
  import threading
 
 
 
 
 
 
128
  threading.Thread(target=run_fastapi, daemon=True).start()
129
+ demo.launch(server_port=7860, share=True)
quick-deploy.sh CHANGED
@@ -1,50 +1,33 @@
1
  #!/bin/bash
2
 
3
- # Quick Hugging Face Deployment for Intercept 2.0
4
- # This script does everything automatically
 
5
 
6
- echo "πŸš€ Intercept 2.0 - Hugging Face Deployment"
7
- echo "============================================="
8
-
9
- # Check if huggingface_hub is installed
10
- if ! python -c "import huggingface_hub" 2>/dev/null; then
11
- echo "πŸ“¦ Installing huggingface_hub..."
12
- pip install huggingface_hub
13
- fi
14
-
15
- # Check if user is logged in
16
- if ! huggingface-cli whoami &> /dev/null; then
17
- echo "❌ Not logged in to Hugging Face."
18
- echo "πŸ”‘ Please login first:"
19
- echo " huggingface-cli login"
20
- echo ""
21
- echo "πŸ’‘ Get your token from: https://huggingface.co/settings/tokens"
22
  exit 1
23
  fi
24
 
25
- # Get username
26
- USERNAME=$(huggingface-cli whoami)
27
- echo "πŸ‘€ Logged in as: $USERNAME"
28
-
29
- # Create space name
30
- SPACE_NAME="intercept-2.0"
31
- echo "πŸ“¦ Creating space: $SPACE_NAME"
32
-
33
- # Create the space
34
- echo "πŸš€ Creating Hugging Face Space..."
35
- huggingface-cli repo create $SPACE_NAME --type space --sdk docker
36
-
37
- # Upload files
38
- echo "πŸ“ Uploading files to space..."
39
- huggingface-cli upload $SPACE_NAME app.py
40
- huggingface-cli upload $SPACE_NAME requirements.txt
41
- huggingface-cli upload $SPACE_NAME Dockerfile
42
- huggingface-cli upload $SPACE_NAME README.md
43
 
 
 
44
  echo ""
45
- echo "βœ… Deployment complete!"
46
- echo "🌐 Your space: https://huggingface.co/spaces/$USERNAME/$SPACE_NAME"
47
- echo "πŸ“± API endpoint: https://$USERNAME-$SPACE_NAME.hf.space/upload"
 
 
48
  echo ""
49
- echo "⏱️ The space will take 5-10 minutes to build and start"
50
- echo "πŸ“± Update your iOS app's server URL to the API endpoint above"
 
 
 
 
1
  #!/bin/bash
2
 
3
+ # Quick deploy to Hugging Face Spaces
4
+ echo "πŸš€ Quick Deploy to Hugging Face Spaces"
5
+ echo "======================================"
6
 
7
+ # Check if we're in the right directory
8
+ if [ ! -f "app.py" ]; then
9
+ echo "❌ Error: app.py not found. Run this from the huggingface/ directory"
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  exit 1
11
  fi
12
 
13
+ echo "πŸ“ Files to upload:"
14
+ echo " - app.py"
15
+ echo " - Dockerfile"
16
+ echo " - requirements.txt"
17
+ echo " - README.md"
18
+ echo ""
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ echo "πŸ”— Upload these files to your Hugging Face Space:"
21
+ echo " https://huggingface.co/spaces/arithescientist/intercept"
22
  echo ""
23
+
24
+ echo "βœ… This simplified version should start much faster!"
25
+ echo " - No nerfstudio at startup (installed on demand)"
26
+ echo " - Minimal dependencies"
27
+ echo " - Faster container startup"
28
  echo ""
29
+
30
+ echo "πŸ“ Next steps:"
31
+ echo "1. Upload the files above to your HF Space"
32
+ echo "2. Wait for build to complete"
33
+ echo "3. Test with your iOS app"
requirements.txt CHANGED
@@ -1,6 +1,4 @@
1
- nerfstudio>=1.0.0
2
- uvicorn
3
  fastapi
4
- pydantic[dotenv]
5
  python-multipart
6
- gradio
 
 
 
1
  fastapi
2
+ uvicorn
3
  python-multipart
4
+ gradio