Image Super Resolution Using Autoencoders In KerasLast Updated on May 3, 2021
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 * scale_percent / 100) height = int(image.shape * 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 * 100 / scale_percent) height = int(small_image.shape * 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): 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): temp = pixalate_image(val_x[i,:,:,:]) val_x_px.append(temp) val_x_px = np.array(val_x_px) #Distorted images
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!
Screenshot of the model summary
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.
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.
Helping The People Who Are In NeedLast Updated on May 8, 2021
"Anybody can help but the help at the right time brings the big difference. Anybody can help everybody but helping the needy brings the big difference".
As rightly quoted above, helping the needy at right time brings the huge impact on the society. On this pandemic situation we come across lot of people in a risk of losing their life though staying inside the home .The reason behind this is,not COVID-19 but POVERTY. There also exist people who is passionate to serve the society by providing the people needs .So we,the TEAM CRUTCH has decided to serve the society through our tech minds by designing the app called CRUTCH which act as bridge between the donor & recipient .
This application is built on top of PEGA platform version 8.4
The challenging task for us is making the live request ,choosing the most needful services,handling the services between donor & recipient .But as a team we were able to conquer the challenges in to fruitful product.
CRUTCH acts as a platform of sharing assets to needy people at right time from donors.
We had a great learning experience .We had a chance of experiencing activities,customizing harness & portal. .
Uniqueness of Our Application CRUTCH
Crutch provides the customer 6 services ,where the customer can chose any service through his/her interest.
Bringing the Need at your doorstep & right time.
Apart from donor & requester crutch has an additional feature of volunteer for people who is passionate in serving the society to assist donor & recipient in bringing their need at their doorstep a right time. Serve the society-tops the leader board. Crutch has an unique feature of maintaining leader board for volunteers on the basis of one who serves the best leads as top performer in leader board.
Crutch is a platform that extends help for the needy people at right time.The motive of crutch is to concatenate the demand & supply . The services available in this app includes Food Service,Education Service ,Cloth Service ,Blood donate/Receive (share blood ) service ,Organ donate /receive (share organ) service,Money (Crutch pay )service .
How Crutch Works
Customer can register as donor/recipient initially .while logging in the next time he has the option to change his role type if he wills. After logging in he can chose any of six exclusive services .If the customer acts as recipient he can request his/her need. The intimation about the request will be sent to all registered donors if any of the donor accepts to donate, then crutch provides them an option to chose Volunteer assistance .if he chooses volunteer service the crutch volunteer will help in delivering the requirement from donor to recipient at right time. Thereby crutch feed the needy people at right time. Crutch has verification team to ensure that details submitted by recipient doesn't contain any false information.
The crutch has 6 services apart from registration & Volunteer Survey & Feed the Need.The following is the detailed description of all case type.
1)Registration: The customer can sign in in to crutch application via registration case type. He has to specify his role type(donor/recipient) & service type(6 services) based on which the work group & workbaskets are assigned for them.They can change role type in future as well.After providing the preliminary details such as personal info,Organisation info(if he/she representing any org) & address details.After the approval by the admin crutch the access credentials are created for the customer.The case will not move to approval unless he accept terms & conditions of crutch . Innovation: We have implemented completion status- Progress bar for the customer to track his registration completion status
2)Feed The Need: The purpose of this case type is to help the needy people in choosing the service according to their need. Six exclusive services are shown to customer on their next login where he/she can choose one and proceed with flow.
Innovation: Six attractive icons are configured where the user clicks the Icon the corresponding case type begins.
3)Crutch Pay: The purpose of this case type is to donate/receive money .The recipient begins the case where he views all his details in editable format .They can edit it if necessary.The customer can raise money request for his own self or for his friend/relatives.In case of friend/relative .He has to provide their details.There are few predefined reasons present for requesting money such as requesting fund for orphanage/home, requesting fund for natural calamity,,requesting for illness/Accident .Customer can also provide his own reason of requesting by choosing others.He has to provide all the required info along with necessary documents.He will also specify his preferred timing for help.After his submission,there happens background verification process by crutch admin where all details are checked. The case proceeds forward only if details are true. Then on the successful completion of verification the intimation will be sent to all donors if any donors accepts he can confirm his own details and move for payment. Method of Payment can also be Negotiated by donor if he is comfortable with.After receiving the money the recipient fills the fullfilment and provide feedback.
Innovation:Modal dialog -Pop up for thanking the customer
4)Food Service: The donor /Recipient can begin the case by providing the Food details.If recipient begins the case it moves to donor for viewing the recipient details and if he accepts the request then it moves to gather delivery information.There the recipient has an option of requesting any volunteer service then the case routes to volunteer workbasket if any of the volunteer picks the work, then he confirms the donor& recipient address details and finally he delivers to them. If the donor begins the case he provides the details of donating food,the case routes to recipient workbasket . The recipient has an option of selecting self or volunteer service .If he goes for volunteer service ,then it routes to volunteer workbasket.if any of the volunteer picks the work, then he confirms the donor& recipient address details and finally he delivers to them.
5)Cloth Service: The donor /Recipient can begin the case by providing the Food details.If recipient begins the case it moves to donor for viewing the recipient details and if he accepts the request then it moves to gather delivery information.There the recipient has an option of requesting any volunteer service then the case routes to volunteer workbasket if any of the volunteer picks the work, then he confirms the donor& recipient address details and finally he delivers to them.If the donor begins the case he provides the details of donating cloth.the case routes to recipient workbasket .The recipient has an option of selecting self or volunteer service .If he goes for volunteer service ,then it routes to volunteer workbasket.if any of the volunteer picks the work, then he confirms the donor& recipient address details and finally he delivers to them.
6)Education Service: The recipient begins the case where he has the option to acts as referencer or self based on type of request he raise. If he is raising for him he can provide as self, if not he can act as referencer. He gives all his preliminary details & attach Necessary Documents.Then the case move forwards to background verification Process. Unless the background verification successfully completes the case does not move forward .On Successful completion ,it routes to donor workbasket.If any of the donor accept to provide contact details are shared with both.Then fulfillment details are received from recipient after receiving the help.
7)Share Blood: This case type can be accessed by donor/Recipient.If donor begins the case he can donate the blood by Providing all the necessary details .If in case of recipient begins the case ,he has two options either he can view the already donated blood details which matches his requirements or he can raise a new request.After his submission of request the case move forwards to donor where he can accept the request & confirm his details and also assist for volunteer service..thus,with help of volunteer support requirements are delivered from donor to recipient.
8)Share Organ: This case type can be accessed by donor/Recipient.If donor begins the case he need to provide his details If he had his organ registration certificate he need to attach it then the admin will review. Then the admin will approve /reject his request. If he does not have his organ registration certificate he can request for medical assistance.Now the hospital details are mailed to the donor. He have to visit the hospital within 5 days.Then the will check him and provide the certificate. If the case is begins by the recipient he can request for the organ.Noe he need to provide the required information and the certificate.Then the case will be routed to Donor hospital. If the donor is available the details will be send through mail.Then he will contact the hospital for further procedure. his hackathon is one of the memorable learning experience for our team .We had a great learning experience of new rules such as creating dynamic routing etc.
As a team we ensure to give our cent percent effort to bring solutions to the problems & Challenges prevail in the society.
AtmLast Updated on May 3, 2021
Me and my friends have done this project with the help of mentor assigned to us.The project is about the performance of ATM machine developed by Python.
For this project we imported sqlite3 and tkinter as tk. We used Tkinter for GUI applications.Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. We have created user defined functions such as creating_db, insert_money, insert_atm, check_100, check_200, check_500, check_2000,wd_money, update_bal and main_page. When we run the code the GUI application is created.In this application we can see a note as 'Welcome to ATM' and in the next lines we can see 100/-,200/-,500/- &2000/- notes. If we want to insert money we can click on the option called insert money, if we want to withdraw money we can click on withdraw at the same time if we want to check the availability of respective notes we can click on Check Availability beside the notes. After checking for the availability of notes the result will be displayed on the Python shell. This Python shell is also known as REPL (Read, Evaluate, Print, Loop), where it reads the command, evaluates the command, prints the result, and loop it back to read the command again.For every insert or withdraw update will be done. By using all this we can perform the operation that is required. All this transaction details will be stored in SQLite.
I hope this would be helpful for the public.
Python Snake GameLast Updated on May 3, 2021
This game reminds everyone their childhood memories.
In this snake game, the player has to move the snake to the fruit in order to eat it. The score will increase once the fruit is eaten. Also, the length of the snake will increase if the snake eats the fruit. The game will get over if the snake touches itself.
The turtle and random modules are used in this game project. So as to install these libraries, simply type “pip install turtle” and “pip install random” on the command prompt.
Turtle library allows us to create pictures, diagrams in a virtual form whereas random module gives the value between the given range of it.
There are 3 functions defined in this game which is “change”, “inside function”, and “move” function. In change function, the x-axis and y-axis are defined. In inside function, the logic of the game is written and in the move function, movement to the snake is given.
There are 4 keys mentioned in the code “right, left, up, down”.
If the player presses the right key, the snake will move to right direction, If the player presses the left key , the snake will move to left direction, If the player presses the up key , the snake will move to upward direction, If the player presses the down key , the snake will move to downward direction and if the snake touches itself the game will get over.
Design And Analysis Of Automobile ChasisLast Updated on May 3, 2021
Completed under the guidance of Dr. Shailesh Ganpule, Department of Mechanical and Industrial Engineering during August 2019 to November 2019. The objective of this design analysis is to find out the best material and most suitable cross-section for a common “Goods Carrier Truck” ladder chassis with the constraints of maximum shear stress, equivalent stress and deflection of the chassis under maximum load condition. In present the Ladder chassis which are used for making buses and trucks are C and I cross section type, but here we also analysed the Box type and Tube Type. In Trucks generally heavy amounts of loads are carried due to which there are always possibilities of being failure/fracture in the chassis/frame. Therefore Chassis with high strength cross section is needed to minimize the failures including factor of safety in design. The different vehicle chassis have been modeled by considering three different cross-sections namely C, I , Rectangular Box (Hollow) and Tubular type cross sections. The problem to be dealt with for this dissertation work is to Design and Analyze using suitable CAD software and Ansys 19.2 for ladder chassis. The report is the work performed towards the optimization of the Truck chassis with constraints of stiffness and strength. The modeling is done using Solid works, and analysis is done using Ansys 19.2 .. The overhangs of the chassis are calculated for the stresses and deflections analytically are compared with the results obtained with the analysis software. Involved in designing of Heavy Loaded Vehicle chassis in SolidWorks with stress simulation and strain analysis in Ansys. Carried out Failure Analysis using Von Mises Criterion to obtain their sustainability. Performed Convergence Analysis to select the most optimized model with the desired factor of safety. Compared software(practical) value obtained with theoretical value obtained.