Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demos/video/style-transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ python3 neural_style.py export --model saved_models/mosaic.pth --accel

python3 style_transfer_test.py --model-file=models/exports/cpu/mosaic_float16.pt --input-video-file=videos/deer.mp4 --output-video-file=videos/mosaic_deer.mp4 --show-output



sh export_and_run_model.sh nature_oil_painting_ep3_bt4_sw3e10_cw_1e5
29 changes: 29 additions & 0 deletions demos/video/style-transfer/cam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import cv2

def main():
# Initialize the webcam (0 is usually the default camera)
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print("Cannot open camera")
return

while True:
# Capture frame-by-frame
ret, frame = cap.read()
if not ret:
print("Failed to grab frame")
break

# Display the resulting frame
cv2.imshow("Webcam", frame)

# Press 'q' to exit
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion demos/video/style-transfer/export_and_run_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ MODEL_NAME=$1
python3 neural_style.py export --model saved_models/${MODEL_NAME}.model --accel \
|| python3 neural_style.py export --model saved_models/${MODEL_NAME}.pth --accel

# nature_oil_painting_ep3_bt4_sw3e10_cw_1e5

python3 style_transfer_test.py --model-file=models/exports/cpu/${MODEL_NAME}_float16.pt --input-video-file=videos/deer.mp4 --show-output
# python3 style_transfer_test.py --model-file=models/exports/cpu/${MODEL_NAME}_float16.pt --input-video-file=videos/deer.mp4 --show-output

python3 style_transfer_test.py --model-file=models/exports/cpu/${MODEL_NAME}_float16.pt --use-webcam --show-output
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading