Spaces:
Runtime error
Runtime error
Ansal
commited on
Commit
·
bf70391
1
Parent(s):
c1c8d6f
working finally
Browse files- Dockerfile +2 -8
- app.py +6 -3
- model.pth +0 -3
- requirements.txt +11 -10
Dockerfile
CHANGED
@@ -1,15 +1,10 @@
|
|
1 |
-
FROM python:3.
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
5 |
COPY ./requirements.txt /code/requirements.txt
|
6 |
|
7 |
-
RUN pip install
|
8 |
-
|
9 |
-
RUN apt-get update && \
|
10 |
-
apt-get install -y git-lfs && \
|
11 |
-
rm -rf /var/lib/apt/lists/* && \
|
12 |
-
git lfs install
|
13 |
|
14 |
COPY . .
|
15 |
|
@@ -19,6 +14,5 @@ USER root
|
|
19 |
RUN mkdir -p /.cache
|
20 |
RUN chmod 777 /.cache
|
21 |
RUN chmod 777 /code/*
|
22 |
-
USER user
|
23 |
|
24 |
CMD ["shiny", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
FROM python:3.11
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
5 |
COPY ./requirements.txt /code/requirements.txt
|
6 |
|
7 |
+
RUN pip install -r ./requirements.txt
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
COPY . .
|
10 |
|
|
|
14 |
RUN mkdir -p /.cache
|
15 |
RUN chmod 777 /.cache
|
16 |
RUN chmod 777 /code/*
|
|
|
17 |
|
18 |
CMD ["shiny", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
@@ -32,9 +32,9 @@ def server(input: Inputs, output: Outputs, session: Session):
|
|
32 |
return None
|
33 |
|
34 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
35 |
-
model2 = AutoModel.from_pretrained("ansal/sidewalk-segment")
|
36 |
model2.eval()
|
37 |
-
model2.to(
|
38 |
|
39 |
image = Image.open(file[0]["datapath"]).convert('RGB')
|
40 |
transform = image_resize_transform
|
@@ -47,7 +47,10 @@ def server(input: Inputs, output: Outputs, session: Session):
|
|
47 |
|
48 |
mask_tensor = predicted_masks.cpu().detach().squeeze()
|
49 |
mask_array = mask_tensor.numpy()
|
50 |
-
mask_array = (mask_array
|
|
|
|
|
|
|
51 |
mask = Image.fromarray(mask_array)
|
52 |
mask = mask.resize((1024, 1024), Image.LANCZOS)
|
53 |
mask = mask.convert('RGBA')
|
|
|
32 |
return None
|
33 |
|
34 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
35 |
+
model2 = AutoModel.from_pretrained("ansal/sidewalk-segment", device_map = 'cpu')
|
36 |
model2.eval()
|
37 |
+
model2.to('cpu')
|
38 |
|
39 |
image = Image.open(file[0]["datapath"]).convert('RGB')
|
40 |
transform = image_resize_transform
|
|
|
47 |
|
48 |
mask_tensor = predicted_masks.cpu().detach().squeeze()
|
49 |
mask_array = mask_tensor.numpy()
|
50 |
+
mask_array = np.nan_to_num(mask_array)
|
51 |
+
mask_array = mask_array * 255
|
52 |
+
mask_array = np.clip(mask_array, 0, 255)
|
53 |
+
mask_array = mask_array.astype(np.uint8)
|
54 |
mask = Image.fromarray(mask_array)
|
55 |
mask = mask.resize((1024, 1024), Image.LANCZOS)
|
56 |
mask = mask.convert('RGBA')
|
model.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:41049da640c5d9c033ea78378413bbf9f299bd17f989c8ebd126b7a66b5aa1e1
|
3 |
-
size 375067302
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
-
shiny
|
2 |
-
shinywidgets
|
3 |
-
ipyleaflet
|
4 |
-
geopy
|
5 |
-
faicons
|
6 |
-
requests
|
7 |
-
Pillow
|
8 |
-
torch
|
9 |
-
numpy
|
10 |
transformers
|
11 |
-
torchvision
|
|
|
|
1 |
+
shiny==0.9.0
|
2 |
+
shinywidgets==0.3.2
|
3 |
+
ipyleaflet==0.19.0
|
4 |
+
geopy==2.4.1
|
5 |
+
faicons==0.2.2
|
6 |
+
requests==2.31.0
|
7 |
+
Pillow==10.0.0
|
8 |
+
torch==2.1.1
|
9 |
+
numpy==1.24.3
|
10 |
transformers
|
11 |
+
torchvision==0.16.1
|
12 |
+
accelerate==0.30.0
|