AItool commited on
Commit
9565e59
1 Parent(s): 8745b82

Upload 6 files

Browse files
Files changed (6) hide show
  1. README.md +8 -7
  2. app.py +36 -0
  3. dunno.jpg +0 -0
  4. model.pkl +3 -0
  5. real.jpg +0 -0
  6. virtual.jpg +0 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Is Virtualstaging
3
- emoji:
4
- colorFrom: indigo
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.34.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: Minima
3
+ emoji: 📈
4
+ colorFrom: red
5
+ colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 2.9.4
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
+ yep
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pathlib
2
+ temp = pathlib.PosixPath
3
+ pathlib.PosixPath = pathlib.WindowsPath
4
+ #|export
5
+ #fastai has to be available, i.e. fastai folder
6
+ from fastai.vision.all import *
7
+ import gradio as gr
8
+ import pickle
9
+
10
+ with open('./model.pkl', 'rb') as f:
11
+ model = pickle.load(f)
12
+
13
+ def is_real(x): return x[0].isupper()
14
+
15
+ #|export
16
+ learn = load_learner('model.pkl')
17
+
18
+ #|export
19
+ categories =('Virtual Staging','Real')
20
+
21
+ def classify_image(img):
22
+ pred,idx,probs = learn.predict(im)
23
+ return dict(zip(categories,map(float,probs)))
24
+
25
+ #*** We have to cast to float above because KAGGLE does not return number on the answer it returns tensors, and Gradio does not deal with numpy so we have to cast to float
26
+
27
+ #|export
28
+ #import gradio as gr
29
+ import gradio as gr
30
+ image = gr.inputs.Image(shape=(192,192))
31
+ label = gr.outputs.Label()
32
+ examples = ['virtual.jpg','real.jpg','dunno.jpg']
33
+
34
+ intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
35
+ intf.launch(inline=False)
36
+
dunno.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6337cb124584166c7d37484f9f6801d1bd1ef8a3961b8f0c42464e7e88c5f7c
3
+ size 46959761
real.jpg ADDED
virtual.jpg ADDED