Skip to content

Instantly share code, notes, and snippets.

View Merwanski's full-sized avatar
:electron:
Focusing

Merwanski

:electron:
Focusing
  • Belgium
  • Belgium
View GitHub Profile
@Merwanski
Merwanski / convert_pascal_annotation_to_yolo.py
Last active November 24, 2021 13:31
convert pascal annotation to yolo
import xml.etree.ElementTree as ET
import pickle
import os,sys
from os import listdir, getcwd
from os.path import join
# TODO
classes = [""] # update with the classes of your dataset
def convert(size,box):
@Merwanski
Merwanski / tcp_image_stream.py
Created November 24, 2021 13:33
image streaming tcp
import sys
import cv2
# TODO update with this part with your ip address
cap = cv2.VideoCapture("tcp://192.168.68.97:18003")
while(True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
@Merwanski
Merwanski / server.py
Created November 24, 2021 13:39
server.py
#!/usr/bin/env python3
from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
import sys
PORT_NUMBER = 5000
SIZE = 1024
hostName = gethostbyname( '0.0.0.0' )
mySocket = socket( AF_INET, SOCK_DGRAM )
@Merwanski
Merwanski / docker_logs.py
Created November 24, 2021 13:43
Docker container logs
# Docker container logs
import datetime
import docker
import time
import os
# how to run it
# python3 docker_logs.py
# TODO update the name for the correct one on the drone
@Merwanski
Merwanski / client.py
Created November 24, 2021 13:52
client.py
#!/usr/bin/env python3
import sys
from socket import socket, AF_INET, SOCK_DGRAM
# TODO update this part with the IP address of the server and port number used
SERVER_IP = '172.19.0.3'
PORT_NUMBER = 5000
SIZE = 1024
print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP, PORT_NUMBER))
@Merwanski
Merwanski / git_branch_in_prompt
Created November 24, 2021 13:56
git branch in terminal prompt
# TODO Add the code below to your barshrc file
# Git branch in prompt.
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
@Merwanski
Merwanski / command tensorflow container
Created November 25, 2021 15:13
tensorflow/tensorflow:latest-gpu-py3 docker container to start with dev machine
Create a new container from the TensorFlow image
"""
$ docker run -it --rm tensorflow/tensorflow:latest-gpu-py3
"""
You should be logged-in in the new container. You can explore it using ls, cd, etc…
You can exit using
$ exit.
Create a directory to exchange files between your machine and the container:
@Merwanski
Merwanski / get_gpu_name.py
Created November 25, 2021 15:25
get gpu name tensorflow and pytorch
# tensorflow
from tensorflow.python.client import device_lib
devices_tf = device_lib.list_local_devices()
devices_tf = print(devices)
# pytorch
import torch
devices_torch = torch.cuda.get_device_name()
print(devices_torch)
# reset last git commit
git reset --soft HEAD~1
@Merwanski
Merwanski / gist:7c4c7872e0dfaa6c7e96f7b3e9bf4e06
Created December 8, 2021 09:45
keep the container running and not exit directly
# add this at the end of your entrypoint file
# to keep the container running and not exit directly
set -x
while $1
do
echo "Press [CTRL+C] to stop.."
sleep 5
echo "My second and third argument is $2 & $3"
done