christinapeng commited on
Commit
87839c4
·
1 Parent(s): e091b5a

last attempt

Browse files
Files changed (2) hide show
  1. app.py +11 -1
  2. model_weights.pth +3 -0
app.py CHANGED
@@ -4,12 +4,22 @@ import gradio as gr
4
  import sys
5
  print(f"Python version: {sys.version}")
6
 
7
- learn = load_learner('model.pkl')
 
 
 
 
 
 
 
 
 
8
 
9
  categories = ('Penguin', 'Puffin')
10
 
11
  def classifyImage(img):
12
  pred, idx, prob = learn.predict(img)
 
13
  return dict(zip(categories, map(float, prob)))
14
 
15
  image = gr.Image(shape=(192, 192))
 
4
  import sys
5
  print(f"Python version: {sys.version}")
6
 
7
+ birds = DataBlock(
8
+ blocks=(ImageBlock, CategoryBlock),
9
+ get_items=get_image_files,
10
+ splitter=RandomSplitter(valid_pct=0.2, seed=42),
11
+ get_y=parent_label,
12
+ item_tfms=Resize(128))
13
+
14
+ learn = vision_learner(dls, resnet34, metrics=accuracy)
15
+
16
+ learn.load("model_weights")
17
 
18
  categories = ('Penguin', 'Puffin')
19
 
20
  def classifyImage(img):
21
  pred, idx, prob = learn.predict(img)
22
+ print(f"Predicted {pred} with p={prob[idx]:.4f}")
23
  return dict(zip(categories, map(float, prob)))
24
 
25
  image = gr.Image(shape=(192, 192))
model_weights.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90570b1806509443777e814e00c99bbfcc118a756fa3d9f058f744e21d2925bf
3
+ size 46912474