Rimi commited on
Commit
42eed67
·
1 Parent(s): 6542239

Add application file

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import flask
2
+ import gradio as gr
3
+ from fastai.vision.all import load_learner
4
+ from fastai import *
5
+ import torch
6
+ import os
7
+ from PIL import Image
8
+ import pathlib
9
+
10
+ temp = pathlib.PosixPath
11
+ pathlib.PosixPath = pathlib.WindowsPath
12
+
13
+ model_path = 'C:\pythons\Deep Learning\insect\insects-recognizer\models\model3-86_.pkl'
14
+
15
+ model = load_learner(model_path)
16
+
17
+ def result(path):
18
+
19
+ pred,_,probability = model.predict(path)
20
+
21
+ return {pred: float(probability.max())}
22
+
23
+ path = 'test_images/'
24
+
25
+ image_path = []
26
+
27
+ for i in os.listdir(path):
28
+ image_path.append(path+i)
29
+
30
+
31
+ image = gr.inputs.Image(shape =(128,128))
32
+ label = gr.outputs.Label()
33
+
34
+ iface = gr.Interface(fn=result, inputs=image, outputs=label, examples = image_path)
35
+ iface.launch(inline = False)