Skip to content

Instantly share code, notes, and snippets.

View Jargon4072's full-sized avatar

Chandan Dwivedi Jargon4072

View GitHub Profile
@Jargon4072
Jargon4072 / detect.py
Created September 25, 2019 12:56
Yolov3_medium_1
import numpy as np
import argparse
import time
import cv2
import os
confthres=0.5
nmsthres=0.1
path="./"
@Jargon4072
Jargon4072 / detect.py
Created September 25, 2019 13:47
Yolov3_medium_2
def get_labels(labels_path):
# load the COCO class labels our YOLO model was trained on
#labelsPath = os.path.sep.join([yolo_path, "yolo_v3/coco.names"])
lpath=os.path.sep.join([yolo_path, labels_path])
LABELS = open(lpath).read().strip().split("\n")
return LABELS
def get_colors(LABELS):
# initialize a list of colors to represent each possible class label
np.random.seed(42)
@Jargon4072
Jargon4072 / detect.py
Created September 25, 2019 19:27
Yolov3_medium_3
def get_predection(image,net,LABELS,COLORS):
(H, W) = image.shape[:2]
# determine only the *output* layer names that we need from YOLO
ln = net.getLayerNames()
ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
# construct a blob from the input image and then perform a forward
# pass of the YOLO object detector, giving us our bounding boxes and
# associated probabilities
@Jargon4072
Jargon4072 / detect.py
Created September 25, 2019 19:30
Yolov3_medium_4
def main():
# load our input image and grab its spatial dimensions
image = cv2.imread("./test1.jpg")
labelsPath="yolo_v3/coco.names"
cfgpath="yolo_v3/yolov3.cfg"
wpath="yolo_v3/yolov3.weights"
Lables=get_labels(labelsPath)
CFG=get_config(cfgpath)
Weights=get_weights(wpath)
nets=load_model(CFG,Weights)
@Jargon4072
Jargon4072 / detect_flask.py
Created September 26, 2019 04:19
yolov3_flask.py
# @Author: Dwivedi Chandan
# @Date: 2019-08-05T13:35:05+05:30
# @Email: chandandwivedi795@gmail.com
# @Last modified by: Dwivedi Chandan
# @Last modified time: 2019-08-07T11:52:45+05:30
# import the necessary packages
import numpy as np
import argparse
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
df1=pd.read_csv("./x01.csv")
df1.columns=["Index","Brain_weight","Body_weight"]
corr_data = df1.corr() #we are using pandas library's corr() function to find correlation.
print(corr_data)
plt.figure(figsize=(9,5))
from numpy import *
# y = mx + b
# m is slope, b is y-intercept
# point is tuple of x,y value at a given step with data as points[i]= [xi, yi]
def compute_error_for_line_given_points(b, m, points):
totalError = 0
for i in range(0, len(points)):
x = points[i, 0]
y = points[i, 1]
def step_gradient(b_current, m_current, points, learningRate):
b_gradient = 0
m_gradient = 0
N = float(len(points))
for i in range(0, len(points)):
x = points[i, 0]
y = points[i, 1]
b_gradient += -(2/N) * (y - ((m_current * x) + b_current))
m_gradient += -(2/N) * x * (y - ((m_current * x) + b_current))
new_b = b_current - (learningRate * b_gradient)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def run_lr(res,data):
# Note: data should be given in pandas format, as shwon below:
'''
Brain_weight Body_weight
62.00 1320.0
55.50 175.0
35.00 56.0
52.16 440.0
0.28 1.9
'''