Tuesday, August 15, 2023

Super Image Resolution By Artificial Intelligence Deep Learning

 Artificial Intelligence Super Image Resolution

super image

Upscale From 565 x 559 To 2260 x 2236

Super Image Resolution Artificial Intelligence Deep Learning


Super Resolution Image By Deep Learning Library EDSR_x4 :-

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 :


Step : 1

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. 


FACE ATTENDENCE SYSTEM MAKING LOGIC

FACE RECOGNITION SYSTEM THAT MACHING FACE FROM STORED MULTIPLE PERSON IMAGE WITH MAXIMUM ACCURACY 



Python Code Is Now Here  : (Write and Test It Proper Indentation.)

import cv2

import face_recognition

import os

import numpy as np

# Load the images from the folder

folder_path = '../userPhoto'

image_files = os.listdir(folder_path)


# Initialize arrays to store known face encodings and names

known_encodings = []

known_names = []

known_images = []


# Load the known face images and compute their encodings

for image_file in image_files:

    image_path = os.path.join(folder_path, image_file)

    image = face_recognition.load_image_file(image_path)

    face_locations = face_recognition.face_locations(image)


    if len(face_locations) > 0:

        encoding = face_recognition.face_encodings(image, face_locations)[0]

        known_encodings.append(encoding)

        known_names.append(os.path.splitext(image_file)[0])

        known_images.append(cv2.resize(image, (100, 100)))  # Resize image for thumbnail display


# Initialize the webcam

video_capture = cv2.VideoCapture(0)


while True:

    # Capture frame-by-frame from the webcam

    ret, frame = video_capture.read()


    # Convert the frame to RGB for face recognition

    rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)


    # Detect faces in the frame

    face_locations = face_recognition.face_locations(rgb_frame)

    face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)


    # Iterate over detected faces

    for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):

        # Compare the face with known encodings

        distances = face_recognition.face_distance(known_encodings, face_encoding)

        min_distance_index = np.argmin(distances)

        min_distance = distances[min_distance_index]


        if min_distance <= 0.45:  # Adjust the threshold as needed

            name = known_names[min_distance_index]

            accuracy = (1 - min_distance) * 100  # Calculate accuracy percentage

            thumbnail = known_images[min_distance_index]


            # Draw a rectangle around the face

            cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0), 2)


            # Display the name and accuracy below the face rectangle

            text = f"{name}: {accuracy:.2f}%"

            cv2.putText(frame, text, (left, bottom + 20), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 1)


            # Display the thumbnail image in the top right corner

            frame[10:110, frame.shape[1] - 110:frame.shape[1] - 10] = thumbnail

        else:

            name = "Unknown"


            # Draw a rectangle around the face

            cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)


            # Display the name below the face rectangle

            cv2.putText(frame, name, (left, bottom + 20), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 1)


    # Display the resulting frame

    cv2.imshow('Face Recognition', frame)


    # Quit the program if 'q' is pressed

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break


# Release the webcam and close windows

video_capture.release()

cv2.destroyAllWindows()


Tuesday, August 8, 2023

Time Attendance Machine Data Fetching Using PHP Code




In php.ini configure :- 
[semi colon must remove from these DLL File and Save INI File]
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll

Now You Can Get User Data By This PHP Code :Required zklibrary File


<?php
include "zklibrary.php";
$zk = new ZKLibrary('192.168.1.7', 4370);
$zk->connect();
$zk->disableDevice();

$users = $zk->getUser();

$useridname= [[]];
  foreach($users as $key=>$user)
{
$useridname[$key][0] = $user[0];
$useridname[$key][1] = $user[1];

}
//echo count($useridname);


$attendance = $zk->getAttendance();

?>
<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
<thead>
  <tr>
    <td width="25">No</td>
    <td>ID</td>
    <td>Name</td>
    <td>Role</td>
    <td>Date</td>
     <td>Time</td>
  </tr>
</thead>

<tbody>
<?php
$no = 0;
foreach($attendance as $key=>$user)
{
  $no++;
  if( date( "d-m-Y", strtotime( $user[3] )) ==date("d-m-Y") ){
?>

  <tr>
    <td align="right"><?php echo $no;?></td>
    <td><?php echo $user[1];?></td>
<?php
for($x=0;$x<count($useridname);$x++){
if($useridname[$x][0] == $user[1]){
?>
    <td><?php echo $useridname[$x][1];?></td>
<?php
}
}
?>
    <td><?php echo $user[2];?></td>
<td><?php echo date( "d-m-Y", strtotime( $user[3] ) ) ?></td>
     <td><?php echo date( "H:i:s", strtotime( $user[3] ) ) ?></td>
  </tr>

<?php
}
}
?>

</tbody>
</table>
<?php

$zk->enableDevice();
$zk->disconnect();

?>

Friday, August 4, 2023

Big Size MYSQL Upload XAMPP phpMyAdmin Panel

XAMPP Apache + MariaDB + PHP 

Main Problem Is That Big Size MYSQL File Not Uploaded or Import in phpMyAdmin Panel.

Solving Technique Here :-

Try these different settings in C:\wamp\bin\apache\apache2.2.6\bin\php.ini

Find:
post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

Change to:
post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M

And add this to C:\wamp\bin\mysql\mysql5.0.45\my.ini:

max_allowed_packet = 200M

Set Only 3 Parameters from php.ini file of your server

A. max_execution_time = 3000000 (Set as per your requirment)

B. post_max_size = 4096M

C. upload_max_filesize = 4096M

Edit C:\xampp\phpMyAdmin\libraries\config.default.php Page

$cfg['ExecTimeLimit'] = 0;

Python Blitz Bits: Zippy Snippets & Spark Projects for Instant Coding Wins

  Python Blitz Bits: Zippy Snippets & Spark Projects for Instant Coding Wins