Skip to content

Instantly share code, notes, and snippets.

View patharanordev's full-sized avatar
🤝
Focusing

PatharaNor patharanordev

🤝
Focusing
View GitHub Profile
@patharanordev
patharanordev / download-kaggle-file.py
Last active October 12, 2020 13:57
Download file from Kaggle via Kaggle own credential
from zipfile import ZipFile
from google.colab import files
!rm -rf kaggle.json
!rm -rf /root/.kaggle/kaggle.json
'''
If you found an error "TypeError: Cannot read property '_uploadFiles' of undefined",
please check cookie mode. You need to allow all cookie
'''
files.upload() #upload kaggle.json
@patharanordev
patharanordev / write-dataframe2csv.py
Created October 6, 2020 16:09
Write DataFrame from pandas to CSV file
production_fname = '{}/production.csv'.format(os.getcwd())
def write_prodfile(production_df):
if os.path.isfile(production_fname):
# Remove if exists
os.remove(production_fname)
production_df.to_csv(r'{}'.format(production_fname), index = False)
@patharanordev
patharanordev / issue_ssl_cert_verify_failed.md
Last active February 14, 2021 02:54
Correct way to solve "CERTIFICATE_VERIFY_FAILED" issue

Solved SSL:CERTIFICATE_VERIFY_FAILED in Python

... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
import ssl

ssl._create_default_https_context = ssl._create_unverified_context
@patharanordev
patharanordev / test_plaidml_vgg.py
Created February 14, 2021 04:10
Test PlaidML performance via simple VGG model
#!/usr/bin/env python
import numpy as np
import os
import time
os.environ['KERAS_BACKEND'] = 'plaidml.keras.backend'
import keras
import keras.applications as kapp
@patharanordev
patharanordev / opencv-mac-camera.md
Last active March 4, 2021 01:22
OpenCV using camera in MacOS

If You are Using MAC, I Actually Solved this Issue By Granting Permission for Terminal To Access Camera in Security and Privacy Section in System Preferences. Hope This Solves Issue In Your Mac Click Here To View Steps

@patharanordev
patharanordev / convert-pt-to-onnx.md
Created March 6, 2021 04:27
How-to-convert `.pt` to `.onnx` model file format.

Convert .pt to .onnx

The function using in Scaled-YOLOv4, please refer to Scaled-YOLOv4 repository.

Before start, the export script requires onnxsim, you need to install it first :

$ pip install -q onnx-simplifier

Fixed gem install cocoapods

If you found error message like this :

Error installing cocoapods: ERROR: Failed to build gem native extension

You should re-install ruby first before install cocoapods.

$ brew reinstall ruby
@patharanordev
patharanordev / cv2_img_encode_base64.md
Last active August 15, 2023 01:17
Convert image from cv2.imread to img.src in HTML

Encode image in nparray to base64

Encode base64 function:

import cv2
import base64

def encode_img(img, im_type):
 """Encodes an image as a png and encodes to base 64 for display."""
@patharanordev
patharanordev / long-run-colab.md
Created March 8, 2021 14:54
To prevent CoLab's session loss

Long run CoLab

In CoLab, press (CTRL + SHIFT + i) to open inspect window. Go to console tab then press source code below and press enter :

function ClickConnect(){
console.log("Working"); 
document
 .querySelector('#top-toolbar > colab-connect-button')
@patharanordev
patharanordev / example-plot-img-grid.md
Last active March 27, 2021 09:58
Using matplotlib to plot image grid M x N

Plot image grid M x N via matplotlib

The example below, try to show predicted result image & label on VGG19 model, I have set grid size to N x 5 :

  • multi-rows
  • 5-columns

I have directory structure like this

content