Spaces:
Sleeping
Sleeping
陳俞蒨
commited on
Commit
·
98b93f0
1
Parent(s):
4df43e2
add docker related files
Browse files- Dockerfile +20 -0
- app.py +1 -10
- requirements.txt +4 -0
- segmentation.py +0 -4
Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 使用 Python 官方鏡像 (3.9-slim)
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# 設置工作目錄
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# 安裝系統依賴(解決 opencv-python 問題)
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
libgl1-mesa-glx libglib2.0-0 && \
|
| 10 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# 複製依賴文件並安裝依賴
|
| 13 |
+
COPY requirements.txt .
|
| 14 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# 複製應用程式代碼到容器
|
| 17 |
+
COPY segmentation.py app.py /app/
|
| 18 |
+
|
| 19 |
+
# 指定容器啟動時的執行指令
|
| 20 |
+
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -1,13 +1,4 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
import gradio as gr
|
| 3 |
-
import sys, time
|
| 4 |
-
import ipywidgets as widget
|
| 5 |
-
from IPython.display import display
|
| 6 |
-
import numpy as np
|
| 7 |
-
import cv2
|
| 8 |
-
from PIL import Image as PIL_Image
|
| 9 |
-
from io import BytesIO
|
| 10 |
-
import matplotlib.pyplot as plt
|
| 11 |
from segmentation import ImageSegmentation
|
| 12 |
|
| 13 |
|
|
@@ -35,4 +26,4 @@ with gr.Blocks() as demo:
|
|
| 35 |
image_button.click(image_segmentation, inputs=[image_input, temp_slider], outputs=image_output)
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
-
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from segmentation import ImageSegmentation
|
| 3 |
|
| 4 |
|
|
|
|
| 26 |
image_button.click(image_segmentation, inputs=[image_input, temp_slider], outputs=image_output)
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
numpy
|
| 3 |
+
Opencv-python
|
| 4 |
+
pillow
|
segmentation.py
CHANGED
|
@@ -1,11 +1,7 @@
|
|
| 1 |
-
import sys, time
|
| 2 |
-
import ipywidgets as widget
|
| 3 |
-
from IPython.display import display
|
| 4 |
import numpy as np
|
| 5 |
import cv2
|
| 6 |
from PIL import Image as PIL_Image
|
| 7 |
from io import BytesIO
|
| 8 |
-
import matplotlib.pyplot as plt
|
| 9 |
|
| 10 |
class ImageSegmentation():
|
| 11 |
def __init__(self, x, threshold_factor):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import cv2
|
| 3 |
from PIL import Image as PIL_Image
|
| 4 |
from io import BytesIO
|
|
|
|
| 5 |
|
| 6 |
class ImageSegmentation():
|
| 7 |
def __init__(self, x, threshold_factor):
|