classification / app.py
Antoine245's picture
Create app.py
eb23072
raw
history blame
692 Bytes
import gradio as gr
import requests
import torch
from PIL import Image
from transformers import AlignProcessor, AlignModel
processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
model = AlignModel.from_pretrained("kakaobrain/align-base")
pipe = pipeline(model="kakaobrain/align-base")
def image_classifier(image):
outputs = pipe(image)
results = {}
for result in outputs:
results[result['label']] = result['score']
return results
title = "Is it a dog"
description = """
This app is not finished
"""
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label", title=title, description=description)
demo.launch(show_api=False)