Spaces:
Sleeping
Sleeping
initial commit
Browse files- README.md +4 -3
- app.py +28 -0
- labradoodle.jpg +0 -0
- model.pkl +3 -0
- poetry.lock +0 -0
- pyproject.toml +19 -0
README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
---
|
2 |
title: Poodle Or Doodle
|
3 |
-
emoji:
|
4 |
colorFrom: red
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.40.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
11 |
---
|
12 |
|
13 |
-
|
|
|
1 |
---
|
2 |
title: Poodle Or Doodle
|
3 |
+
emoji: 🐶
|
4 |
colorFrom: red
|
5 |
+
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.40.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
short_description: Upload an image and see if it's a poodle or doodle.
|
12 |
---
|
13 |
|
14 |
+
A small Gradio app backed by a fine-tuned resnet18 model for predicting if you're looking at a standard poodle or a labradoodle.
|
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
learn = load_learner("model.pkl")
|
6 |
+
|
7 |
+
|
8 |
+
def predict(img):
|
9 |
+
# use PIL to resize the image to 224x224
|
10 |
+
img = Image.fromarray(img)
|
11 |
+
pred, pred_idx, probs = learn.predict(img)
|
12 |
+
# if the prediction contains poodle, return poodle
|
13 |
+
if "poodle" in pred:
|
14 |
+
return "poodle"
|
15 |
+
return "doodle"
|
16 |
+
|
17 |
+
|
18 |
+
title = "Poodle or Doodle"
|
19 |
+
description = "A resnet18 model fine tuned on 400 images of poodles and labradoodles. You can predict using the default image or upload an image an image of your own to see if you're looking at a poodle or doodle."
|
20 |
+
|
21 |
+
gr.Interface(
|
22 |
+
fn=predict,
|
23 |
+
inputs=gr.Image(value="labradoodle.jpg"),
|
24 |
+
outputs=gr.Label(),
|
25 |
+
title=title,
|
26 |
+
description=description,
|
27 |
+
allow_flagging="never",
|
28 |
+
).launch()
|
labradoodle.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e2fc9b0b3ae80537a281f2d712512335d08ad6f606bfe50360d50a60a3ee664a
|
3 |
+
size 87468778
|
poetry.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.poetry]
|
2 |
+
name = "poodle-or-doodle"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = "A small Gradio app for seeing if the image is a poodle or labradoodle backed by a fine-tuned resnet18 model"
|
5 |
+
authors = ["jsulz <[email protected]>"]
|
6 |
+
license = "MIT"
|
7 |
+
readme = "README.md"
|
8 |
+
package-mode = false
|
9 |
+
|
10 |
+
[tool.poetry.dependencies]
|
11 |
+
python = "3.12.2"
|
12 |
+
gradio = "4.40.0"
|
13 |
+
fastai = "^2.7.16"
|
14 |
+
pillow = "^10.4.0"
|
15 |
+
|
16 |
+
|
17 |
+
[build-system]
|
18 |
+
requires = ["poetry-core"]
|
19 |
+
build-backend = "poetry.core.masonry.api"
|