Skip to content

Commit 4f20135

Browse files
committed
changes
1 parent fddda39 commit 4f20135

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

MachineLearning Projects/Landmark Recognition using TensorFlow/main.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
import PIL
3+
import tensorflow as tf
4+
import tensorflow_hub as hub
5+
import numpy as np
6+
import pandas as pd
7+
from geopy.geocoders import Nominatim
8+
9+
model_url = 'https://tfhub.dev/google/on_device_vision/classifier/landmarks_classifier_asia_V1/1'
10+
labels = 'landmarks_classifier_asia_V1_label_map.csv'
11+
df = pd.read_csv(labels)
12+
labels = dict(zip(df.id, df.name))
13+
14+
def image_processing(image):
15+
image = "taj_mahal.jpg"
16+
img_shape = (321, 321)
17+
classifier = tf.keras.Sequential(
18+
[hub.KerasLayer(model_url, input_shape=img_shape + (3,), output_key="predictions:logits")])
19+
img = PIL.Image.open(image)
20+
img = img.resize(img_shape)
21+
img1 = img
22+
img = np.array(img) / 255.0
23+
img = img[np.newaxis]
24+
result = classifier.predict(img)
25+
fresult = labels[np.argmax(result)],img1
26+
print("Prediction Location is ",fresult[0])
27+
geolocator = Nominatim(user_agent="Your_Name")
28+
location = geolocator.geocode(fresult[0])
29+
floc = location.address,location.latitude, location.longitude
30+
print(location.address,location.latitude, location.longitude)
31+
32+
33+
def run():
34+
35+
img_file = 'taj.jpg'
36+
image_processing(img_file)
37+
Loading

0 commit comments

Comments
 (0)