Spaces:
Sleeping
Sleeping
house classifier
Browse files- .gitignore +1 -0
- README.md +2 -2
- alfresco.jpg +0 -0
- app.py +16 -4
- bedroom.jpg +0 -0
- export.pkl +3 -0
- index.html +34 -0
- kitchen.jpg +0 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
classifier/
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: House Classifier
|
3 |
+
emoji: 🏠
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
alfresco.jpg
ADDED
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
def house_classifier(x): return x[0].isupper()
|
|
|
5 |
|
6 |
+
learn = load_learner('export.pkl')
|
7 |
+
|
8 |
+
categories = ('alfresco', 'bathroom', 'bedroom', 'garage', 'house backyard', 'house front', 'kitchen', 'living room', 'scenery', 'theatre room')
|
9 |
+
|
10 |
+
def classify_image(img):
|
11 |
+
pred,idx,probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float,probs)))
|
13 |
+
|
14 |
+
image = gr.Image()
|
15 |
+
label = gr.Label()
|
16 |
+
examples = ['bedroom.jpg', 'kitchen.jpg', 'alfresco.jpg']
|
17 |
+
|
18 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
19 |
+
intf.launch(inline=False)
|
bedroom.jpg
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06164c3d54e8ede5bff251de9379454926332370bbb0854df7b719044f628e01
|
3 |
+
size 47001598
|
index.html
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7 |
+
<title>Cat or Dog predictor</title>
|
8 |
+
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<header>
|
12 |
+
<h1>Predict a dog or cat from an image</h1>
|
13 |
+
<p>Model provided by <a href="https://github.com/fastai/fastai">fastai</a> and api hosted by <a href="https://hf.space/embed/jph00/testing/api" target="_blank">hugging face</a>
|
14 |
+
</p>
|
15 |
+
<a href="https://github.com/nuvic/predict_image" target="_blank">Github Repo</a>
|
16 |
+
</header>
|
17 |
+
<main>
|
18 |
+
<header>
|
19 |
+
<h2>Submit a picture of either a cat or dog</h2>
|
20 |
+
<p id="prediction"></p>
|
21 |
+
<p id="confidences"></p>
|
22 |
+
<p id="error"></p>
|
23 |
+
</header>
|
24 |
+
<section>
|
25 |
+
<img id="myImage" height="400" width="400">
|
26 |
+
<form id="form">
|
27 |
+
<label for="fileInput"></label>
|
28 |
+
<input id="fileInput" type="file" onchange="onFileSelected(event)" name="File">
|
29 |
+
</form>
|
30 |
+
</section>
|
31 |
+
</main>
|
32 |
+
<script src="index.js"></script>
|
33 |
+
</body>
|
34 |
+
</html>
|
kitchen.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
fastai
|