Spaces:
Runtime error
Runtime error
Commit
·
eb23072
1
Parent(s):
d25dfc4
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import torch
|
4 |
+
from PIL import Image
|
5 |
+
from transformers import AlignProcessor, AlignModel
|
6 |
+
|
7 |
+
processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
|
8 |
+
model = AlignModel.from_pretrained("kakaobrain/align-base")
|
9 |
+
|
10 |
+
pipe = pipeline(model="kakaobrain/align-base")
|
11 |
+
|
12 |
+
def image_classifier(image):
|
13 |
+
outputs = pipe(image)
|
14 |
+
results = {}
|
15 |
+
for result in outputs:
|
16 |
+
results[result['label']] = result['score']
|
17 |
+
return results
|
18 |
+
title = "Is it a dog"
|
19 |
+
description = """
|
20 |
+
This app is not finished
|
21 |
+
"""
|
22 |
+
|
23 |
+
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label", title=title, description=description)
|
24 |
+
demo.launch(show_api=False)
|