-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_download.py
36 lines (31 loc) · 1.34 KB
/
image_download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import pandas as pd
import urllib.request
# from ImageClassifier import CreateDataAndModel
from ImageClassifier import Run
import numpy as np
# df = pd.read_csv("data.csv",error_bad_lines=False)
# os.chdir('/home/naman/Desktop/image/')
# for url in df['img_url']:
# klass = url.split('/')[4]
# print(klass)
# try:
# os.mkdir(klass)
# except:
# pass
# os.chdir(f'/home/naman/Desktop/image/data/{klass}')
# try:
# urllib.request.urlretrieve(url, f"{url.split('/')[5]}.jpg")
# except:
# print('lite ho gaya',url)
# pass
# os.chdir('/home/naman/Desktop/image/data')
# main = CreateDataAndModel(file_path="/home/naman/Desktop/image/data/", model_file_name_to_save="model.hdf5", init_lr=0.0001, epochs=10, batch_size=25)
# # Here "./data/" is the data folder where we have the label folder- "apple" and "banana" (Remember to include a "/" after the folder like "./data/" ). Basically, you have to give the data folder path where you have the label folders, it can also be like "./seg_pred/seg_pred/".
# main.create() # This will create the data and the model for you.
r = Run(model_file_name="model.hdf5") # The model file in your current directory
def pred(loc='/home/naman/Desktop/image/data/aeroplane/2008_001380.jpg.jpg'):
pred = r.run(loc)
print(pred)
return pred
pred()