Spaces:
Runtime error
Runtime error
Commit ·
8f6a226
1
Parent(s): daf7bc7
Adding first time setup.
Browse files- Makefile +3 -0
- firstTimeSetup.sh +8 -0
- streamlit_app.py +1 -1
- webcam_stream.py +6 -3
Makefile
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
model-server: style
|
| 2 |
docker run --gpus all -p 8500:8500 --mount type=bind,source=/home/albert/github/neural-style/style,target=/models/style -e MODEL_NAME=style -t tensorflow/serving:latest-gpu
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
app:
|
| 5 |
exec streamlit run streamlit_app.py
|
|
|
|
| 1 |
model-server: style
|
| 2 |
docker run --gpus all -p 8500:8500 --mount type=bind,source=/home/albert/github/neural-style/style,target=/models/style -e MODEL_NAME=style -t tensorflow/serving:latest-gpu
|
| 3 |
|
| 4 |
+
model-server-cpu: style
|
| 5 |
+
docker run -p 8500:8500 --mount type=bind,source=/home/albert/github/neural-style/style,target=/models/style -e MODEL_NAME=style -t tensorflow/serving
|
| 6 |
+
|
| 7 |
app:
|
| 8 |
exec streamlit run streamlit_app.py
|
firstTimeSetup.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
rm -rf venv
|
| 4 |
+
python -m venv venv
|
| 5 |
+
|
| 6 |
+
source venv/bin/activate
|
| 7 |
+
python -m pip install pip wheel setuptools --upgrade
|
| 8 |
+
pip install -e .
|
streamlit_app.py
CHANGED
|
@@ -23,7 +23,7 @@ def main():
|
|
| 23 |
col1.subheader('Content Image')
|
| 24 |
col2.subheader('Style Image')
|
| 25 |
show_image = col1.empty()
|
| 26 |
-
show_style = col2.empty(
|
| 27 |
|
| 28 |
st.subheader('Style Transfer')
|
| 29 |
show_transfer = st.empty()
|
|
|
|
| 23 |
col1.subheader('Content Image')
|
| 24 |
col2.subheader('Style Image')
|
| 25 |
show_image = col1.empty()
|
| 26 |
+
show_style = col2.empty(i
|
| 27 |
|
| 28 |
st.subheader('Style Transfer')
|
| 29 |
show_transfer = st.empty()
|
webcam_stream.py
CHANGED
|
@@ -28,7 +28,7 @@ class WebcamVideoStream:
|
|
| 28 |
self.stopped = True
|
| 29 |
|
| 30 |
|
| 31 |
-
def style_transfer_direct(image, model, resize=None):
|
| 32 |
if resize:
|
| 33 |
image = cv2.resize(np.array(image, dtype=np.float32), (512, 512))
|
| 34 |
else:
|
|
@@ -40,11 +40,14 @@ def style_transfer_direct(image, model, resize=None):
|
|
| 40 |
|
| 41 |
def main():
|
| 42 |
model = tf.saved_model.load('style/1')
|
| 43 |
-
video_capture = WebcamVideoStream(0)
|
| 44 |
video_capture.start()
|
|
|
|
|
|
|
|
|
|
| 45 |
while True:
|
| 46 |
content_image = video_capture.read()
|
| 47 |
-
transfer = style_transfer_direct(content_image, model)
|
| 48 |
cv2.imshow('style camera', transfer)
|
| 49 |
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 50 |
break
|
|
|
|
| 28 |
self.stopped = True
|
| 29 |
|
| 30 |
|
| 31 |
+
def style_transfer_direct(image, style_image, model, resize=None):
|
| 32 |
if resize:
|
| 33 |
image = cv2.resize(np.array(image, dtype=np.float32), (512, 512))
|
| 34 |
else:
|
|
|
|
| 40 |
|
| 41 |
def main():
|
| 42 |
model = tf.saved_model.load('style/1')
|
| 43 |
+
video_capture = WebcamVideoStream('http://192.168.0.10:4747/video')
|
| 44 |
video_capture.start()
|
| 45 |
+
|
| 46 |
+
style_image = np.array(cv2.imread('/home/albert/Downloads/pattern.jpeg'), dtype=np.float32)[np.newaxis, ...] / 255.
|
| 47 |
+
|
| 48 |
while True:
|
| 49 |
content_image = video_capture.read()
|
| 50 |
+
transfer = style_transfer_direct(content_image, style_image, model)
|
| 51 |
cv2.imshow('style camera', transfer)
|
| 52 |
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 53 |
break
|