fix
Browse files- Dockerfile +0 -35
- app.py +22 -0
Dockerfile
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
# Use a lightweight Python base image
|
2 |
-
FROM python:3.10-slim
|
3 |
-
|
4 |
-
# Set environment variables
|
5 |
-
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
-
ENV PYTHONUNBUFFERED=1
|
7 |
-
|
8 |
-
# Set working directory
|
9 |
-
WORKDIR /app
|
10 |
-
|
11 |
-
# Install system dependencies
|
12 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
13 |
-
git \
|
14 |
-
build-essential \
|
15 |
-
&& rm -rf /var/lib/apt/lists/*
|
16 |
-
|
17 |
-
# Install PyTorch CPU version
|
18 |
-
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
19 |
-
|
20 |
-
# Copy the segment-anything-2 repo and install it in editable mode
|
21 |
-
COPY segment-anything-2 ./segment-anything-2
|
22 |
-
RUN pip install -e ./segment-anything-2
|
23 |
-
|
24 |
-
# Copy the manual requirements and install them without dependencies
|
25 |
-
COPY requirements_manual.txt .
|
26 |
-
RUN pip install --no-deps -r requirements_manual.txt
|
27 |
-
|
28 |
-
# Copy rest of the app
|
29 |
-
COPY . .
|
30 |
-
|
31 |
-
# Expose Gradio/Streamlit default port
|
32 |
-
EXPOSE 7860
|
33 |
-
|
34 |
-
# Start the app (adjust depending on whether you're using Gradio or Streamlit)
|
35 |
-
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
@@ -7,6 +28,7 @@ from io import BytesIO
|
|
7 |
|
8 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
9 |
|
|
|
10 |
# Dummy placeholders for SAM2 functions (replace with real logic)
|
11 |
def segment_reference(image, click):
|
12 |
# click = [x, y]
|
|
|
1 |
+
import subprocess
|
2 |
+
|
3 |
+
def setup_deps():
|
4 |
+
print("Setting up dependencies...")
|
5 |
+
try:
|
6 |
+
import torch
|
7 |
+
# Already installed? Skip setup
|
8 |
+
return
|
9 |
+
except ImportError:
|
10 |
+
pass
|
11 |
+
|
12 |
+
def run(cmd, cwd=None):
|
13 |
+
print(f"▶ {cmd}")
|
14 |
+
subprocess.check_call(cmd, shell=True, cwd=cwd)
|
15 |
+
|
16 |
+
run("pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu")
|
17 |
+
run("pip install -e .", cwd="segment-anything-2")
|
18 |
+
run("pip install --no-deps -r requirements_manual.txt")
|
19 |
+
|
20 |
+
setup_deps()
|
21 |
+
|
22 |
import gradio as gr
|
23 |
import numpy as np
|
24 |
from PIL import Image
|
|
|
28 |
|
29 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
30 |
|
31 |
+
|
32 |
# Dummy placeholders for SAM2 functions (replace with real logic)
|
33 |
def segment_reference(image, click):
|
34 |
# click = [x, y]
|