Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
|
4 |
-
# Load the
|
5 |
learn = load_learner('clocker.pkl')
|
6 |
|
7 |
-
def
|
8 |
-
#
|
9 |
-
pred,
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# Return the predicted gender and probabilities
|
15 |
-
return pred, transgender_probs
|
16 |
|
17 |
# Create the Gradio interface
|
18 |
-
|
19 |
-
fn=
|
20 |
-
inputs=gr.Image(
|
21 |
-
outputs=
|
22 |
-
|
23 |
-
|
24 |
-
]
|
25 |
-
examples=[
|
26 |
-
["average_woman.jpg"],
|
27 |
-
["transgender_woman.jpg"]
|
28 |
-
],
|
29 |
-
title="Transfem Clocker",
|
30 |
-
description="Upload a photo of a woman and this will guess if she's trans."
|
31 |
)
|
32 |
|
33 |
# Launch the interface
|
34 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
|
4 |
+
# Load the exported model
|
5 |
learn = load_learner('clocker.pkl')
|
6 |
|
7 |
+
def classify_image(img):
|
8 |
+
# Make a prediction
|
9 |
+
pred, idx, probs = learn.predict(img)
|
10 |
+
return {
|
11 |
+
"average woman": float(probs[0]),
|
12 |
+
"transgender woman": float(probs[1])
|
13 |
+
}
|
|
|
|
|
14 |
|
15 |
# Create the Gradio interface
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=classify_image,
|
18 |
+
inputs=gr.Image(),
|
19 |
+
outputs=gr.Label(num_top_classes=2),
|
20 |
+
title="Woman Type Classifier",
|
21 |
+
description="Upload an image to classify whether it's an average woman or a transgender woman.",
|
22 |
+
examples=["average_woman.jpg"]
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
)
|
24 |
|
25 |
# Launch the interface
|
26 |
+
iface.launch()
|