Skip to content

Instantly share code, notes, and snippets.

View Sachin-crypto's full-sized avatar

Sachin Pal Sachin-crypto

View GitHub Profile
@Sachin-crypto
Sachin-crypto / append.py
Created March 23, 2023 17:01
A simple demonstration of list append()
# List of names
friends = ['Sachin', 'Rishu', 'Yashwant']
# Printing the original list
print('Original List:', friends)
# Appending an element
friends.append('Abhishek')
# Printing the updated list
print('New List: ', friends)
@Sachin-crypto
Sachin-crypto / extendd.py
Created March 23, 2023 17:00
A simple demonstration of list extend()
# List of names
friends = ['Sachin', 'Rishu', 'Yashwant']
# Printing the original list
print('Original List:', friends)
# Using extend() to extend the list
friends.extend(['Yogesh', 'Abhishek'])
# Printing the updated list
print('New List: ', friends)
@Sachin-crypto
Sachin-crypto / insertt.py
Created March 23, 2023 16:59
A simple demonstration of list insert()
# List of names
friends = ['Sachin', 'Rishu', 'Yashwant']
# Printing the original list
print('Original List:', friends)
# Inserting an element
friends.insert(1, 'Abhishek')
# Printing the updated list
print('New List: ', friends)
@Sachin-crypto
Sachin-crypto / adoption_pet.py
Created March 20, 2023 15:12
A simple python program to adopt a pet and the details will be entered in a file.
'''
A Python program to adopt a pet and appending the details in a file.
The entry can also be viewed by reading the file
'''
import datetime
# Defining main function
def get_pet(pet):
img_input = input("Enter the path of an image: ")
display_and_predict(img_input)
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
img_input = input("Enter the path of an image: ")
display_and_predict(img_input)
# Function to display and predicting the Image
def display_and_predict(img_path_input):
display_img = Image.open(img_path_input)
plt.imshow(display_img)
plt.show()
img = preprocess_img(img_path_input)
pred = predict_result(img)
print("Prediction: ", pred)
def predict_result(predict):
pred = my_model.predict(predict)
return np.argmax(pred[0], axis=-1)
def preprocess_img(img_path):
open_img = image.load_img(img_path, target_size=(224, 224))
img_arr = image.img_to_array(open_img)/255.0
img_reshape = img_arr.reshape(1, 224,224,3)
return img_reshape