huntrezz commited on
Commit
f3c1019
·
verified ·
1 Parent(s): a710b9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
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
- # Make a prediction
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="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
 
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