<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: raven</title>
    <description>The latest articles on DEV Community by raven (@raven404).</description>
    <link>https://dev.to/raven404</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F385731%2Fbdb61c37-4666-4d78-9726-3f215fb55e5a.jpeg</url>
      <title>DEV Community: raven</title>
      <link>https://dev.to/raven404</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raven404"/>
    <language>en</language>
    <item>
      <title>Object Detection Using Tensorflow </title>
      <dc:creator>raven</dc:creator>
      <pubDate>Thu, 10 Dec 2020 16:52:15 +0000</pubDate>
      <link>https://dev.to/raven404/object-detection-using-tensorflow-27ed</link>
      <guid>https://dev.to/raven404/object-detection-using-tensorflow-27ed</guid>
      <description>&lt;p&gt;Object Detection using Tensorflow is a computer vision technique. As the name suggests, it helps us in detecting, locating, and tracing an object from an image or camera.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Object detection?&lt;/strong&gt;&lt;br&gt;
Object detection is a computer vision technique in which a software system can detect, locate, and trace the object from a given image or video. The special attribute about object detection is that it identifies the class of object (person, table, chair, etc.) and their location-specific coordinates in the given image. The location is pointed out by drawing a bounding box around the object. The bounding box may or may not accurately locate the position of the object. The ability to locate the object inside an image defines the performance of the algorithm used for detection. Face detection is one of the examples of object detection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does Object detection work?&lt;/strong&gt;&lt;br&gt;
Generally, the object detection task is carried out in three steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generates the small segments in the input as shown in the image below. As you can see the large set of bounding boxes are  spanning the full image&lt;/li&gt;
&lt;li&gt;Feature extraction is carried out for each segmented rectangular area to predict whether the rectangle contains a valid object.&lt;/li&gt;
&lt;li&gt;Overlapping boxes are combined into a single bounding rectangle (Non-Maximum Suppression)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is TensorFlow?&lt;/strong&gt;&lt;br&gt;
Tensorflow is an open-source library for numerical computation and large-scale machine learning that ease Google Brain TensorFlow, the process of acquiring data, training models, serving predictions, and refining future results.&lt;/p&gt;

&lt;p&gt;Tensorflow bundles together Machine Learning and Deep Learning models and algorithms. It uses Python as a convenient front-end and runs it efficiently in optimized C++.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object Detection Using Tensorflow&lt;/strong&gt;&lt;br&gt;
As mentioned above the knowledge of neural network and machine learning is not mandatory for using this API as we are mostly going to use the files provided in the API. All we need is some knowledge of python and passion for completing this project.&lt;br&gt;
Follow the below-mentioned steps :&lt;br&gt;
Step 1: Create a folder named ObjectDetection and open it with the VS Code.&lt;br&gt;
Step 2: Download Tensorflow API from Github Repository by typing the below-mentioned command in  vs code's terminal&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/tensorflow/models&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;step 3: Setting up a virtual environment&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python -m venv --system-site-packages .\venv&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;activate the environment
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;.\venv\Scripts\activate&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;upgrading pip version to the latest
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;python -m pip install --upgrade --ignore-installed&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Step 4: Installing dependencies&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing and upgrading tensorflow
&lt;code&gt;pip install tensorflow&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;pip install --upgrade tensorflow&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;installing matplotlib
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;pip install pillow Cython lxml jupyter matplotlib&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the research subfolder in the models folder.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;cd \models\research\&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Step 5: Now we need to download &lt;a href="https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-win64.zip"&gt;Protocol Buffers (Protobuf)&lt;/a&gt; which are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data, – think of it as XML, but smaller, faster, and simpler.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract the content of the downloaded zip from the above link in the research subfolder of the models' folder and visit the bin folder and copy the path of the &lt;em&gt;protoc.exe&lt;/em&gt; there.&lt;/li&gt;
&lt;li&gt;Then open "Edit the system environment variables" and click on "Environment Variables".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(i) Under system variables select 'path' and click on edit.&lt;br&gt;
   (ii)Click on New and paste the copied path of the 'protoc.exe'.&lt;br&gt;
Step 6: Then in the terminal of vs code run this command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;protoc object_detection/protos/*.proto --python_out=.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Step 7: Create a new python file named 'detect.py' in the same folder and paste the code given below :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import pathlib
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from IPython.display import display
from object_detection.utils import ops as utils_ops
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util

while "models" in pathlib.Path.cwd().parts:
    os.chdir('..')

def load_model(model_name):
  base_url = 'http://download.tensorflow.org/models/object_detection/'
  model_file = model_name + '.tar.gz'
  model_dir = tf.keras.utils.get_file(
    fname=model_name, 
    origin=base_url + model_file,
    untar=True)

  model_dir = pathlib.Path(model_dir)/"saved_model"
  model = tf.saved_model.load(str(model_dir))
  return model

PATH_TO_LABELS = 'models/research/object_detection/data/mscoco_label_map.pbtxt'
category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)

model_name = 'ssd_inception_v2_coco_2017_11_17'
detection_model = load_model(model_name)

def run_inference_for_single_image(model, image):
  image = np.asarray(image)
  # The input needs to be a tensor, convert it using `tf.convert_to_tensor`.
  input_tensor = tf.convert_to_tensor(image)
  # The model expects a batch of images, so add an axis with `tf.newaxis`.
  input_tensor = input_tensor[tf.newaxis,...]

  # Run inference
  model_fn = model.signatures['serving_default']
  output_dict = model_fn(input_tensor)

  # All outputs are batches tensors.
  # Convert to numpy arrays, and take index [0] to remove the batch dimension.
  # We're only interested in the first num_detections.
  num_detections = int(output_dict.pop('num_detections'))
  output_dict = {key:value[0, :num_detections].numpy() 
                 for key,value in output_dict.items()}
  output_dict['num_detections'] = num_detections

  # detection_classes should be ints.
  output_dict['detection_classes'] = output_dict['detection_classes'].astype(np.int64)

  # Handle models with masks:
  if 'detection_masks' in output_dict:
    # Reframe the the bbox mask to the image size.
    detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(
              output_dict['detection_masks'], output_dict['detection_boxes'],
               image.shape[0], image.shape[1])      
    detection_masks_reframed = tf.cast(detection_masks_reframed &amp;gt; 0.5,
                                       tf.uint8)
    output_dict['detection_masks_reframed'] = detection_masks_reframed.numpy()

  return output_dict

def show_inference(model, frame):
  #take the frame from webcam feed and convert that to array
  image_np = np.array(frame)
  # Actual detection.

  output_dict = run_inference_for_single_image(model, image_np)
  # Visualization of the results of a detection.
  vis_util.visualize_boxes_and_labels_on_image_array(
      image_np,
      output_dict['detection_boxes'],
      output_dict['detection_classes'],
      output_dict['detection_scores'],
      category_index,
      instance_masks=output_dict.get('detection_masks_reframed', None),
      use_normalized_coordinates=True,
      line_thickness=5)

  return(image_np)

#Now we open the webcam and start detecting objects
import cv2
video_capture = cv2.VideoCapture(0)
while True:
    # Capture frame-by-frame
    re,frame = video_capture.read()
    Imagenp=show_inference(detection_model, frame)
    cv2.imshow('object detection', cv2.resize(Imagenp, (800,600)))
    if cv2.waitKey(1) &amp;amp;amp; 0xFF == ord('q'):
        break
video_capture.release()
cv2.destroyAllWindows()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 7:For real-time object detection we need one more dependency OpenCV.So to install OpenCV run this command in terminal.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install opencv-python&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Step 8: Now we are all done and our setup is ready to be executed and detect the objects. Execute the 'detect.py'&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python detect.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>python</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Managing multiple GitHub account using git in windows  </title>
      <dc:creator>raven</dc:creator>
      <pubDate>Thu, 04 Jun 2020 15:07:28 +0000</pubDate>
      <link>https://dev.to/raven404/managing-multiple-github-account-using-git-in-windows-2m0h</link>
      <guid>https://dev.to/raven404/managing-multiple-github-account-using-git-in-windows-2m0h</guid>
      <description>&lt;p&gt;Wanna use another GitHub account in my windows pc but wait I already got my personal account added in git.&lt;br&gt;
No problem here you can see how you can manage multiple accounts without any hassle:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;This DIY is meant for windows users.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;*Set up SSH Keys.&lt;br&gt;
*Add the keys to your Github accounts:&lt;br&gt;
*Create a configuration file to manage the separate keys&lt;br&gt;
*Update stored identities&lt;br&gt;
*Test PUSH&lt;br&gt;
*Test PULL&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Set up SSH Keys&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let's consider your two GitHub accounts are named githubPersonal and githubWork, respectively.&lt;/p&gt;

&lt;p&gt;Create two SSH keys, saving each to a separate file:&lt;br&gt;
Execute the below mentioned commands in gitbash&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ cd ~/.ssh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;$ ssh-keygen -t rsa -C "your_email_id_associated_with_githubPersonal_account&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;save it as &lt;code&gt;id_rsa_personal&lt;/code&gt; when prompted (you can rename personal)&lt;br&gt;
&lt;code&gt;$ Enter passphrase (empty for no passphrase):&lt;/code&gt; &lt;em&gt;skip this by pressing enter&lt;/em&gt;&lt;br&gt;
&lt;code&gt;$ Enter same passphrase again:&lt;/code&gt; &lt;em&gt;skip this by pressing enter&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ ssh-keygen -t rsa -C "your_email_id_associated_with_githubWork_account"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;save it as &lt;code&gt;id_rsa_work&lt;/code&gt; when prompted (you can rename personal)&lt;br&gt;
&lt;code&gt;$ Enter passphrase (empty for no passphrase):&lt;/code&gt; &lt;em&gt;skip this by pressing enter&lt;/em&gt;&lt;br&gt;
&lt;code&gt;$ Enter same passphrase again:&lt;/code&gt; &lt;em&gt;skip this by pressing enter&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The above commands setup the following files:&lt;br&gt;
id_rsa_personal&lt;br&gt;
id_rsa_personal.pub&lt;br&gt;
id_rsa_work&lt;br&gt;
id_rsa_work.pub&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Add the keys to your Github accounts:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Copy the key to your clipboard by opening the file in vs code:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ code . id_rsa_personal.pub&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add the key to your account:&lt;/strong&gt;&lt;br&gt;
Go to your GitHub Account Settings&lt;br&gt;
Click “SSH Keys” then “Add SSH key”&lt;br&gt;
Paste your key into the “Key” field and add a relevant title&lt;br&gt;
Click “Add key” then enter your GitHub password to confirm.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Repeat the process for your githubWork account.&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Create a configuration file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a configuration file to manage the separate keys in ~/.ssh/ using &lt;br&gt;
&lt;code&gt;$ touch config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Edit the file using the text editor of your choice. I used vs code - &lt;br&gt;
&lt;code&gt;$ code . config&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# githubPersonal
Host personal
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_personal

# githubWork
Host work
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_work 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Update stored identities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;initialize the ssh-agent (use powershell)&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Get-Service -Name ssh-agent | Set-Service -StartupType Manual&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Clear currently stored identities:&lt;br&gt;
$ ssh-add -D&lt;br&gt;
Add new keys:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ ssh-add id_rsa_personal&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;$ ssh-add id_rsa_work&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Test to make sure new keys are stored:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ ssh-add -l&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Test to make sure Github recognizes the keys:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ ssh -T personal&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ ssh -T work&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Test PUSH&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On Github, create a new repo in your personal account, githubPersonal, called test-personal.&lt;br&gt;
Back on your local machine, create a test directory:&lt;br&gt;
&lt;code&gt;$ cd ~/documents&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ mkdir test-personal&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ cd test-personal&lt;/code&gt;&lt;br&gt;
Add a blank “readme.md” file and PUSH to Github:&lt;br&gt;
&lt;code&gt;$ touch readme.md&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ git init&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ git add .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ git commit -am "first commit"&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ git remote add origin git@personal:githubPersonal/test-personal.git&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$ git push origin master&lt;/code&gt;&lt;br&gt;
Notice how we’re using the custom account, git@personal, instead of &lt;a href="mailto:git@github.com"&gt;git@github.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Repeat the process for your githubWork account.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
