Spaces:
Runtime error
Runtime error
tabaochoke
commited on
Commit
·
ce35a1d
1
Parent(s):
489df57
complete
Browse files- 1 (1004).jpg +0 -0
- 10010892_result.jpg +0 -0
- 10019581_result.jpg +0 -0
- 498970d2f45988eae9d6a2eb59bc450f.jpg +0 -0
- app.py +29 -4
- learner.pkl +3 -0
1 (1004).jpg
ADDED
![]() |
10010892_result.jpg
ADDED
![]() |
10019581_result.jpg
ADDED
![]() |
498970d2f45988eae9d6a2eb59bc450f.jpg
ADDED
![]() |
app.py
CHANGED
@@ -1,7 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from fastcore.all import *
|
4 |
+
from fastai.vision.all import *
|
5 |
+
from fastai.vision.widgets import *
|
6 |
+
import pickle
|
7 |
+
import torch
|
8 |
|
9 |
+
|
10 |
+
def label_func (f):
|
11 |
+
return f[:2] !="1 "
|
12 |
+
|
13 |
+
Pkl_Filename = "learner.pkl"
|
14 |
+
with open(Pkl_Filename, 'rb') as file:
|
15 |
+
learn = torch.load ( file , map_location=torch.device('cpu') )
|
16 |
+
|
17 |
+
category = ("Waifu" , "Human")
|
18 |
+
def infer_im (im ) :
|
19 |
+
pre , idx , prob = learn.predict (im)
|
20 |
+
flo_prob = list ( map (float , prob) )[0]
|
21 |
+
return dict ( zip (category , ( flo_prob , 1 - flo_prob ) ) )
|
22 |
+
|
23 |
+
|
24 |
+
examples = ["1 (1004).jpg",
|
25 |
+
"498970d2f45988eae9d6a2eb59bc450f.jpg" ,
|
26 |
+
"10010892_result.jpg" ,
|
27 |
+
"10019581_result.jpg"]
|
28 |
+
|
29 |
+
gr.Interface(fn= infer_im,
|
30 |
+
inputs=gr.inputs.Image(shape=(128 , 128)),
|
31 |
+
outputs=gr.outputs.Label(num_top_classes=2) ,
|
32 |
+
examples = examples ).launch(inline = False)
|
learner.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:92c7c6d0ee3a6fda84aa09011f0600388ec4569d34b91367bfa1c3b028ef8ad9
|
3 |
+
size 141517491
|