-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from aagustinconti/app
App
- Loading branch information
Showing
9 changed files
with
118 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.pt | ||
*.avi | ||
*.mp4 | ||
*.jpg | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import docker | ||
import os | ||
import logging | ||
|
||
# Debug | ||
logging.basicConfig( | ||
format='%(asctime)s | %(levelname)s: %(message)s', level=logging.INFO) | ||
|
||
# Get the current working directory | ||
logging.info("Looking for the current directory...") | ||
cwd = os.getcwd() | ||
logging.info(f"The current directory is --> {cwd}") | ||
|
||
logging.info("Looking for the current display...") | ||
display = os.getenv("DISPLAY") | ||
logging.info(f"The current display is --> {display}") | ||
|
||
|
||
# Docker SDK --> https://docker-py.readthedocs.io/en/stable/containers.html | ||
|
||
logging.info("Instantiating Docker client...") | ||
client = docker.from_env() | ||
|
||
logging.info("Checking if the Image already exists...") | ||
|
||
if str(os.popen("docker image inspect yolov7_detect_track_count:latest 2> /dev/null").read())[:2] == "[]": | ||
|
||
logging.info("The image doesn't exist. Building the Docker Image...") | ||
|
||
os.chdir("./dependencies") | ||
|
||
cwd = os.getcwd() | ||
logging.info(f"The current directory is --> {cwd}") | ||
|
||
os.system("docker build -t yolov7_detect_track_count .") | ||
os.chdir("..") | ||
|
||
cwd = os.getcwd() | ||
logging.info(f"The current directory is --> {cwd}") | ||
|
||
else: | ||
logging.info("The image has already exists.") | ||
|
||
|
||
logging.info( | ||
"Setting up X Server to accept connections. Turning Access control off...") | ||
os.system("xhost +") | ||
|
||
|
||
logging.info("Running a container...") | ||
|
||
|
||
container = client.containers.run( | ||
image='yolov7_detect_track_count:latest', | ||
stdin_open=True, | ||
tty=True, | ||
auto_remove=True, | ||
network_mode='host', | ||
name="test", | ||
device_requests=[docker.types.DeviceRequest( | ||
device_ids=["0"], capabilities=[['gpu']])], | ||
devices=["/dev/video0:/dev/video0"], | ||
volumes={ | ||
'/tmp/.X11-unix': {'bind': '/tmp/.X11-unix', 'mode': 'rw'}, | ||
cwd: {'bind': '/workspace', 'mode': 'rw'} | ||
}, | ||
environment=[f"DISPLAY={display}"], | ||
command='python test_oop.py' | ||
) |
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters