Spaces:
Running
Running
File size: 878 Bytes
21d686f 3b5549d 21d686f 1c903c0 21d686f 2aa6bfd a6f56a5 21d686f |
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 |
from transformers import pipeline
import gradio as gr
modelName = "Deepfake-image"
hfUser = "Hemg"
def prediction_function(inputFile):
# get user name of their hugging face
modelPath = hfUser + "/" + modelName
# takes some time
classifier = pipeline("image-classification", model=modelPath)
try:
result = classifier(inputFile)
predictions = dict()
labels = []
for eachLabel in result:
predictions[eachLabel["label"]] = eachLabel["score"]
labels.append(eachLabel["label"])
result = predictions
except:
result = "no data provided!!"
return result
# change modelName parameter
def create_demo():
demo = gr.Interface(
fn=prediction_function,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=2),
)
demo.launch()
create_demo() |