exvertus commited on
Commit
412b855
·
1 Parent(s): f5f849b

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Fastai Season Guesser
3
- emoji: 💻
4
- colorFrom: yellow
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 4.13.0
8
  app_file: app.py
9
- pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: fastai-season-guesser
 
 
 
 
 
3
  app_file: app.py
4
+ sdk: gradio
5
+ sdk_version: 4.11.0
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner, PILImage
2
+ from pathlib import Path
3
+ import gradio
4
+
5
+ here = Path(__file__).parent
6
+ predicter = load_learner(here / 'seasons.pkl')
7
+
8
+ labels = predicter.dls.vocab
9
+
10
+ def predict(img):
11
+ _img = PILImage.create(img)
12
+ _, _, probabilities = predicter.predict(_img)
13
+ return {labels[i]: float(prob) for i, prob in enumerate(probabilities)}
14
+
15
+ example_dir = here / 'test'
16
+ gradio.Interface(
17
+ fn=predict,
18
+ inputs=gradio.Image(),
19
+ outputs=gradio.Label(num_top_classes=3),
20
+ title='Season Guesser',
21
+ description='What season is this image?',
22
+ article="<p style='text-align: center'><a href='https://github.com/exvertus/fastai-coursework/tree/main/one/seasons' target='_blank'>See the code</a></p>",
23
+ examples=[
24
+ example_dir / 'summer.jpg',
25
+ example_dir / 'winter.jpg',
26
+ example_dir / 'autumn.jpg',
27
+ example_dir / 'winter-art.jpg',
28
+ ]
29
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastai
2
+ fastbook
3
+ gradio
seasons.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca807b04528dfb2ec052adf1b6fc1410089aa77de5521260064ac469dd771701
3
+ size 87480854
test/autumn.jpg ADDED
test/summer.jpg ADDED
test/winter-art.jpg ADDED
test/winter.jpg ADDED
train_model.ipynb ADDED
The diff for this file is too large to render. See raw diff