CoolFace
Apppublic

universalml/sdf

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py40 linesDownload Raw Back to root
1from transformers import pipeline2import gradio as gr3 4 5modelName = "sdf"6hfUser = "universalml"7 8 9def prediction_function(inputFile):10    # get user name of their hugging face11    modelPath = hfUser + "/" + modelName12    # takes some time13    classifier = pipeline("image-classification", model=modelPath)14 15    try:16        result = classifier(inputFile)17        predictions = dict()18        labels = []19        for eachLabel in result:20            predictions[eachLabel["label"]] = eachLabel["score"]21            labels.append(eachLabel["label"])22        result = predictions23    except:24        result = "no data provided!!"25 26    return result27 28 29# change modelName parameter30def create_demo():31    demo = gr.Interface(32        fn=prediction_function,33        inputs=gr.Image(type="pil"),34        outputs=gr.Label(num_top_classes=3),35    )36    demo.launch()37 38 39create_demo()40