tapas0A commited on
Commit
3657fc2
·
1 Parent(s): 689a171

Upload with huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +11 -0
  2. app.py +9 -0
  3. requirements.txt +2 -0
  4. test.py +10 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.8-slim-buster
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+
7
+ RUN pip3 install --no-cache-dir -r requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["python3", "app.py"]
app.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+
4
+ def color_to_bw(image):
5
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
6
+ return gray
7
+
8
+ iface = gr.Interface(fn=color_to_bw, inputs="image", outputs="image")
9
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ opencv-python-headless
test.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ from app import color_to_bw
4
+
5
+ def test_color_to_bw():
6
+ image = cv2.imread("test_image.jpg")
7
+ expected_output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
8
+ assert np.array_equal(color_to_bw(image), expected_output)
9
+
10
+ test_color_to_bw()