File size: 1,104 Bytes
d3119f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98dbf51
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

pipe_aesthetic = pipeline("image-classification", "cafeai/cafe_aesthetic")
def aesthetic(input_img):
    data = pipe_aesthetic(input_img, top_k=2)
    final = {}
    for d in data:
        final[d["label"]] = d["score"]
    return final
demo_aesthetic = gr.Interface(fn=aesthetic, inputs=gr.Image(type="pil"), outputs=gr.Label(label="aesthetic"))

pipe_style = pipeline("image-classification", "cafeai/cafe_style")
def style(input_img):
    data = pipe_style(input_img, top_k=5)
    final = {}
    for d in data:
        final[d["label"]] = d["score"]
    return final
demo_style = gr.Interface(fn=style, inputs=gr.Image(type="pil"), outputs=gr.Label(label="style"))

pipe_waifu = pipeline("image-classification", "cafeai/cafe_waifu")
def waifu(input_img):
    data = pipe_waifu(input_img, top_k=5)
    final = {}
    for d in data:
        final[d["label"]] = d["score"]
    return final
demo_waifu = gr.Interface(fn=waifu, inputs=gr.Image(type="pil"), outputs=gr.Label(label="waifu"))

gr.Parallel(demo_aesthetic, demo_style, demo_waifu).launch()