-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastai_model.py
59 lines (35 loc) · 1.21 KB
/
fastai_model.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""fastai model.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1JvEq1V2PXX7faevDT59eozuH9twVbwtr
"""
import argparse
from fastai import *
from fastai.vision import *
import argparse
# Initialize parser
parser = argparse.ArgumentParser()
# Adding optional argument
parser.add_argument("-m", "--model", help="Model Path")
parser.add_argument("-i", "--image")
# Read arguments from command line
args = parser.parse_args()
im_path = args.image
model_path = args.model
learn = load_learner(model_path, "model.pkl")
pred = learn.predict(open_image(im_path))[2].numpy().tolist()
print(pred)
# # Initialize parser
# parser = argparse.ArgumentParser()
# # Adding optional argument
# parser.add_argument("-m", "--model", help="Model Path")
# parser.add_argument("-i", "--image")
# # Read arguments from command line
# args = parser.parse_args()
# im_path = args.image
# model_path = args.model
# learn = load_learner(model_path, "model.pkl")
# pred = learn.predict(open_image(im_path))[2].numpy().tolist()
# print(pred)
# #!python / content/script.py - -image '/content/drive/MyDrive/index.jpg' - -model '/content/drive/MyDrive'