Skip to content

Instantly share code, notes, and snippets.

@e96031413
e96031413 / yolov3-tiny.cfg
Last active October 13, 2019 04:29
YOLOv3 Tiny的cfg檔案(針對單class)
[net]
# Testing
batch=16
subdivisions=16
# Training
# batch=64
# subdivisions=2
width=416
height=416
channels=3
@e96031413
e96031413 / yolov3.cfg
Created October 12, 2019 12:15
YOLOv3的cfg檔案(針對單class)
[net]
# Testing
# batch=1
# subdivisions=1
# Training
batch=16
subdivisions=16
width=288 # input image resolution in width
height=288 # input image resolution in height
channels=3 # color space of input image
@e96031413
e96031413 / opencv-image.py
Last active October 21, 2019 08:38
使用Python的OpenCV進行圖片人臉辨識
import cv2
# 載入分類器
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# 讀取圖片
img = cv2.imread('a.jpg')
# 轉成灰階圖片
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 偵測臉部
faces = face_cascade.detectMultiScale(
gray,
@e96031413
e96031413 / opencv-video.py
Last active October 21, 2019 08:49
使用Python的OpenCV進行影片人臉辨識
import cv2
# 載入分類器
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# 從視訊鏡頭擷取影片.
#cap = cv2.VideoCapture(0)
# 使用現有影片
cap = cv2.VideoCapture('test.mp4')
@e96031413
e96031413 / LINE-Notify.py
Created October 20, 2019 11:56
使用LINE Notify TOKEN建立自己的Line BOT
import requests
def lineNotifyMessage(token, msg):
headers = {
"Authorization": "Bearer " + token,
"Content-Type" : "application/x-www-form-urlencoded"
}
payload = {'message': msg}
r = requests.post("https://notify-api.line.me/api/notify", headers = headers, params = payload)
@e96031413
e96031413 / auto-predict.sh
Created October 25, 2019 10:28
將外網FTP所上傳的影片複製到darknet資料夾、針對影片進行辨識、將結果自動上傳到Youtube
cp /home/e96031413/PiToTX2/video/*.mp4 /home/e96031413/AlexeyAB/darknet/data/bird/video/
cp -a /home/e96031413/PiToTX2/image/. /home/e96031413/AlexeyAB/darknet/data/bird/image
#./darknet detector test cfg/voc.data cfg/yolov3.cfg yolov3_10000.weights data/bird/image/bird.jpg | tee predict_img_result.txt | sleep 1s ; kill $!
./darknet detector demo cfg/voc.data cfg/yolov3.cfg yolov3_10000.weights data/bird/video/test.mp4 -out_filename detect-result.avi | sleep 120s ; kill $!
youtube-upload --title="video from tx2" detect-result.avi
@e96031413
e96031413 / yolov2-tiny.cfg
Created October 26, 2019 04:35
YOLOv2 Tiny的cfg檔案(針對單class)
[net]
# Testing
batch=16
subdivisions=16
# Training
# batch=64
# subdivisions=2
width=416
height=416
channels=3
@e96031413
e96031413 / linebot_cwb.py
Created December 7, 2019 06:08
中央氣象局-行政區天氣概況LINE機器人
import requests
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
#關閉瀏覽器跳出訊息
prefs = {
'profile.default_content_setting_values' :
{
'notifications' : 2
@e96031413
e96031413 / Upgrade_All_Packages_With_pip.py
Created December 24, 2019 12:15
Upgrade all of your python packages with pip at one time.
#only for pip >= 10.0.1
#for pip < 10.0.1, please upgrade your pip version with the following code
'''python -m pip install --user --upgrade pip'''
import pkg_resources
from subprocess import call
packages = [dist.project_name for dist in pkg_resources.working_set]
call("pip install --upgrade " + ' '.join(packages), shell=True)
@e96031413
e96031413 / text2speech.py
Created December 28, 2019 07:35
This script can help you ( Text to Speech )
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
while 1:
print('Enter the Word')
#可用中文、英文
s = input( )
speaker.Speak(s)