This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def download_image(image): | |
| response = requests.get(image[0], stream=True) | |
| realname = ''.join(e for e in image[1] if e.isalnum()) | |
| file = open("C://images//bs//{}.jpg".format(realname), 'wb') | |
| response.raw.decode_content = True | |
| shutil.copyfileobj(response.raw, file) | |
| del response |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| image_info = [] | |
| for a in aas: | |
| image_tag = a.findChildren("img") | |
| image_info.append((image_tag[0]["src"], image_tag[0]["alt"])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| url = "https://rubikscode.net/" | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.text, "html.parser") | |
| aas = soup.find_all("a", class_='entry-featured-image-url') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bs4 import BeautifulSoup | |
| import requests | |
| import urllib.request | |
| import shutil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loss, accuracy = resnet.evaluate(data_loader.test_batches, steps = validation_steps) | |
| print("--------ResNet---------") | |
| print("Loss: {:.2f}".format(loss)) | |
| print("Accuracy: {:.2f}".format(accuracy)) | |
| print("---------------------------") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| history = resnet.fit(data_loader.train_batches, | |
| epochs=10, | |
| validation_data=data_loader.validation_batches) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| base_learning_rate = 0.0001 | |
| resnet = Wrapper(resnet_base) | |
| resnet.compile(optimizer=tf.keras.optimizers.RMSprop(lr=base_learning_rate), | |
| loss='binary_crossentropy', | |
| metrics=['accuracy']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resnet_base = tf.keras.applications.ResNet101V2(input_shape=IMG_SHAPE, include_top=False, weights='imagenet') | |
| resnet_base.trainable = True | |
| from_layer = 100 | |
| for layer in resnet_base.layers[:from_layer]: | |
| layer.trainable = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loss1, accuracy1 = vgg16.evaluate(data_loader.test_batches, steps = 20) | |
| loss2, accuracy2 = googlenet.evaluate(data_loader.test_batches, steps = 20) | |
| loss3, accuracy3 = resnet.evaluate(data_loader.test_batches, steps = 20) | |
| print("--------VGG16---------") | |
| print("Loss: {:.2f}".format(loss1)) | |
| print("Accuracy: {:.2f}".format(accuracy1)) | |
| print("---------------------------") | |
| print("--------GoogLeNet---------") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| history = resnet.fit(data_loader.train_batches, | |
| epochs=10, | |
| validation_data=data_loader.validation_batches) |