Assignment 6.3.pdf

D

big data

Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/r
esnet/resnet50_weights_tf_dim_ordering_tf_kernels.h5

102973440/102967424 [==============================] - 153s 1us/step

('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image
s/cat1.PNG', [[('n02124075', 'Egyptian_cat', 0.40473214), ('n02123045', 'tabby', 0.3
7820032), ('n02123159', 'tiger_cat', 0.18440679), ('n02127052', 'lynx', 0.02030049),
('n02120505', 'grey_fox', 0.0031651843), ('n02356798', 'fox_squirrel', 0.000663975
2), ('n02129604', 'tiger', 0.0004948665), ('n02128757', 'snow_leopard', 0.0004507356
2), ('n03958227', 'plastic_bag', 0.00036802635), ('n02128385', 'leopard', 0.00035691
64)]])

In [1]: import glob, os

import numpy as np

from keras.preprocessing.image import load_img

from keras.preprocessing.image import img_to_array

from keras.applications.resnet50 import preprocess_input

from keras.applications.imagenet_utils import preprocess_input,decode_predictions

import matplotlib.pyplot as plt

from tensorflow.keras.applications import resnet50

resnet_model = resnet50.ResNet50(weights='imagenet')

In [2]: def run_prediction(filename):

input_image = load_img(filename, target_size=(224, 224))

plt.imshow(input_image)

plt.show()



# convert the image to a numpy array

numpy_image = img_to_array(input_image)

image_batch = np.expand_dims(numpy_image,axis=0)

image_procesed= preprocess_input(image_batch)

prediction=resnet_model.predict(image_procesed)

output=filename, decode_predictions(prediction, top=10)

print(output)

with open('Results/predictions/resnet50/results.txt', 'a') as f:

f.writelines(str(output))













In [5]: filename = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment
run_prediction(filename)

In [6]: filename2 = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignmen
run_prediction(filename2)
('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image
s/cat2.PNG', [[('n02123045', 'tabby', 0.6036403), ('n02124075', 'Egyptian_cat', 0.30
550975), ('n02123159', 'tiger_cat', 0.023157293), ('n02127052', 'lynx', 0.00862331
1), ('n04493381', 'tub', 0.005825389), ('n02909870', 'bucket', 0.004084795), ('n0348
2405', 'hamper', 0.003631829), ('n02123394', 'Persian_cat', 0.0030924305), ('n079308
64', 'cup', 0.0030116315), ('n04209239', 'shower_curtain', 0.0025875547)]])

('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image
s/human.PNG', [[('n03617480', 'kimono', 0.2810746), ('n02963159', 'cardigan', 0.0987
3904), ('n04136333', 'sarong', 0.09751529), ('n03866082', 'overskirt', 0.08254426),
('n03877472', 'pajama', 0.065047406), ('n03450230', 'gown', 0.051486332), ('n0431117
4', 'steel_drum', 0.026140286), ('n04325704', 'stole', 0.014662189), ('n03534580',
'hoopskirt', 0.014379749), ('n02948072', 'candle', 0.013780539)]])

In [8]: filename3 = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignmen
run_prediction(filename3)

In [ ]:

Recomendados

Assignment7.pdfAssignment7.pdf
Assignment7.pdfdash41
37 views6 Folien
Assignment 6.2b.pdfAssignment 6.2b.pdf
Assignment 6.2b.pdfdash41
9 views4 Folien
Assignment 6.2a.pdfAssignment 6.2a.pdf
Assignment 6.2a.pdfdash41
10 views4 Folien
Assignment 6.1.pdfAssignment 6.1.pdf
Assignment 6.1.pdfdash41
14 views4 Folien
Assignment 5.3.pdfAssignment 5.3.pdf
Assignment 5.3.pdfdash41
19 views4 Folien
Assignment 5.2.pdfAssignment 5.2.pdf
Assignment 5.2.pdfdash41
4 views7 Folien

Más contenido relacionado

Último(20)

Journey of Generative AIJourney of Generative AI
Journey of Generative AI
thomasjvarghese4918 views
Microsoft Fabric.pptxMicrosoft Fabric.pptx
Microsoft Fabric.pptx
Shruti Chaurasia19 views
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
Abdul salam 12 views
PROGRAMME.pdfPROGRAMME.pdf
PROGRAMME.pdf
HiNedHaJar14 views
Survey on Factuality in LLM's.pptxSurvey on Factuality in LLM's.pptx
Survey on Factuality in LLM's.pptx
NeethaSherra15 views
3196 The Case of The East River3196 The Case of The East River
3196 The Case of The East River
ErickANDRADE9011 views
ColonyOSColonyOS
ColonyOS
JohanKristiansson69 views
PTicketInput.pdfPTicketInput.pdf
PTicketInput.pdf
stuartmcphersonflipm314 views
MOSORE_BRESCIAMOSORE_BRESCIA
MOSORE_BRESCIA
Federico Karagulian5 views
Introduction to Microsoft Fabric.pdfIntroduction to Microsoft Fabric.pdf
Introduction to Microsoft Fabric.pdf
ishaniuudeshika21 views
Building Real-Time Travel AlertsBuilding Real-Time Travel Alerts
Building Real-Time Travel Alerts
Timothy Spann102 views

Destacado(20)

How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC4.1K views
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy82.1K views
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani30.3K views
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking6.9K views
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from Prince
Empowered Presentations142.8K views
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views

Assignment 6.3.pdf

  • 1. Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/r esnet/resnet50_weights_tf_dim_ordering_tf_kernels.h5 102973440/102967424 [==============================] - 153s 1us/step ('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image s/cat1.PNG', [[('n02124075', 'Egyptian_cat', 0.40473214), ('n02123045', 'tabby', 0.3 7820032), ('n02123159', 'tiger_cat', 0.18440679), ('n02127052', 'lynx', 0.02030049), ('n02120505', 'grey_fox', 0.0031651843), ('n02356798', 'fox_squirrel', 0.000663975 2), ('n02129604', 'tiger', 0.0004948665), ('n02128757', 'snow_leopard', 0.0004507356 2), ('n03958227', 'plastic_bag', 0.00036802635), ('n02128385', 'leopard', 0.00035691 64)]]) In [1]: import glob, os import numpy as np from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array from keras.applications.resnet50 import preprocess_input from keras.applications.imagenet_utils import preprocess_input,decode_predictions import matplotlib.pyplot as plt from tensorflow.keras.applications import resnet50 resnet_model = resnet50.ResNet50(weights='imagenet') In [2]: def run_prediction(filename): input_image = load_img(filename, target_size=(224, 224)) plt.imshow(input_image) plt.show() # convert the image to a numpy array numpy_image = img_to_array(input_image) image_batch = np.expand_dims(numpy_image,axis=0) image_procesed= preprocess_input(image_batch) prediction=resnet_model.predict(image_procesed) output=filename, decode_predictions(prediction, top=10) print(output) with open('Results/predictions/resnet50/results.txt', 'a') as f: f.writelines(str(output)) In [5]: filename = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment run_prediction(filename) In [6]: filename2 = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignmen run_prediction(filename2)
  • 2. ('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image s/cat2.PNG', [[('n02123045', 'tabby', 0.6036403), ('n02124075', 'Egyptian_cat', 0.30 550975), ('n02123159', 'tiger_cat', 0.023157293), ('n02127052', 'lynx', 0.00862331 1), ('n04493381', 'tub', 0.005825389), ('n02909870', 'bucket', 0.004084795), ('n0348 2405', 'hamper', 0.003631829), ('n02123394', 'Persian_cat', 0.0030924305), ('n079308 64', 'cup', 0.0030116315), ('n04209239', 'shower_curtain', 0.0025875547)]]) ('C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignment 06/image s/human.PNG', [[('n03617480', 'kimono', 0.2810746), ('n02963159', 'cardigan', 0.0987 3904), ('n04136333', 'sarong', 0.09751529), ('n03866082', 'overskirt', 0.08254426), ('n03877472', 'pajama', 0.065047406), ('n03450230', 'gown', 0.051486332), ('n0431117 4', 'steel_drum', 0.026140286), ('n04325704', 'stole', 0.014662189), ('n03534580', 'hoopskirt', 0.014379749), ('n02948072', 'candle', 0.013780539)]]) In [8]: filename3 = 'C:/Users/walee/Desktop/Adil Khan/Big Data/DSC 650/Assignments/Assignmen run_prediction(filename3) In [ ]: