clip-embedding / app.py
barabum's picture
auth
2be815a
raw
history blame contribute delete
No virus
450 Bytes
import gradio as gr
import numpy as np
from PIL import Image
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('clip-ViT-B-32')
def image_to_embedding(img: np.ndarray):
embedding = model.encode(sentences=[Image.fromarray(img)], batch_size=128)
return embedding
iface = gr.Interface(fn=image_to_embedding, inputs="image", outputs="textbox", cache_examples=True)
iface.launch(auth=("Cdpv9i6Q", "R206pqYF"))