Spaces:
Sleeping
Sleeping
Jon Taylor
commited on
Commit
•
0ce0c17
1
Parent(s):
e606d44
fixed dotend req
Browse files- Dockerfile +6 -7
- app/bot.py +3 -4
- app/pipeline.py +2 -2
- requirements.txt +1 -1
Dockerfile
CHANGED
@@ -5,6 +5,10 @@ ARG DEBIAN_FRONTEND=noninteractive
|
|
5 |
ENV PYTHONUNBUFFERED=1
|
6 |
ENV NODE_MAJOR=20
|
7 |
|
|
|
|
|
|
|
|
|
8 |
RUN apt-get update && apt-get install --no-install-recommends -y \
|
9 |
build-essential \
|
10 |
python3.9 \
|
@@ -23,15 +27,11 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg -
|
|
23 |
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null
|
24 |
RUN apt-get update && apt-get install nodejs -y
|
25 |
|
26 |
-
# Expose Flask port
|
27 |
-
ENV FAST_API_PORT=7860
|
28 |
-
EXPOSE 7860
|
29 |
-
|
30 |
# Install Python dependencies
|
31 |
COPY ./requirements.txt /code/requirements.txt
|
32 |
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
|
33 |
|
34 |
-
# Copy package.json and package-lock.json
|
35 |
COPY frontend/package*.json frontend/
|
36 |
RUN cd frontend && npm install
|
37 |
|
@@ -44,5 +44,4 @@ COPY app/ app/
|
|
44 |
COPY server.py server.py
|
45 |
|
46 |
#ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
|
47 |
-
|
48 |
-
CMD ["python3", "app/pipeline_test.py"]
|
|
|
5 |
ENV PYTHONUNBUFFERED=1
|
6 |
ENV NODE_MAJOR=20
|
7 |
|
8 |
+
# Expose Flask port
|
9 |
+
ENV FAST_API_PORT=7860
|
10 |
+
EXPOSE 7860
|
11 |
+
|
12 |
RUN apt-get update && apt-get install --no-install-recommends -y \
|
13 |
build-essential \
|
14 |
python3.9 \
|
|
|
27 |
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null
|
28 |
RUN apt-get update && apt-get install nodejs -y
|
29 |
|
|
|
|
|
|
|
|
|
30 |
# Install Python dependencies
|
31 |
COPY ./requirements.txt /code/requirements.txt
|
32 |
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
|
33 |
|
34 |
+
# Copy package.json and package-lock.json
|
35 |
COPY frontend/package*.json frontend/
|
36 |
RUN cd frontend && npm install
|
37 |
|
|
|
44 |
COPY server.py server.py
|
45 |
|
46 |
#ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
|
47 |
+
CMD ["python3", "server.py"]
|
|
app/bot.py
CHANGED
@@ -86,7 +86,7 @@ class DailyVision(EventHandler):
|
|
86 |
self.__camera = Daily.create_camera_device("camera",
|
87 |
width = video_frame.width,
|
88 |
height = video_frame.height,
|
89 |
-
color_format="
|
90 |
self.__client.update_inputs({
|
91 |
"camera": {
|
92 |
"isEnabled": True,
|
@@ -115,16 +115,15 @@ class DailyVision(EventHandler):
|
|
115 |
|
116 |
if video_frame:
|
117 |
image = Image.frombytes("RGBA", (video_frame.width, video_frame.height), video_frame.buffer)
|
118 |
-
result_image = self.__pipeline.predict(params, image)
|
119 |
self.__camera.write_frame(result_image.tobytes())
|
120 |
#pil = Image.fromarray(result.render()[0], mode="RGB").tobytes()
|
121 |
-
#self.__camera.write_frame(result_image.tobytes())
|
122 |
except queue.Empty:
|
123 |
pass
|
124 |
|
125 |
def on_video_frame(self, participant_id, video_frame):
|
126 |
# Process ~15 frames per second (considering incoming frames at 30fps).
|
127 |
-
if time.time() - self.__time >
|
128 |
self.__time = time.time()
|
129 |
self.setup_camera(video_frame)
|
130 |
self.__queue.put(video_frame)
|
|
|
86 |
self.__camera = Daily.create_camera_device("camera",
|
87 |
width = video_frame.width,
|
88 |
height = video_frame.height,
|
89 |
+
color_format="RGBA")
|
90 |
self.__client.update_inputs({
|
91 |
"camera": {
|
92 |
"isEnabled": True,
|
|
|
115 |
|
116 |
if video_frame:
|
117 |
image = Image.frombytes("RGBA", (video_frame.width, video_frame.height), video_frame.buffer)
|
118 |
+
result_image = self.__pipeline.predict(params, image)
|
119 |
self.__camera.write_frame(result_image.tobytes())
|
120 |
#pil = Image.fromarray(result.render()[0], mode="RGB").tobytes()
|
|
|
121 |
except queue.Empty:
|
122 |
pass
|
123 |
|
124 |
def on_video_frame(self, participant_id, video_frame):
|
125 |
# Process ~15 frames per second (considering incoming frames at 30fps).
|
126 |
+
if time.time() - self.__time > 5: #0.05:
|
127 |
self.__time = time.time()
|
128 |
self.setup_camera(video_frame)
|
129 |
self.__queue.put(video_frame)
|
app/pipeline.py
CHANGED
@@ -181,8 +181,8 @@ class Pipeline:
|
|
181 |
|
182 |
self.pipe(
|
183 |
prompt="warmup",
|
184 |
-
image=[Image.new("
|
185 |
-
control_image=[Image.new("
|
186 |
)
|
187 |
|
188 |
def predict(self, params: "Pipeline.InputParams", image) -> Image.Image:
|
|
|
181 |
|
182 |
self.pipe(
|
183 |
prompt="warmup",
|
184 |
+
image=[Image.new("RGBA", (640, 480))],
|
185 |
+
control_image=[Image.new("RGBA", (640, 480))],
|
186 |
)
|
187 |
|
188 |
def predict(self, params: "Pipeline.InputParams", image) -> Image.Image:
|
requirements.txt
CHANGED
@@ -10,7 +10,7 @@ pillow
|
|
10 |
pydantic
|
11 |
utils
|
12 |
psutil
|
13 |
-
dotenv
|
14 |
|
15 |
transformers==4.35.2
|
16 |
torch==2.1.1
|
|
|
10 |
pydantic
|
11 |
utils
|
12 |
psutil
|
13 |
+
python-dotenv
|
14 |
|
15 |
transformers==4.35.2
|
16 |
torch==2.1.1
|