Artificial Intelligence and Programming Language Tips and Tricks
Different type of difficulties and problem faced by programmer, super user and AI Creator on digital world. Some of technical solutions that faced and overcome or solve by me with this tips and tricks.
Tuesday, September 3, 2024
Monday, August 19, 2024
Monday, August 21, 2023
R Language Fetching Data From Excel Sheet
R Language Query Data on Excel Sheet Column Header :-
Install xlsx Package :-
install.packages("xlsx") Verify and Load the "xlsx" Package:- # Verify the package is installed. any(grepl("xlsx",installed.packages())) # Load the library into R workspace. library("xlsx") Reading the Excel File:- # Read the first worksheet in the file input.xlsx. data <- read.xlsx("student_list.xlsx", sheetIndex = 1) print(data) #Data Query in Excel Sheet Column Header :- retval <- subset(data, Blood.Group == "O+") print(retval)
Reading a CSV File :-
data <- read.csv("Mutual Fund List.csv")
print(data) print(is.data.frame(data)) print(ncol(data)) print(nrow(data)) # Get the max salary from data frame. sal <- max(data$salary) print(sal) # Get the max salary from data frame. sal <- max(data$salary) # Get the person detail having max salary. retval <- subset(data, salary == max(salary)) print(retval) #Get all the people working in IT department retval <- subset( data, dept == "IT") print(retval) #Get the persons in IT department whose salary is greater than 600 info <- subset(data, salary > 600 & dept == "IT") print(info) #Get the people who joined on or after 2014 retval <- subset(data, as.Date(start_date) > as.Date("2014-01-01")) print(retval) # Write filtered data into a new file. write.csv(retval,"output.csv") newdata <- read.csv("output.csv") print(newdata)
Tuesday, August 15, 2023
Super Image Resolution By Artificial Intelligence Deep Learning
Artificial Intelligence Super Image Resolution
Upscale From 565 x 559 To 2260 x 2236
import cv2
from cv2 import dnn_superres
# initialize super resolution object
sr = dnn_superres.DnnSuperResImpl_create()
# read the model
path = 'EDSR_x4.pb'
sr.readModel(path)
# set the model and scale
sr.setModel('edsr', 4)
# if you have cuda support
sr.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
sr.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
# load the image
image = cv2.imread('../MessageMP3/lowimg.jpg')
# upsample the image
upscaled = sr.upsample(image)
# save the upscaled image
cv2.imwrite('../MessageMP3/high.jpg', upscaled)
# traditional method - bicubic
bicubic = cv2.resize(image, (upscaled.shape[1], upscaled.shape[0]), interpolation=cv2.INTER_CUBIC)
# save the image
cv2.imwrite('../MessageMP3/highbicube.jpg', bicubic)
Super Resolution Image By Deep Learning Library LapSRN_x8 :-
import cv2
from cv2 import dnn_superres
# initialize super resolution object
sr = dnn_superres.DnnSuperResImpl_create()
# read the model
path = 'LapSRN_x8.pb'
sr.readModel(path)
# set the model and scale
sr.setModel('lapsrn', 8)
# if you have cuda support
sr.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
sr.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
# load the image
image = cv2.imread('MessageMP3/lowimg.jpg')
# upsample the image
upscaled = sr.upsample(image)
# save the upscaled image
cv2.imwrite('MessageMP3/high.jpg', upscaled)
# traditional method - bicubic
bicubic = cv2.resize(image, (upscaled.shape[1], upscaled.shape[0]), interpolation=cv2.INTER_CUBIC)
# save the image
cv2.imwrite('MessageMP3/highbicube.jpg', bicubic)
Super Resolution Image By Deep Learning Library FSRCNN_x3 :-
import cv2
import matplotlib.pyplot as plt
img = cv2.imread("../MessageMP3/lowimg.jpg")
sr = cv2.dnn_superres.DnnSuperResImpl_create()
path = "FSRCNN_x3.pb"
sr.readModel(path)
sr.setModel("fsrcnn",3)
result = sr.upsample(img)
cv2.imwrite("../MessageMP3/highimg1.jpg",result)
Super Resolution Image By Deep Learning Library FSRCNN_x4 :-
import cv2
import matplotlib.pyplot as plt
img = cv2.imread("../MessageMP3/lowimg.jpg")
sr = cv2.dnn_superres.DnnSuperResImpl_create()
path = "FSRCNN_x4.pb"
sr.readModel(path)
sr.setModel("fsrcnn",4)
result = sr.upsample(img)
cv2.imwrite("../MessageMP3/highimg1.jpg",result)
Monday, August 14, 2023
MySQL Database and Table Query
MySQL Database and Table Query For Getting Desired Result.
Rename A Table MySQL :-
rename TABLE super_category to category
Rename A Table Column Name MySQL :-
ALTER TABLE category change name category_name varchar(50)
Create Table Copy with Data without inherit indexes and auto_increment:-
CREATE TABLE master_category SELECT * FROM category
Create Table Copy only Structure without Data inherit indexes and auto_increment :-
CREATE TABLE master_category like category
One Table to Another Table Copy Selected Column Data :-
INSERT INTO master_category(description, create_date)
SELECT description,create_date FROM category
One Table to Another Table Copy All Data :-
INSERT master_category SELECT * FROM category
Create Table with Selected Column Copy from Another Table with Data :-
CREATE TABLE category SELECT id, category_name FROM super_category
Create Table with Selected Column Copy from Another Table only Structure :
CREATE TABLE super_category SELECT id, category_name FROM category limit 0
One Database to Another Database Create Table Copy with Data :-
CREATE TABLE profile.master_category SELECT * FROM king.category
One Database to Another Database Create Table Copy Structure :-
CREATE TABLE profile.super_category like king.category
One Database Table Selected Column Data Copy to Another Databse Table :-
INSERT INTO profile.super_category(description, create_date)
SELECT description,create_date FROM king.category
Delete Table All Records :-
TRUNCATE TABLE master_category
Delete Complete Table :-
DROP TABLE master_category
Add New Column in Existing Table :-
ALTER TABLE super_category ADD created_at DATETIME
ALTER TABLE super_category ADD sub_category VARCHAR(100) NOT NULL
ALTER TABLE super_category ADD active BOOLEAN DEFAULT TRUE
ALTER TABLE super_category ADD stock int(11) DEFAULT 0
Delete Selected Column from Existing Table :-
ALTER TABLE super_category DROP created_at
ALTER TABLE super_category DROP sub_category
ALTER TABLE super_category DROP active
Add a Value to a Selected Column for all records :-
update super_category set stock=10
Add DEFAULT value for Selected Column :-
ALTER TABLE super_category ALTER stock SET DEFAULT 15
ALTER TABLE super_category MODIFY stock INT NOT NULL
ALTER TABLE super_category MODIFY stock INT DEFAULT 0
Delete a Default Value From a Column :-
ALTER TABLE super_category ALTER stock DROP DEFAULT
Add Auto Increment to Selected Column :-
ALTER TABLE category AUTO_INCREMENT=1000
Create a View :-
Create view tbl_category as select * from category
Show a View :-
select * from tbl_category
Conditional Sum for Employee PaySlip Record How many Times :-
SELECT sum(if(emp_system_code='EMP-008',1,0)) as "SANAT DE",
sum(if(emp_system_code='EMP-002',1,0)) as AVALEONG
FROM paysilp_employee_details
Find duplicate values in one column :-
SELECT * FROM contacts ORDER BY email
SELECT email,COUNT(email) FROM contacts GROUP BY email HAVING COUNT(email) > 1
Find duplicate values in multiple columns :-
SELECT first_name, COUNT(first_name),last_name,COUNT(last_name),email,
COUNT(email) FROM contacts GROUP BY first_name,last_name,email
HAVING COUNT(first_name) > 1 AND COUNT(last_name) > 1 AND COUNT(email) > 1;
Sunday, August 13, 2023
R Language Fetching Data From MySql Table
R Language How to Get Data From MySql Table :
install.packages("RMySQL")
library("RMySQL")
Step : 2
Create a connection Object to MySQL database.
We will connect to the sample database named
"DB_school" that comes with MySql installation.mysqlconnection = dbConnect(MySQL(),user='root',password='',dbname='DB_school',host='localhost')
Step : 3
View List the tables available in this database.
dbListTables(mysqlconnection)Step : 4
Query the "register" tables to get all the rows.
result = dbSendQuery(mysqlconnection, "select * from registerdb")Step : 5
Store the result in a R data frame object. n = 5 is used to
fetch first 5 rows.data.frame = fetch(result, n = 5) print(data.frame)
Step : 6
We can pass any valid select query to get the result.
result = dbSendQuery(mysqlconnection, "select * from registerdb where YYYY = '2010'")
Step : 7
Fetch all the records(with n = -1) and store it as a data frame.
data.frame = fetch(result, n = -1) print(data.frame)
Thursday, August 10, 2023
Face Recognition Smart Attendance System
FACE ATTENDANCE SYSTEM DEMOSTRATION :
STEP : 1
CHECKING WEBCAM.
STEP : 2
CAPTURE FACE BY WEBCAM & STORED IN A FOLDER.
STEP : 3
TRAINED THE FACE IMAGES BY AI.
STEP : 4
NOW RECOGNISED FACE BY WEBCAM WITH AI.
Subscribe to:
Posts (Atom)
-
MySQL Database and Table Query For Getting Desired Result. Rename A Table MySQL :- rename TABLE super_category to category Rename A Tabl...
-
R Language Query Data on Excel Sheet Column Header :- Install xlsx Package :- install.packages("xlsx") Verify and Load the &quo...
-
Artificial Intelligence Super Image Resolution Upscale From 565 x 559 To 2260 x 2236 Super Resolution Image By Deep Learning Library E...