Aruno commited on
Commit
1e1778e
1 Parent(s): 821d811

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -11
app.py CHANGED
@@ -1,23 +1,33 @@
1
  import gradio
2
- from transformers import AutoImageProcessor, MobileNetV2Model
3
  import torch
4
- from datasets import load_dataset
5
 
6
  image_processor = AutoImageProcessor.from_pretrained("Aruno/gemini-beauty")
7
- model = MobileNetV2Model.from_pretrained("Aruno/gemini-beauty")
 
8
 
9
  def inference(img):
10
  inputs = image_processor(img, return_tensors="pt")
11
  with torch.no_grad():
12
- outputs = model(**inputs)
 
 
 
 
 
 
 
 
13
  return outputs
14
 
 
15
  iface = gradio.Interface(
16
- fn=inference,
17
- inputs='image',
18
- outputs='image',
19
- title='Your Attractivness',
20
- description='Check your attractivness',
21
- examples=["face_01.jpg", "face_02.jpg"])
 
22
 
23
- iface.launch()
 
1
  import gradio
 
2
  import torch
3
+ from transformers import AutoImageProcessor, MobileNetV2ForImageClassification
4
 
5
  image_processor = AutoImageProcessor.from_pretrained("Aruno/gemini-beauty")
6
+ model = MobileNetV2ForImageClassification.from_pretrained("Aruno/gemini-beauty")
7
+
8
 
9
  def inference(img):
10
  inputs = image_processor(img, return_tensors="pt")
11
  with torch.no_grad():
12
+ outputs = model(**inputs).logits[0]
13
+ outputs = outputs.softmax(dim=0)
14
+ outputs = {
15
+ "attractive": outputs[0],
16
+ "normal": outputs[1],
17
+ "ugly": outputs[2],
18
+ "very attractive": outputs[3],
19
+ "very_ugly": outputs[4],
20
+ }
21
  return outputs
22
 
23
+
24
  iface = gradio.Interface(
25
+ fn=inference,
26
+ inputs="image",
27
+ outputs="label",
28
+ title="Your Attractivness",
29
+ description="Check your attractivness",
30
+ examples=["face_01.jpg", "face_02.jpg"],
31
+ )
32
 
33
+ iface.launch()