Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,33 @@
|
|
1 |
import gradio
|
2 |
-
from transformers import AutoImageProcessor, MobileNetV2Model
|
3 |
import torch
|
4 |
-
from
|
5 |
|
6 |
image_processor = AutoImageProcessor.from_pretrained("Aruno/gemini-beauty")
|
7 |
-
model =
|
|
|
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 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
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()
|