Digital Version Of Modern Periodic Table

Last Updated on May 3, 2021

About

This is a simple project completed during my first semester in CSE, this program allows the user to search foe an element based on the name of the element or its atomic number and shows the information regarding the element as the output.

More Details: Digital Version of Modern Periodic Table

Submitted By


Share with someone who needs it

Hacktube

Last Updated on May 3, 2021

About

A Chrome extension that fights online harassment by filtering out comments with strong language.

Inspiration

YouTube is a place for millions of people to share their voices and engage with their communities. Unfortunately, the YouTube comments section is notorious for enabling anonymous users to post hateful and derogatory messages with the click of a button. These messages are purely meant to cause anger and depression without ever providing any constructive criticism. For YouTubers, this means seeing the degrading and mentally-harmful comments on their content, and for the YouTube community, this means reading negative and offensive comments on their favorite videos. As young adults who consume this online content, we feel as though it is necessary to have a tool that combats these comments to make YouTube a safer place.

What it does

HackTube automatically analyzes every YouTube video you watch, targeting comments which are degrading and offensive. It is constantly checking the page for hateful comments, so if the user loads more comments, the extension will pick those up. It then blocks comments which it deems damaging to the user, listing the total number of blocked comments at the top of the page. This process is all based on user preference, since the user chooses which types of comments (sexist, racist, homophobic, etc) they do not want to see. It is important to note that the user can disable the effects of the extension at any time. HackTube is not meant to censor constructive criticism; rather, it combats comments which are purely malicious in intent.

How we built it

HackTube uses JavaScript to parse through every YouTube comment almost instantly, comparing its content to large arrays that we made which are full of words that are commonly used in hate speech. We chose our lists of words carefully to ensure that the extension would focus on injurious comments rather than helpful criticism. We used standard HTML and CSS to style the popup for the extension and the format of the censored comments.

Challenges we ran into

We are trying to use cookies to create settings for the user which would be remembered even after the user closes the browser. That way anyone who uses HackTube will be able to choose exactly which types of comments they don't want to see and then have those preferences remembered by the extension. Unfortunately, Chrome blocks the use of cookies unless you use a special API, and we didn't have enough time to complete our implementation of that API at this hackathon.

Accomplishments that we're proud of

We are proud of making a functional product that can not only fight online harassment and cyberbullying but also appeal to a wide variety of people.

What we learned

We learned how to dynamically alter the source code of a webpage through a Chrome extension. We also learned just how many YouTube comments are full of hate and malicious intent.

What's next for HackTube

Right now, for demo purposes, HackTube merely changes the hateful comments into a red warning statement. In the future, HackTube will have an option to fully take out the malicious comment, so users’ YouTube comments feed will be free of any trace of hateful comments. Users won’t have to worry about how many comments were flagged and what they contained. Additionally, we will have a way for users to input their own words that offend them and take the comments that contain those words out of the section.

More Details: HackTube

Submitted By


Image Super Resolution Using Autoencoders In Keras

Last Updated on May 3, 2021

About

In this project, we learned about basic functionality of auto-encoders and implemented an Image Super-Resolution enhancement task. This task could have multiple use cases in daily lifestyles. For example, we can use this technique to enhance the quality of low-resolution videos as well. So, even without labels, we can work with the image data and solve several real-world problems.We will be working on ‘Labeled Faces in the Wild Home’ dataset. This dataset contains a database of labelled faces, generally used for face recognition and detection. However, our aim is not to detect faces but to make a model to enhance image resolution.The dataset comprises of multiple sub directories containing various images of that person. Hence, it is important to capture image paths from these directories.

Load and Preprocess Images

The size of original images are of 250 x 250 pixels. However, it would take a lot computation power to process these images on normal computer. Therefore, we will reduce the size of all images to 80 x 80 pixels.

As there are around 13,000 images, it would take lot of time if we process it individually. Hence, we take advantage of multiprocessing library provided in python for ease of execution.
tqdm is a progress library that we use to get a progress bar of the work done.
from tqdm import tqdm
from multiprocessing import Pool

progress = tqdm(total= len(face_images), position=0)
def read(path):
  img = image.load_img(path, target_size=(80,80,3))
  img = image.img_to_array(img)
  img = img/255.
  progress.update(1)
  return img
p = Pool(10)
img_array = p.map(read, face_images)

In order to save time in future, let’s store our img_array (contains images) with the help of pickle library:

with open('img_array.pickle','wb') as f:
  pickle.dump(img_array, f)

print(len(img_array))

Data preparation for Model Training

Now, we will split our dataset to train and validation set. We will use train data to train our model and validation data will be used to evaluate the model.

all_images = np.array(img_array)

#Split test and train data. all_images will be our output images
train_x, val_x = train_test_split(all_images, random_state = 32, test_size=0.2)

As this is an image resolution enhancement task we will distort our images and take it as an input images. The original images will be added as our output images.

#now we will make input images by lowering resolution without changing the size
def pixalate_image(image, scale_percent = 40):
  width = int(image.shape[1] * scale_percent / 100)
  height = int(image.shape[0] * scale_percent / 100)
  dim = (width, height)
  small_image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
  
  # scale back to original size
  width = int(small_image.shape[1] * 100 / scale_percent)
  height = int(small_image.shape[0] * 100 / scale_percent)
  dim = (width, height)
  low_res_image = cv2.resize(small_image, dim, interpolation =  cv2.INTER_AREA)
 return low_res_image
The idea is to take these distorted images and feed it to our model and make model learn to get the original image back.


train_x_px = []

for i in range(train_x.shape[0]):
  temp = pixalate_image(train_x[i,:,:,:])
  train_x_px.append(temp)
train_x_px = np.array(train_x_px)   #Distorted images
# get low resolution images for the validation set
val_x_px = []
for i in range(val_x.shape[0]):
  temp = pixalate_image(val_x[i,:,:,:])
  val_x_px.append(temp)
val_x_px = np.array(val_x_px)     #Distorted images

Input Image

Original Image

Model building

Let's define the structure of model. Moreover, to overcome the possibility of over-fitting, we are using l1 regularization technique in our convolution layer.

Input_img = Input(shape=(80, 80, 3))  
    
#encoding architecture
x1 = Conv2D(64, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(Input_img)
x2 = Conv2D(64, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x1)
x3 = MaxPool2D(padding='same')(x2)
x4 = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x3)
x5 = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x4)
x6 = MaxPool2D(padding='same')(x5)
encoded = Conv2D(256, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x6)
#encoded = Conv2D(64, (3, 3), activation='relu', padding='same')(x2)
# decoding architecture
x7 = UpSampling2D()(encoded)
x8 = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x7)
x9 = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x8)
x10 = Add()([x5, x9])
x11 = UpSampling2D()(x10)
x12 = Conv2D(64, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x11)
x13 = Conv2D(64, (3, 3), activation='relu', padding='same', kernel_regularizer=regularizers.l1(10e-10))(x12)
x14 = Add()([x2, x13])
# x3 = UpSampling2D((2, 2))(x3)
# x2 = Conv2D(128, (3, 3), activation='relu', padding='same')(x3)
# x1 = Conv2D(256, (3, 3), activation='relu', padding='same')(x2)
decoded = Conv2D(3, (3, 3), padding='same',activation='relu', kernel_regularizer=regularizers.l1(10e-10))(x14)
autoencoder = Model(Input_img, decoded)
autoencoder.compile(optimizer='adam', loss='mse', metrics=['accuracy'])

You can modify this model as per your choice and requirement to get better results. You can change number of layers, number of units or some regularization techniques too. For the time being, let’s move forward and see what our model looks like!

autoencoder.summary()

Screenshot of the model summary

Model Training

We will first define some callbacks so that it would be easy for model visualization and evaluation in future.

early_stopper = EarlyStopping(monitor='val_loss', min_delta=0.01, patience=50, verbose=1, mode='min')

model_checkpoint =  ModelCheckpoint('superResolution_checkpoint3.h5', save_best_only = True)

Let's train our model:

history = autoencoder.fit(train_x_px,train_x,
            epochs=500,
            validation_data=(val_x_px, val_x),
            callbacks=[early_stopper, model_checkpoint])
The execution time was around 21 seconds per epoch on 12GB NVIDIA Tesla K80 GPU. EarlyStopping was achieved at 65th epoch.

Now, let's evaluate our model on our test dataset:

results = autoencoder.evaluate(val_x_px, val_x)
print('val_loss, val_accuracy', results)
val_loss, val_accuracy [0.002111854264512658, 0.9279356002807617]


We are getting some pretty good results from our model with around 93% validation accuracy and a validation loss of 0.0021.

Make Predictions

predictions = autoencoder.predict(val_x_px)

n = 4
plt.figure(figsize= (20,10))
for i in range(n):
  ax = plt.subplot(3, n, i+1)
  plt.imshow(val_x_px[i+20])
  ax.get_xaxis().set_visible(False)
  ax.get_yaxis().set_visible(False)
  ax = plt.subplot(3, n, i+1+n)
  plt.imshow(predictions[i+20])
  ax.get_xaxis().set_visible(False)
  ax.get_yaxis().set_visible(False)
plt.show()

1st row — Input Images & 2nd row — Output Images

In this project, we learned about basic functionality of auto-encoders and implemented an Image Super-Resolution enhancement task. This task could have multiple use cases in daily lifestyles. For example, we can use this technique to enhance the quality of low-resolution videos as well. So, even without labels, we can work with the image data and solve several real-world problems.

More Details: Image Super Resolution using Autoencoders in keras

Submitted By


Age And Gender Detection

Last Updated on May 3, 2021

About

objective :To build a gender and age detector that can approximately guess the gender and age of the person (face) in a picture or through webcam.

Description : In this Python Project, I had used Deep Learning to accurately identify the gender and age of a person from a single image of a face. I used the models trained by Tal hassner and Gil levi. The predicted gender may be one of ‘Male’ and ‘Female’, and the predicted age may be one of the following ranges- (0 – 2), (4 – 6), (8 – 12), (15 – 20), (25 – 32), (38 – 43), (48 – 53), (60 – 100) (8 nodes in the final softmax layer). It is very difficult to accurately guess an exact age from a single image because of factors like makeup, lighting, obstructions, and facial expressions. And so, I made this a classification problem instead of making it one of regression.

For this python project, I had used the Adience dataset; the dataset is available in the public domain. This dataset serves as a benchmark for face photos and is inclusive of various real-world imaging conditions like noise, lighting, pose, and appearance. The images have been collected from Flickr albums and distributed under the Creative Commons (CC) license. It has a total of 26,580 photos of 2,284 subjects in eight age ranges (as mentioned above) and is about 1GB in size. The models I used had been trained on this dataset.

Working : Open your Command Prompt or Terminal and change directory to the folder where all the files are present.

  • Detecting Gender and Age of face in Image Use Command :

python detect.py --image image_name

  • Detecting Gender and Age of face through webcam Use Command :

python detect.py

More Details: Age and Gender Detection

Submitted By


Interact With Quantum Computing Hardware Devices Using Amazon Bracket

Last Updated on May 3, 2021

About

The Amazon Braket Python SDK is an open source library that provides a framework that you can use to interact with quantum computing hardware devices through Amazon Braket.

Prerequisites

Before you begin working with the Amazon Braket SDK, make sure that you've installed or configured the following prerequisites.


Python 3.7.2 or greater

Download and install Python 3.7.2 or greater from Python.org.


Git

Install Git from https://git-scm.com/downloads. Installation instructions are provided on the download page.


IAM user or role with required permissions

As a managed service, Amazon Braket performs operations on your behalf on the AWS hardware that is managed by Amazon Braket. Amazon Braket can perform only operations that the user permits. You can read more about which permissions are necessary in the AWS Documentation.

The Braket Python SDK should not require any additional permissions aside from what is required for using Braket. However, if you are using an IAM role with a path in it, you should grant permission for iam:GetRole.

To learn more about IAM user, roles, and policies, see Adding and Removing IAM Identity Permissions.


Boto3 and setting up AWS credentials

Follow the installation instructions for Boto3 and setting up AWS credentials.

Note: Make sure that your AWS region is set to one supported by Amazon Braket. You can check this in your AWS configuration file, which is located by default at ~/.aws/config.


Configure your AWS account with the resources necessary for Amazon Braket

If you are new to Amazon Braket, onboard to the service and create the resources necessary to use Amazon Braket using the AWS console.


Installing the Amazon Braket Python SDK

The Amazon Braket Python SDK can be installed with pip as follows:

pip install amazon-braket-sdk

You can also install from source by cloning this repository and running a pip install command in the root directory of the repository:

git clone https://github.com/aws/amazon-braket-sdk-python.git
cd amazon-braket-sdk-python
pip install .


Check the version you have installed

You can view the version of the amazon-braket-sdk you have installed by using the following command:

pip show amazon-braket-sdk

You can also check your version of amazon-braket-sdk from within Python:

>>> import braket._sdk as braket_sdk
>>> braket_sdk.__version__

Usage


Running a circuit on an AWS simulator

import boto3
from braket.aws import AwsDevice
from braket.circuits import Circuit

device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
s3_folder = ("amazon-braket-Your-Bucket-Name", "folder-name") # Use the S3 bucket you created during onboarding

bell = Circuit().h(0).cnot(0, 1)
task = device.run(bell, s3_folder, shots=100)
print(task.result().measurement_counts)

The code sample imports the Amazon Braket framework, then defines the device to use (the SV1 AWS simulator). The s3_folder statement defines the Amazon S3 bucket for the task result and the folder in the bucket to store the task result. This folder is created when you run the task. It then creates a Bell Pair circuit, executes the circuit on the simulator and prints the results of the job.

More Details: Interact with Quantum Computing Hardware Devices using Amazon Bracket

Submitted By


Binance Trading Bot | Built With React.Js

Last Updated on May 3, 2021

About

Automated Binance trading bot with trailing buy/sell strategy

How it works


Trailing Buy/Sell Bot

This bot is using the concept of trailing buy/sell order which allows following the price fall/rise.

  • The bot can monitor multiple symbols. Each symbol will be monitored per second.
  • The bot is only tested and working with USDT pair in the FIAT market such as BTCUSDT, ETHUSDT. You can add more FIAT symbols like BUSD, AUD from the frontend. However, I didn't test in the live server. So use with your own risk.
  • The bot is using MongoDB to provide a persistence database. However, it does not use the latest MongoDB to support Raspberry Pi 32bit. Used MongoDB version is 3.2.20, which is provided by apcheamitru.


Buy Signal

The bot will continuously monitor the lowest value for the period of the candles. Once the current price reaches the lowest price, then the bot will place a STOP-LOSS-LIMIT order to buy. If the current price continuously falls, then the bot will cancel the previous order and re-place the new STOP-LOSS-LIMIT order with the new price.

  • The bot will not place a buy order if has enough coin (typically over $10 worth) to sell when reaches the trigger price for selling.

Buy Scenario

Let say, if the buy configurations are set as below:

  • Maximum purchase amount: $50
  • Trigger percentage: 1.005 (0.5%)
  • Stop price percentage: 1.01 (1.0%)
  • Limit price percentage: 1.011 (1.1%)

And the market is as below:

  • Current price: $101
  • Lowest price: $100
  • Trigger price: $100.5

Then the bot will not place an order because the trigger price ($100.5) is less than the current price ($101).

In the next tick, the market changes as below:

  • Current price: $100
  • Lowest price: $100
  • Trigger price: $100.5

The bot will place new STOP-LOSS-LIMIT order for buying because the current price ($100) is less than the trigger price ($100.5). For the simple calculation, I do not take an account for the commission. In real trading, the quantity may be different. The new buy order will be placed as below:

  • Stop price: $100 * 1.01 = $101
  • Limit price: $100 * 1.011 = $101.1
  • Quantity: 0.49

In the next tick, the market changes as below:

  • Current price: $99
  • Current limit price: $99 * 1.011 = 100.089
  • Open order stop price: $101

As the open order's stop price ($101) is higher than the current limit price ($100.089), the bot will cancel the open order and place new STOP-LOSS-LIMIT order as below:

  • Stop price: $99 * 1.01 = $99.99
  • Limit price: $99 * 1.011 = $100.089
  • Quantity: 0.49

If the price continuously falls, then the new buy order will be placed with the new price.

And if the market changes as below in the next tick:

  • Current price: $100

Then the current price reaches the stop price ($99.99); hence, the order will be executed with the limit price ($100.089).


Sell Signal

If there is enough balance for selling and the last buy price is recorded in the bot, then the bot will start monitoring the sell signal. Once the current price reaches the trigger price, then the bot will place a STOP-LOSS-LIMIT order to sell. If the current price continuously rises, then the bot will cancel the previous order and re-place the new STOP-LOSS-LIMIT order with the new price.

  • If the coin is worth less than typically $10 (minimum notional value), then the bot will remove the last buy price because Binance does not allow to place an order of less than $10.
  • If the bot does not have a record for the last buy price, the bot will not sell the coin.


Sell Scenario

Let say, if the sell configurations are set as below:

  • Trigger percentage: 1.05 (5.0%)
  • Stop price percentage: 0.98 (-2.0%)
  • Limit price percentage: 0.979 (-2.1%)

And the market is as below:

  • Coin owned: 0.5
  • Current price: $100
  • Last buy price: $100
  • Trigger price: $100 * 1.05 = $105

Then the bot will not place an order because the trigger price ($105) is higher than the current price ($100).

If the price is continuously falling, then the bot will keep monitoring until the price reaches the trigger price.

In the next tick, the market changes as below:

  • Current price: $105
  • Trigger price: $105

The bot will place new STOP-LOSS-LIMIT order for selling because the current price ($105) is higher or equal than the trigger price ($105). For the simple calculation, I do not take an account for the commission. In real trading, the quantity may be different. The new sell order will be placed as below:

  • Stop price: $105 * 0.98 = $102.9
  • Limit price: $105 * 0.979 = $102.795
  • Quantity: 0.5

In the next tick, the market changes as below:

  • Current price: $106
  • Current limit price: $103.774
  • Open order stop price: $102.29

As the open order's stop price ($102.29) is less than the current limit price ($103.774), the bot will cancel the open order and place new STOP-LOSS-LIMIT order as below:

  • Stop price: $106 * 0.98 = $103.88
  • Limit price: $106 * 0.979 = $103.774
  • Quantity: 0.5

If the price continuously rises, then the new sell order will be placed with the new price.

And if the market changes as below in the next tick:

  • Current price: $103

The the current price reaches the stop price ($103.88); hence, the order will be executed with the limit price ($103.774).


Frontend + WebSocket

React.js based frontend communicating via Web Socket:

  • List monitoring coins with buy/sell signals/open orders
  • View account balances
  • Manage global/symbol settings
  • Delete caches that are not monitored
  • Link to public URL
  • Support Add to Home Screen


More Details: Binance Trading Bot | Built with React.js

Submitted By