Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,16 @@
|
|
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 |
-
|
9 |
-
pred, idx, probs = learn.predict(img)
|
10 |
return {
|
11 |
"average woman": float(probs[0]),
|
12 |
"transgender woman": float(probs[1])
|
@@ -17,9 +21,9 @@ iface = gr.Interface(
|
|
17 |
fn=classify_image,
|
18 |
inputs=gr.Image(),
|
19 |
outputs=gr.Label(num_top_classes=2),
|
20 |
-
title="
|
21 |
-
description="Upload an image
|
22 |
-
|
23 |
)
|
24 |
|
25 |
# Launch the interface
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
|
4 |
+
# Define the GrayscaleTransform class
|
5 |
+
class GrayscaleTransform(Transform):
|
6 |
+
def encodes(self, img: PILImage):
|
7 |
+
return img.convert("L")
|
8 |
+
|
9 |
# Load the exported model
|
10 |
learn = load_learner('clocker.pkl')
|
11 |
|
12 |
def classify_image(img):
|
13 |
+
pred, _, probs = learn.predict(img)
|
|
|
14 |
return {
|
15 |
"average woman": float(probs[0]),
|
16 |
"transgender woman": float(probs[1])
|
|
|
21 |
fn=classify_image,
|
22 |
inputs=gr.Image(),
|
23 |
outputs=gr.Label(num_top_classes=2),
|
24 |
+
title="Transfem Clocker AI",
|
25 |
+
description="Upload an image of a woman and this will guess if she is trans.",
|
26 |
+
|
27 |
)
|
28 |
|
29 |
# Launch the interface
|