VanAnh commited on
Commit
e4eed16
·
1 Parent(s): e761131

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -19
app.py CHANGED
@@ -1,28 +1,10 @@
1
  import gradio as gr
2
- import numpy as np # linear algebra
3
- import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
4
- import os # operating system
5
  from fastai.vision.all import * # fastai stuff
6
- import gradio as gr
7
 
8
  def is_cat(x): return x[0].isupper()
9
 
10
- dls = ImageDataLoaders.from_name_func('.',
11
- get_image_files(path), valid_pct=0.2, seed=42,
12
- label_func=is_cat,
13
- item_tfms=Resize(192))
14
-
15
- learn = vision_learner(dls, resnet18, metrics=error_rate)
16
- # fine_tune() method automatically uses best practices for fine tuning
17
- # a pre-trained model
18
- learn.fine_tune(3)
19
-
20
-
21
- learn.export('model.pkl')
22
-
23
  learn_inf = load_learner(path/'model.pkl')
24
 
25
-
26
  categories =('Dog','Cat')
27
  def classify_image(img):
28
  pred, idx, probs = learn_inf.predict(img)
@@ -33,4 +15,4 @@ label = gr.outputs.Label()
33
  examples = ['dog.jpeg','cat.jpeg','catdog.jpeg']
34
  intt = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
35
 
36
- iface.launch()
 
1
  import gradio as gr
 
 
 
2
  from fastai.vision.all import * # fastai stuff
 
3
 
4
  def is_cat(x): return x[0].isupper()
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  learn_inf = load_learner(path/'model.pkl')
7
 
 
8
  categories =('Dog','Cat')
9
  def classify_image(img):
10
  pred, idx, probs = learn_inf.predict(img)
 
15
  examples = ['dog.jpeg','cat.jpeg','catdog.jpeg']
16
  intt = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
17
 
18
+ iface.launch(inline=False)