bobalbrecht commited on
Commit
53a8393
1 Parent(s): f1dea7c

feat: working now

Browse files
Files changed (3) hide show
  1. activate +1 -0
  2. app.py +10 -23
  3. models/cloudmodel.pkl +2 -2
activate ADDED
@@ -0,0 +1 @@
 
1
+ micromamba activate base
app.py CHANGED
@@ -1,12 +1,4 @@
1
- # import gradio as gr
2
-
3
- # def greet(name):
4
- # return "Hello " + name + "!!"
5
-
6
- # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- # iface.launch()
8
-
9
- __all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
10
 
11
  import gradio as gr
12
  from fastai.vision.all import *
@@ -29,23 +21,18 @@ cloud_categories = (
29
  'Lenticular'
30
  )
31
 
32
- cloud_examples = [image_path / f"{c}.jpg" for c in cloud_categories]
33
-
34
- cloud_learner = load_learner(model_path/'cloudmodel.pkl')
35
 
36
- def is_cat(x): return x[0].isupper()
37
-
38
- learn = load_learner('model.pkl')
39
-
40
- categories = ('Dog', 'Cat')
41
 
42
  def classify_image(img):
43
- pred, idx, probs = learn.predict(img)
44
- return dict(zip(categories, map(float,probs)))
 
45
 
46
- image= gr.inputs.Image(shape=(192, 192))
47
- label = gr.outputs.Label()
48
- examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
 
49
 
50
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
51
  intf.launch(inline=False)
1
+ __all__ = ['cloud_learn', 'classify_image', 'cloud_categories', 'cloud_examples', 'intf']
 
 
 
 
 
 
 
 
2
 
3
  import gradio as gr
4
  from fastai.vision.all import *
21
  'Lenticular'
22
  )
23
 
24
+ cloud_examples = [str(image_path / f"{c}.jpg") for c in cloud_categories]
25
+ cloud_learn = load_learner(model_path/'cloudmodel.pkl')
 
26
 
 
 
 
 
 
27
 
28
  def classify_image(img):
29
+ pred, idx, probs = cloud_learn.predict(img)
30
+ return dict(zip(cloud_categories, map(float,probs)))
31
+
32
 
33
+ intf = gr.Interface(fn=classify_image,
34
+ inputs=gr.inputs.Image(shape=(192, 192)),
35
+ outputs=gr.outputs.Label(),
36
+ examples=cloud_examples)
37
 
 
38
  intf.launch(inline=False)
models/cloudmodel.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:406827942d140e486ec8b53afd3f0376d34d9045dbae151e7af1d22442448ff1
3
- size 102978463
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5db5c0bdfef2a1f7f6883b5f853fe6b330c93a17dee1fa4043272a85bce3a678
3
+ size 103263967