File size: 911 Bytes
25b5a23
 
1e1778e
25b5a23
 
1e1778e
 
25b5a23
 
821d811
25b5a23
1e1778e
 
 
 
 
 
 
 
 
25b5a23
 
1e1778e
25b5a23
1e1778e
 
 
 
 
 
 
25b5a23
1e1778e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio
import torch
from transformers import AutoImageProcessor, MobileNetV2ForImageClassification

image_processor = AutoImageProcessor.from_pretrained("Aruno/gemini-beauty")
model = MobileNetV2ForImageClassification.from_pretrained("Aruno/gemini-beauty")


def inference(img):
    inputs = image_processor(img, return_tensors="pt")
    with torch.no_grad():
        outputs = model(**inputs).logits[0]
        outputs = outputs.softmax(dim=0)
        outputs = {
            "attractive": outputs[0],
            "normal": outputs[1],
            "ugly": outputs[2],
            "very attractive": outputs[3],
            "very_ugly": outputs[4],
        }
    return outputs


iface = gradio.Interface(
    fn=inference,
    inputs="image",
    outputs="label",
    title="Your Attractivness",
    description="Check your attractivness",
    examples=["face_01.jpg", "face_02.jpg"],
)

iface.launch()