lohedman commited on
Commit
036c5a3
·
1 Parent(s): b429989

updating the gradio functionality

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,23 +1,25 @@
1
  from fastai.vision.all import *
2
- import gradio as gr #pip install gradio==3.50
3
  import pathlib
4
- #temp = pathlib.PosixPath
5
- #pathlib.PosixPath = pathlib.WindowsPath
6
 
7
- #im = PILImage.create('grizzly.jpg')
8
  learn = load_learner('export.pkl')
9
- #print(learn.predict(im))
 
10
  categories = ('grizzly', 'black', 'teddy')
11
 
 
12
  def classify_image(img):
13
  pred, idx, probs = learn.predict(img)
14
  return dict(zip(categories, map(float,probs)))
15
 
16
- #print(classify_image(im))
17
-
18
- image = gr.inputs.Image(shape=(192,192))
19
- label = gr.outputs.Label()
20
  examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg', 'dunno.jpg']
21
 
 
22
  inft = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
 
 
23
  inft.launch(inline=False)
 
1
  from fastai.vision.all import *
2
+ import gradio as gr
3
  import pathlib
 
 
4
 
5
+ # Load the trained model
6
  learn = load_learner('export.pkl')
7
+
8
+ # Categories for the prediction
9
  categories = ('grizzly', 'black', 'teddy')
10
 
11
+ # Image classification function
12
  def classify_image(img):
13
  pred, idx, probs = learn.predict(img)
14
  return dict(zip(categories, map(float,probs)))
15
 
16
+ # Define the Gradio interface
17
+ image = gr.Image(shape=(192, 192)) # Define the image input with shape
18
+ label = gr.Label() # Output label for the classification result
 
19
  examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg', 'dunno.jpg']
20
 
21
+ # Create the interface
22
  inft = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+
24
+ # Launch the interface
25
  inft.launch(inline=False)
black.jpgZone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://upload.wikimedia.org/wikipedia/commons/0/08/01_Schwarzb%C3%A4r.jpg
dunno.jpgZone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://i.redd.it/is-this-a-brown-grizzly-bear-or-a-black-bear-v0-p2gs8tx9h07b1.jpg?width=1280&format=pjpg&auto=webp&s=de0a2fe5abac9d5ca3a6f6910ff8f144e26bc6e8
export.pklZone.Identifier ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ HostUrl=about:internet
grizzly.jpgZone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://upload.wikimedia.org/wikipedia/commons/a/a9/GrizzlyBearJeanBeaufort.jpg
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio==3.50
2
  fastai
 
1
+ gradio
2
  fastai
teddy.jpgZone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://cdn4.volusion.store/9nxdj-fchy5/v/vspfiles/photos/AR-01779-2.jpg?v-cache=1721046273