Skip to content

Commit

Permalink
add cleanup + move scripts to utils + move data directory + updated d…
Browse files Browse the repository at this point in the history
…evcontainer to use opencv-headless
  • Loading branch information
cedricve committed Jun 1, 2024
1 parent dc86c1d commit a28eda4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 28 deletions.
44 changes: 21 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/coverage-py:2": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"streetsidesoftware.code-spell-checker"
]
}
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/coverage-py:2": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// We will override with opencv-python-headless as we cannot show the visualizations.
"postCreateCommand": "pip3 install --user -r requirements.txt && pip install opencv-python-headless",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"streetsidesoftware.code-spell-checker"
]
}
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
assets/videos
data/video.mp4
__pycache__
.venv
.env
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Empty file added data/.gitkeep
Empty file.
11 changes: 7 additions & 4 deletions example_inference.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from uugai_python_color_prediction.ColorPrediction import ColorPrediction
from uugai_python_dynamic_queue.MessageBrokers import RabbitMQ
from uugai_python_kerberos_vault.KerberosVault import KerberosVault

from assets.scripts.read_first_frame import read_first_frame
from utils.read_first_frame import read_first_frame
from dotenv import load_dotenv
import os

Expand Down Expand Up @@ -40,7 +39,7 @@
# Retrieve media from the Kerberos Vault
print("4) Retrieving media from the Kerberos Vault...")
resp = kerberos_vault.retrieve_media(
message, media_type='video', media_savepath='assets/videos/video.mp4')
message, media_type='video', media_savepath='data/video.mp4')

############################################
# Implement your own logic here
Expand All @@ -49,11 +48,15 @@
# In this example, we will perform color prediction on the first frame of
# the video
print("5) Perform action on the media... (in this case color prediction)")
main_colors, _, _ = ColorPrediction.find_main_colors(image=read_first_frame('assets/videos/video.mp4'),
main_colors, _, _ = ColorPrediction.find_main_colors(image=read_first_frame('data/video.mp4'),
min_clusters=1,
max_clusters=5,
downsample_factor=0.95,
increase_elbow=0,
verbose=False,
plot=False)
print("\tMain colors found in the first frame:", main_colors.tolist())

# Cleanup the video
print("6) Cleaning up the video...")
os.remove('data/video.mp4')
File renamed without changes.

0 comments on commit a28eda4

Please sign in to comment.