Spaces:
Running
Running
File size: 1,022 Bytes
94b23c1 2f76171 94b23c1 2f76171 94b23c1 87799b5 94b23c1 e938efe 94b23c1 e938efe d6d67f9 e938efe 94b23c1 |
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 35 36 37 38 39 |
import json
import gradio as gr
import os
import spaces
from tqdm import tqdm
from PIL import Image
from utils import WaifuScorer
SCORER = None
@spaces.GPU
def score_image(image: Image.Image) -> float:
global SCORER
if SCORER is None:
SCORER = WaifuScorer(
device='cuda',
verbose=True,
)
return SCORER([image])[0]
demo = gr.Interface(
fn=score_image,
inputs=gr.Image(type='pil', label='Image', height=512),
outputs=gr.Number(label='Score', precision=2),
title='Waifu Scorer V3',
description='''Score ranges from 0 to 10, higher is better\n
[Github](https://github.com/Eugeoter/waifu-scorer) | [Model](https://huggingface.co/Eugeoter/waifu-scorer-v3) | [Inspiration](https://github.com/christophschuhmann/improved-aesthetic-predictor)''',
examples=[
'examples/example_1.jpg',
'examples/example_2.jpg',
'examples/example_3.jpg',
'examples/example_4.jpg',
],
cache_examples=True,
)
demo.queue().launch()
|