Spaces:
Running
Running
import json | |
import gradio as gr | |
import os | |
import spaces | |
from tqdm import tqdm | |
from PIL import Image | |
from utils import WaifuScorer | |
SCORER = None | |
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'), | |
outputs=gr.Number(label='Score', precision=2), | |
title='Waifu Scorer V3', | |
description='''Score ranges from 0 to 10, higher is better. | |
[Github](https://github.com/Eugeoter/waifu-scorer) | [Model](https://huggingface.co/Eugeoter/waifu-scorer-v3) | [Inspiration](https://github.com/christophschuhmann/improved-aesthetic-predictor)''', | |
) | |
demo.queue().launch() | |