Spaces:
Sleeping
Sleeping
add pytorch cuda
Browse files- Dockerfile +25 -0
- app.py +1 -0
- requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
|
| 7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
# Set up a new user named "user" with user ID 1000
|
| 10 |
+
RUN useradd -m -u 1000 user
|
| 11 |
+
|
| 12 |
+
# Switch to the "user" user
|
| 13 |
+
USER user
|
| 14 |
+
|
| 15 |
+
# Set home to the user's home directory
|
| 16 |
+
ENV HOME=/home/user \
|
| 17 |
+
PATH=/home/user/.local/bin:$PATH
|
| 18 |
+
|
| 19 |
+
# Set the working directory to the user's home directory
|
| 20 |
+
WORKDIR $HOME/app
|
| 21 |
+
|
| 22 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 23 |
+
COPY --chown=user . $HOME/app
|
| 24 |
+
|
| 25 |
+
CMD ["python", "main.py"]
|
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import gradio as gr
|
|
| 5 |
model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3")
|
| 6 |
|
| 7 |
if torch.cuda.is_available():
|
|
|
|
| 8 |
model = model.cuda()
|
| 9 |
|
| 10 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
|
|
|
| 5 |
model = torch.hub.load("PeterL1n/RobustVideoMatting", "mobilenetv3")
|
| 6 |
|
| 7 |
if torch.cuda.is_available():
|
| 8 |
+
print("Using GPU")
|
| 9 |
model = model.cuda()
|
| 10 |
|
| 11 |
convert_video = torch.hub.load("PeterL1n/RobustVideoMatting", "converter")
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
av
|
|
|
|
| 2 |
torch==2.1.0
|
| 3 |
torchaudio==2.1.0
|
| 4 |
torchvision==0.16.0
|
|
|
|
| 1 |
av
|
| 2 |
+
--extra-index-url https://download.pytorch.org/whl/cu113
|
| 3 |
torch==2.1.0
|
| 4 |
torchaudio==2.1.0
|
| 5 |
torchvision==0.16.0
|