muellerzr HF staff commited on
Commit
98e8a80
1 Parent(s): 2b5d2b6

Initial with fastai

Browse files
Files changed (4) hide show
  1. exported_fastai.pkl +3 -0
  2. requirements.txt +7 -0
  3. src/__init__.py +0 -0
  4. src/app.py +19 -0
exported_fastai.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2efcd6c1dcde8806b674d596d0a3dbf6b38d5eab048a5e8d9374dd53e69410eb
3
+ size 22805785
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio=="3.18.0"
2
+ fastai=="2.7.10"
3
+ fastcore=="1.5.28"
4
+ pillow=="9.4.0"
5
+ timm=="0.6.12"
6
+ torch=="1.13.1"
7
+ torchvision=="0.14.1"
src/__init__.py ADDED
File without changes
src/app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.learner import load_learner
3
+ from fastai.vision.core import PILImage
4
+
5
+ # Load the model
6
+ learn = load_learner('../exported_fastai.pkl', cpu=False)
7
+
8
+ def classify_image(inp):
9
+ inp = PILImage.create(inp)
10
+ pred, _, _ = learn.predict(inp)
11
+ return pred
12
+
13
+ iface = gr.Interface(
14
+ fn=classify_image,
15
+ inputs=gr.inputs.Image(),
16
+ outputs="text",
17
+ title="Fastai Classifier",
18
+ description="An example of using Fastai in Gradio.",
19
+ ).launch()